summaryrefslogblamecommitdiffstats
path: root/tests/errors
blob: f14ddfca6c20d13ad7ffdda457c3bc7a1dee8a35 (plain) (tree)


























































                                                                                                        
# -*- sh -*-
# See LICENSE file for copyright and license details.

strerror-all.tu > $a
stderr perror-all.tu > $b
diff -u $a $b
test $(wc -l < $a) -ge 10

strerror-bad.tu > $a
stderr perror-bad.tu > $b
diff -u $a $b
test $(wc -l < $a) = 2
grep -i '\(un\|not \)recogni[sz]ed' > /dev/null < $a
test "$(sed 1q < $a)" = "$(sed 1d < $a)"

for t in perror-bad.tu perror-all.tu; do
	stderr $t "" > $a
	stderr $t > $b
	diff -u $a $b

	stderr $t "test" > $a
	stderr $t > $b
	(! diff -u $a $b >/dev/null)

	stderr $t "test" > $a
	stderr $t | sed 's/^/test: /' > $b
	diff -u $a $b
done

strerror-all.tu > $a
list-errors.tu > $b
(! grep '^-' >/dev/null < $b)
grep '^[0-9]\+ ' >/dev/null < $b
grep '^[0-9]\+ LIBSYSCALLS_E_[A-Z]\+ ' >/dev/null < $b
grep '^[0-9]\+ LIBSYSCALLS_E_[A-Z]\+ [A-Z].*[^.]$' >/dev/null < $b
cut -d ' ' -f 3- < $b | diff -u $a -
sed 1q < $b | grep '^0 LIBSYSCALLS_E_OK Success$' >/dev/null
test -z "$(cut -d ' ' -f 1 < $b | sort | uniq -d)"
test -z "$(cut -d ' ' -f 2 < $b | sort | uniq -d)"
test -z "$(cut -d ' ' -f 3- < $b | sort | uniq -d)"

test "$(get-error.tu LIBSYSCALLS_E_OK)" = 'Success'
test "$(get-error.tu LIBSYSCALLS_E_OSNOSUP)" = 'Operating system not supported'
test "$(get-error.tu LIBSYSCALLS_E_NOSUCHSYSCALL)" = 'No such system call'

# This can be updated, its just to check that nothing is accidentally changed in LIBSYSCALLS_LIST_ERRORS
cat > $a <<.
0 LIBSYSCALLS_E_OK Success
1 LIBSYSCALLS_E_OSNOSUP Operating system not supported
2 LIBSYSCALLS_E_ARCHNOSUP Architecture not supported for selected operating system
3 LIBSYSCALLS_E_NOSUCHSYSCALL No such system call
4 LIBSYSCALLS_E_NOERRORS There is no error listing for selected operating system
5 LIBSYSCALLS_E_NOSIGNALS There is no signal listing for selected operating system
6 LIBSYSCALLS_E_NOMEM Failed to allocate required memory
7 LIBSYSCALLS_E_INVAL Invalid arguments passed to function
8 LIBSYSCALLS_E_NOSUCHTYPE Type does not exist on the selected operating system or architecture
9 LIBSYSCALLS_E_ISSTRUCT Type is a structure or union
.
list-errors.tu | diff -u $a -