PageRenderTime 118ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.func.ksh

https://github.com/okuoku/freebsd-head
Korn Shell | 74 lines | 32 code | 9 blank | 33 comment | 4 complexity | 285b1f0d9dd5ece04a66a4ea49243016 MD5 | raw file
  1. #
  2. # CDDL HEADER START
  3. #
  4. # The contents of this file are subject to the terms of the
  5. # Common Development and Distribution License (the "License").
  6. # You may not use this file except in compliance with the License.
  7. #
  8. # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  9. # or http://www.opensolaris.org/os/licensing.
  10. # See the License for the specific language governing permissions
  11. # and limitations under the License.
  12. #
  13. # When distributing Covered Code, include this CDDL HEADER in each
  14. # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15. # If applicable, add the following below this CDDL HEADER, with the
  16. # fields enclosed by brackets "[]" replaced with your own identifying
  17. # information: Portions Copyright [yyyy] [name of copyright owner]
  18. #
  19. # CDDL HEADER END
  20. #
  21. #
  22. # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
  23. # Use is subject to license terms.
  24. #
  25. # ident "%Z%%M% %I% %E% SMI"
  26. script()
  27. {
  28. $dtrace -qs /dev/stdin <<EOF
  29. profile-1234hz
  30. /arg0 != 0/
  31. {
  32. @[func(arg0)] = count();
  33. }
  34. tick-100ms
  35. /i++ == 50/
  36. {
  37. exit(0);
  38. }
  39. EOF
  40. }
  41. spinny()
  42. {
  43. while true; do
  44. /usr/bin/date > /dev/null
  45. done
  46. }
  47. if [ $# != 1 ]; then
  48. echo expected one argument: '<'dtrace-path'>'
  49. exit 2
  50. fi
  51. dtrace=$1
  52. spinny &
  53. child=$!
  54. #
  55. # This is gutsy -- we're assuming that mutex_enter(9F) will show up in the
  56. # output. This is most likely _not_ to show up in the output if the
  57. # platform does not support arbitrary resolution interval timers -- but
  58. # the above script was stress-tested down to 100 hertz and still ran
  59. # successfully on all platforms, so one is hopeful that this test will pass
  60. # even in that case.
  61. #
  62. script | tee /dev/fd/2 | grep mutex_enter > /dev/null
  63. status=$?
  64. kill $child
  65. exit $status