~nabijaczleweli/voreutils

ref: cb91cf21c628ab3d5e42d89694d99fcca6c8efc8 voreutils/tests/sleep -rwxr-xr-x 658 bytes
cb91cf21наб Add uname (and arch). Centralise spaced print 4 months ago
                                                                                
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
#!/bin/sh
# SPDX-License-Identifier: 0BSD

sleep="${CMDDIR}sleep"

case "$(date +"%s.%N")" in
	*N)
		echo "sleep: skipping, date(1) doesn't support %N" >&2
		exit
		;;
	*)
		format="%s.%N"
		;;
esac

:                 ; p0="$(date +"%s.%N")"
"$sleep" 0.2      ; p1="$(date +"%s.%N")"
"$sleep" 0.1 .1   ; p2="$(date +"%s.%N")"
"$sleep" 0.1s 0.1s; p3="$(date +"%s.%N")"
"$sleep" 1.388e-4h; p4="$(date +"%s.%N")"

i=0
{
	echo "(($p1 - $p0) - .2) < .01"
	echo "(($p2 - $p1) - .2) < .01"
	echo "(($p3 - $p2) - .2) < .01"
	echo "(($p4 - $p3) - .5) < .01"
} | bc | while read -r ok; do
	i=$(( i + 1 ))
	[ "$ok" -eq 1 ] || echo "sleep: expression $i wrong" >&3
done