~nabijaczleweli/voreutils

ref: cb91cf21c628ab3d5e42d89694d99fcca6c8efc8 voreutils/tests/uname -rwxr-xr-x 1.9 KiB
cb91cf21наб Add uname (and arch). Centralise spaced print a month 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
# SPDX-License-Identifier: 0BSD

tmpdir="$(mktemp -dt "uname.XXXXXXXXXX")/"
uname="${CMDDIR}uname"

altname="${tmpdir%/}"
altname="${altname##*/}"

ln -fs "$uname" "${tmpdir}uname"
ln -fs "$uname" "${tmpdir}arch"
ln -fs "$uname" "${tmpdir}something-else"
ln -fs "$uname" "${tmpdir}$altname"

"${tmpdir}uname" > /dev/null; err=$?
[ $err -eq 0 ] || echo "uname: got $err instead of 0 for uname" >&3
"${tmpdir}arch" > /dev/null; err=$?
[ $err -eq 0 ] || echo "uname: got $err instead of 1 for arch" >&3
errstr="$("${tmpdir}something-else" 2>&1 > /dev/null)"; err=$?
[ $err -eq 2 ]   || echo "uname: got $err instead of 2 for something-else" >&3
[ -n "$errstr" ] || echo "uname: stderr empty for something-else" >&3
errstr="$("${tmpdir}$altname" 2>&1 > /dev/null)"; err=$?
[ $err -eq 2 ]   || echo "uname: got $err instead of 2 for $altname" >&3
[ -n "$errstr" ] || echo "uname: stderr empty for $altname" >&3

"${tmpdir}uname" -m > "${tmpdir}uname--m"
"${tmpdir}arch" | cmp - "${tmpdir}uname--m" || echo "uname: arch doesn't match uname -m" >&3

"${tmpdir}uname" > "${tmpdir}uname-"
"${tmpdir}uname" -s | cmp - "${tmpdir}uname-" || echo "uname: default doesn't match -s" >&3

"${tmpdir}uname" -s > "${tmpdir}uname--s"
"${tmpdir}uname" -o | cmp - "${tmpdir}uname--s" || echo "uname: -o doesn't match -s" >&3

for s in '' '-s'; do for n in '' '-n'; do for r in '' '-r'; do for v in '' '-v'; do for m in '' '-m'; do for p in '' '-p'; do
	uname $s $n $r $v $m $p > "${tmpdir}uname $s $n $r $v $m $p"
	"${tmpdir}uname" $s $n $r $v $m $p | cmp - "${tmpdir}uname $s $n $r $v $m $p" || echo "uname: $s $n $r $v $m $p doesn't match system" >&3
done; done; done; done; done; done

if uname -i > "${tmpdir}uname -i" 2>/dev/null; then
	"${tmpdir}uname" -i | cmp - "${tmpdir}uname -i" || echo "uname: -s doesn't match system" >&3
else
	echo "uname: skipping -i, no system support" >&2
fi

rm -rf "$tmpdir" >&3