blob: 6cf002d50807b6a809e36e589ff82101ff6ba450 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/bin/sh
set -o nounset
TIME="${TIME-/usr/bin/time}"
echo "SUITE: time(1)"
what $TIME
echo
EXIT=0
echo TEST: check real time
TIME_SLEEP=`$TIME 2>&1 sleep 1 | sed -n -E 's/[ ]+([0-9]+).*/\1/p'`
TIME_STATUS=$?
if [ "$TIME_STATUS" -ne "0" ]; then
echo FAIL: time failed with "$TIME_STATUS"
EXIT=1
fi
if [ "$TIME_SLEEP" -lt "0" ]; then
echo FAIL: time mis-timed sleep
EXIT=2
fi
MONOTONIC=`sysctl -n kern.monotonic.task_thread_counting`
if [ "$MONOTONIC" -ne "0" ]; then
echo TEST: check instructions retired
TIME_INSTRS=`$TIME -l 2>&1 sleep 1 | sed -E -n '/instructions/p'`
if [ -z "$TIME_INSTRS" ]; then
echo FAIL: time is not showing instructions retired
EXIT=3
fi
else
echo SKIP: check instructions retired
fi
# NB: SIGINT and SIGQUIT work locally, but the automated test harnesses tries to
# handle those signals itself before the fork.
echo TEST: check child SIGUSR1
TIME_USR1=`$TIME 2>&1 sh -c 'kill -USR1 $$ && sleep 5 && true'`
TIME_STATUS=$?
if [ "$TIME_STATUS" -eq "0" ]; then
echo FAIL: time should allow child to receive SIGUSR1
EXIT=4
fi
echo TEST: check non-existent binary
TIME_NONEXIST=`$TIME 2>&1 ./this-wont-exist`
TIME_STATUS=$?
if [ "$TIME_STATUS" -ne "127" ]; then
echo FAIL: time should error when measuring a non-existent command
EXIT=5
fi
exit $EXIT
|