~nabijaczleweli/voreutils

ref: 5a4de15fa57068c5e4fe56192c37c3bcc069990c voreutils/tests/sleep -rwxr-xr-x 525 bytes
5a4de15fнаб Add sleep 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
# SPDX-License-Identifier: 0BSD

sleep="${CMDDIR}sleep"

:                 ; 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