1#!/bin/sh
2
3# Check whether -c and -w options work.
4
5. "${srcdir=.}/init.sh"
6
7check_prog sleep
8check_prog grep
9
10make_log()
11{
12	$STRACE $args > $LOG 2>&1 || {
13		cat $LOG
14		fail_ "$STRACE $args failed"
15	}
16}
17
18grep_log()
19{
20	LC_ALL=C grep -E -x -e "$*" $LOG > /dev/null || {
21		cat $LOG
22		fail_ "unexpected output from $STRACE $args"
23	}
24}
25
26args='-c sleep 1'
27make_log
28grep nanosleep $LOG > /dev/null ||
29	skip_ 'sleep does not use nanosleep'
30grep_log ' *[^ ]+ +0\.0[^n]*nanosleep'
31
32args='-c -enanosleep sleep 1'
33make_log
34grep_log ' *[^ ]+ +0\.0[^n]*nanosleep'
35
36args='-cw sleep 1'
37make_log
38grep_log ' *[^ ]+ +(1\.0|0\.99)[^n]*nanosleep'
39
40args='-cw -enanosleep sleep 1'
41make_log
42grep_log '100\.00 +(1\.0|0\.99)[^n]*nanosleep'
43
44exit 0
45