8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / dtrace / test / tst / common / pragma / tst.temporal2.ksh
blob4e8d592d81d62e60d6170aea64e2638b1851153b
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, even when some
24 # buffers are empty
26 # SECTION: Pragma
28 # NOTES: The temporal option has no effect on a single-CPU system, so
29 # this needs to be run on a multi-CPU system to effectively test the
30 # temporal option.
32 ############################################################################
34 if [ $# != 1 ]; then
35 echo expected one argument: '<'dtrace-path'>'
36 exit 2
39 dtrace=$1
40 file=/tmp/out.$$
42 rm -f $file
44 $dtrace -o $file -s /dev/stdin <<EOF
45 #pragma D option quiet
46 #pragma D option destructive
47 #pragma D option temporal
48 #pragma D option switchrate=1000hz
51 * Use two enablings of the same probe, so that cpu 0 will always
52 * record its data just a little bit before the other cpus.
53 * We don't want to use the chill() action in the same enabling
54 * that we record the timestamp, because chill() causes the
55 * timestamp to be re-read, and thus not match the timestamp
56 * which libdtrace uses to sort the records.
59 profile-401
60 /cpu == 0/
62 printf("%d\n", timestamp);
65 profile-401
66 /cpu != 0/
68 chill(1000); /* one microsecond */
71 profile-401
72 /cpu != 0/
74 printf("%d\n", timestamp);
77 tick-1s
78 /k++ == 10/
80 printf("%d\n", timestamp);
81 exit(0);
83 EOF
85 status=$?
86 if [ "$status" -ne 0 ]; then
87 echo $tst: dtrace failed
88 exit $status
91 # dtrace outputs a blank line at the end, which will sort to the beginning,
92 # so use grep to remove the blank line.
93 head -n -1 $file > $file.2
95 sort -n $file.2 | diff $file.2 -
96 status=$?
97 if [ "$status" -ne 0 ]; then
98 echo $tst: output is not sorted
99 exit $status
102 exit $status