diff options
Diffstat (limited to 'tests/errors')
-rw-r--r-- | tests/errors | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/errors b/tests/errors new file mode 100644 index 0000000..f14ddfc --- /dev/null +++ b/tests/errors @@ -0,0 +1,59 @@ +# -*- 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 - |