8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / dtrace / test / tst / common / pragma / tst.temporal.ksh
blob9a0aed0678cf06e68a335198276e5fa254a907b4
1 #!/bin/ksh -p
3 # CDDL HEADER START
5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
8 # 1.0 of the CDDL.
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy of the CDDL is also available via the Internet at
12 # http://www.illumos.org/license/CDDL.
14 # CDDL HEADER END
18 # Copyright (c) 2012 by Delphix. All rights reserved.
21 ############################################################################
22 # ASSERTION:
23 # temporal option causes output to be sorted
25 # SECTION: Pragma
27 # NOTES: The temporal option has no effect on a single-CPU system, so
28 # this needs to be run on a multi-CPU system to effectively test the
29 # temporal option.
31 ############################################################################
33 if [ $# != 1 ]; then
34 echo expected one argument: '<'dtrace-path'>'
35 exit 2
38 dtrace=$1
39 file=/tmp/out.$$
41 rm -f $file
43 $dtrace -o $file -c 'sleep 3' -s /dev/stdin <<EOF
44 #pragma D option quiet
45 #pragma D option temporal
47 BEGIN
49 @lines = count();
50 printf("0 begin\n");
53 END
55 /* Bump @lines every time we print a line. */
56 @lines = count();
57 printf("%u end\n", timestamp);
58 @lines = count();
59 printa("99999999999999999 lines %@u\n", @lines);
62 profile-97hz
64 @lines = count();
65 printf("%u\n", timestamp);
67 EOF
69 status=$?
70 if [ "$status" -ne 0 ]; then
71 echo $tst: dtrace failed
72 exit $status
75 # dtrace outputs a blank line at the end, which will sort to the beginning,
76 # so use head to remove the blank line.
77 head -n -1 $file > $file.2
79 sort -n $file.2 | diff $file.2 -
80 status=$?
81 if [ "$status" -ne 0 ]; then
82 echo $tst: output is not sorted
83 exit $status
86 head -n 1 $file.2 | grep begin >/dev/null
87 status=$?
88 if [ "$status" -ne 0 ]; then
89 echo $tst: begin probe did not fire
90 exit $status
93 tail -n 2 $file.2 | grep end >/dev/null
94 status=$?
95 if [ "$status" -ne 0 ]; then
96 echo $tst: end probe did not fire
97 exit $status
100 if [ $(tail -n 1 $file.2 | cut -f3 -d ' ') -ne \
101 $(wc -l $file.2) ]; then
102 echo $tst: incorrect number of lines output
103 exit 1
106 exit $status