Print this page
12197 sleeptest is failing
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/test/util-tests/tests/sleep/sleeptest.ksh
+++ new/usr/src/test/util-tests/tests/sleep/sleeptest.ksh
1 1 #!/bin/ksh
2 2 #
3 3 # This file and its contents are supplied under the terms of the
4 4 # Common Development and Distribution License ("CDDL"), version 1.0.
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
5 5 # You may only use this file in accordance with the terms of version
6 6 # 1.0 of the CDDL.
7 7 #
8 8 # A full copy of the text of the CDDL should have accompanied this
9 9 # source. A copy of the CDDL is also available via the Internet at
10 10 # http://www.illumos.org/license/CDDL.
11 11 #
12 12
13 13 #
14 14 # Copyright 2019 Robert Mustacchi
15 +# Copyright 2020 Joyent, Inc.
15 16 #
16 17
17 18 #
18 19 # Basic tests of sleep(1). sleep is a little hard to test, especially
19 20 # for longer running cases. Therefore to test it, we basically take
20 21 # advantage of our knowledge of how it is implemented. We see that it
21 22 # properly is sleeping for the right amount of time by looking at the
22 23 # call to nanosleep in libc and make sure that the structures time is
23 24 # what we expect.
24 25 #
25 26
26 27 unalias -a
27 28 set -o pipefail
28 29
29 30 #
30 31 # Set the locale for the start of the test to be C.UTF-8 to make sure
31 32 # that we have a good starting point and correct fractional
32 33 # interpretation.
33 34 #
34 35 export LC_ALL=C.UTF-8
35 36
36 37 sleep_arg0="$(basename $0)"
37 38 sleep_prog=/usr/bin/sleep
38 39 sleep_dir="$(dirname $0)"
39 40 sleep_dscript=$sleep_dir/sleep.d
40 41 sleep_awk=$sleep_dir/sleep.awk
41 42 sleep_exit=0
42 43
43 44 #
44 45 # This is the factor by which we're going to basically say that the slp
45 46 # microstate has to complete within. Because the system will usually
46 47 # have a bit of additional latency, we will usually be greater than that
47 48 # as well. This determines how much we should actually do that by.
48 49 #
49 50 sleep_factor=1.5
50 51
51 52 warn()
52 53 {
53 54 typeset msg="$*"
54 55 [[ -z "$msg" ]] && msg="failed"
55 56 echo "TEST FAILED: $sleep_arg0: $msg" >&2
56 57 }
57 58
58 59 sleep_bound()
59 60 {
60 61 typeset min=$1
61 62 typeset test="sleep $min: bounding"
62 63
63 64 ptime -m $sleep_prog $min 2>&1 | nawk -f $sleep_awk min=$min \
64 65 factor=$sleep_factor
65 66 if [[ $? -ne 42 ]]; then
66 67 warn "$test"
67 68 sleep_exit=1
68 69 else
69 70 printf "TEST PASSED: %s\n" "$test"
70 71 fi
71 72 }
72 73
73 74 sleep_one()
74 75 {
75 76 typeset arg=$1
76 77 typeset secs=$2
77 78 typeset nsecs=$3
78 79 typeset test="sleep $arg: $secs secs $nsecs ns"
79 80
80 81 if ! dtrace -qws $sleep_dscript -c "$sleep_prog $arg" $secs $nsecs; then
81 82 warn "$test"
82 83 sleep_exit=1
83 84 else
84 85 printf "TEST PASSED: %s\n" "$test"
85 86 fi
86 87 }
87 88
88 89 sleep_err()
89 90 {
90 91 typeset test="negative test: sleep $*"
91 92
92 93 if $sleep_prog $* 2>/dev/null; then
93 94 warn "$test"
94 95 sleep_exit=1
95 96 else
96 97 printf "TEST PASSED: %s\n" "$test"
97 98 fi
98 99 }
99 100
100 101 if [[ -n $SLEEP ]]; then
101 102 sleep_prog=$SLEEP
102 103 fi
103 104
104 105 #
105 106 # First test basic integer values. Both in base 10 and hex.
106 107 #
107 108 sleep_one 1 1 0
108 109 sleep_one 23 23 0
109 110 sleep_one 0xff 0xff 0
110 111 sleep_one 123456789 123456789 0
111 112 sleep_one 1e8 100000000 0
112 113
113 114 #
114 115 # Fractional values.
115 116 #
116 117 sleep_one 2.5 2 500000000
117 118 sleep_one 0.9 0 900000000
118 119 sleep_one 34.0051 34 5100000
119 120 sleep_one 0x654.100 0x654 62500000
120 121
121 122 #
122 123 # Large values that are basically the same as infinity. The current
123 124 # implementation will do a sleep in groups of INT32_MAX at a time. So
124 125 # make sure our large values are the same.
125 126 #
126 127 sleep_one Inf 0x7fffffff 0
127 128 sleep_one +Inf 0x7fffffff 0
128 129 sleep_one 1e100 0x7fffffff 0
129 130 sleep_one 0x123456789abc 0x7fffffff 0
130 131
131 132 #
132 133 # That all of our suffixes for time increments work and make sense.
133 134 #
134 135 sleep_one 1s 1 0
135 136 sleep_one 1m 60 0
136 137 sleep_one 1h 3600 0
137 138 sleep_one 1d 86400 0
138 139 sleep_one 1w 604800 0
139 140 sleep_one 1y 31536000 0
140 141
141 142 sleep_one 3.5s 3 500000000
142 143 sleep_one 3.6d 311040 0
143 144 sleep_one 2.001y 63103536 0
144 145
145 146 #
146 147 # Now we need to go through and use ptime -m to get the slp time for
147 148 # things and make sure it is always greater than what we asked for and
148 149 # less than a bound.
149 150 #
150 151 sleep_bound 0.01
151 152 sleep_bound 0.1
152 153 sleep_bound 0.25
153 154 sleep_bound 0.5
154 155 sleep_bound 0.75
155 156
156 157 #
157 158 # The next set of tests are negative tests that make sure that sleep
158 159 # does not correctly execute in these cases.
159 160 #
160 161 sleep_err \"\"
↓ open down ↓ |
136 lines elided |
↑ open up ↑ |
161 162 sleep_err 1 2 3
162 163 sleep_err 1@23
163 164 sleep_err 0,56
164 165 sleep_err "hello"
165 166 sleep_err s
166 167 sleep_err 1z
167 168 sleep_err -- -0.3
168 169
169 170 #
170 171 # Test a locale that uses a ',' character (de_DE.UTF-8 is one) as the
171 -# decimal point to make sure that sleep correctly is using LC_NUMERIC.
172 -#
173 -export LANG=de_DE.UTF-8
172 +# decimal point to make sure that sleep is correctly using LC_NUMERIC.
173 +export LC_ALL=de_DE.UTF-8
174 174 sleep_err 21.45
175 175 sleep_one 2,5 2 500000000
176 176 sleep_one 34,0051 34 5100000
177 177 sleep_one 3,6d 311040 0
178 -export LANG=C.UTF-8
178 +export LC_ALL=C.UTF-8
179 179
180 180 exit $sleep_exit
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX