summaryrefslogtreecommitdiffstats
path: root/tests/syscall-errors
blob: 8d85dedc1faf88eec66ad8d0b3ed85e73e8e327c (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
# -*- sh -*-
# See LICENSE file for copyright and license details.

for os in $(getnamelist OS); do
	osn=$(getnum OS $os)
	for arch in $(getnamelist ARCH); do
		archn=$(getnum ARCH $arch)
		get-syscall-errors.tu $osn $archn $os $arch > $a
		grep -v '^[0-9]\{1,\} -' >/dev/null < $a
		grep -v '^-' < $a > $b
		grep '^\([0-9]\{1,\}\) \1 ' < $a | diff -u $a -
		if issupported $os $arch; then
			(! test "$(cat $a)" = x)
			if test "$os" = LINUX; then
				signed=1
				grep '^[0-9]\{1,\} [0-9]\{1,\} [A-Z0-9_]\{1,\}$' >/dev/null < $a
				test -z "$(grep -v '^[0-9]\{1,\} [0-9]\{1,\} [A-Z0-9_]\{1,\}$' < $a)"
				required="ERESTARTSYS ERESTARTNOINTR ERESTARTNOHAND ERESTART_RESTARTBLOCK EPERM ENOENT EDOM ELOOP"
			else
				continue;
			fi
			for req in $required; do
				grep '^-\{0,1\}[0-9]\{1,\} [0-9]\{1,\} '"$req"\$ >/dev/null < $a
			done
			cut -d ' ' -f $(( 2 - signed )) < $a > $b && sort -n < $b | diff -u $b -
			if test -f testcases/errors-$os-$arch; then
				if ! diff -u testcases/errors-$os-$arch $a; then
					printf '\033[33m%s\033[m\n' "Maybe new errors have been added for $os on $arch"
					exit 1
				fi
			fi
		else
			# Can still be successful because it may be hardcorded to
			# use the same table as another architecture that is supported,
			# however it cannot be successful if the OS is not supported
			issupported $os
		fi
		test -z "$(cut -d ' ' -f 1 < $a | sort | uniq -d)"
		test -z "$(cut -d ' ' -f 2 < $a | sort | uniq -d)"
		test -z "$(cut -d ' ' -f 3 < $a | sort | uniq -d)"
	done
done
test -f testcases/errors-LINUX-AMD64
test -f testcases/errors-LINUX-PARISC_32
test -f testcases/errors-LINUX-PARISC_64
(! diff -u testcases/errors-LINUX-AMD64 testcases/errors-LINUX-PARISC_32 >/dev/null)