summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/default-integers8
-rw-r--r--tests/endians175
-rw-r--r--tests/errors1
-rw-r--r--tests/fixed-array-types9
-rw-r--r--tests/load-archinfo2
-rw-r--r--tests/load-functions24
-rw-r--r--tests/preamble41
-rw-r--r--tests/sections90
-rw-r--r--tests/signals6
-rw-r--r--tests/signness296
-rw-r--r--tests/syscall-errors6
-rw-r--r--tests/test-self-check7
12 files changed, 657 insertions, 8 deletions
diff --git a/tests/default-integers b/tests/default-integers
index 12faa5a..a33e51a 100644
--- a/tests/default-integers
+++ b/tests/default-integers
@@ -9,7 +9,13 @@ for arch in $(getnamelist ARCH); do
if test $arch = M68K; then
maxalign=16
- elif test $arch = I386; then
+ elif test $arch = I386 || \
+ test $arch = ARM_OABI_LE || \
+ test $arch = ARM_OABI_BE || \
+ test $arch = SH_LE || \
+ test $arch = SH_BE || \
+ test $arch = MICROBLAZE_32_LE || \
+ test $arch = MICROBLAZE_32_BE; then
maxalign=32
else
maxalign=64
diff --git a/tests/endians b/tests/endians
new file mode 100644
index 0000000..13f29f8
--- /dev/null
+++ b/tests/endians
@@ -0,0 +1,175 @@
+# -*- sh -*-
+# See LICENSE file for copyright and license details.
+
+check_endian () {
+ xvalue="$1"
+ text0="$2"
+ text1="$3"
+ textoff="$4"
+ bits="$5"
+ shift 5
+
+ sxvalue="$(printf '%s\n' "$xvalue" | sed 's/^0*//' | sed 's/^$/0/')"
+
+ test "$(to-tracer-endian.tu $text0 $textoff $bits $@)" = "$sxvalue"
+ test "$(to-tracer-endian.tu $text1 $textoff $bits $@)" = "$sxvalue"
+ test "$(to-tracee-endian.tu $xvalue $textoff $bits $@)" = "$text0 $text1"
+}
+
+check_endian0 () {
+ xvalue="$1"
+ text="$2"
+ textoff="$3"
+ bits="$4"
+ shift 4
+ check_endian $xvalue $text $text $textoff $bits $@
+}
+
+check_endian 0 00 FE 0 1 0
+check_endian 0 00 FD 1 1 0
+check_endian 0 00 FB 2 1 0
+check_endian 0 00 F7 3 1 0
+check_endian 0 00 EF 4 1 0
+check_endian 0 00 DF 5 1 0
+check_endian 0 00 BF 6 1 0
+check_endian 0 00 7F 7 1 0
+check_endian 0 0000 FFFE 8 1 0
+
+check_endian 1 01 FF 0 1 0
+check_endian 1 02 FF 1 1 0
+check_endian 1 04 FF 2 1 0
+check_endian 1 08 FF 3 1 0
+check_endian 1 10 FF 4 1 0
+check_endian 1 20 FF 5 1 0
+check_endian 1 40 FF 6 1 0
+check_endian 1 80 FF 7 1 0
+check_endian 1 0001 FFFF 8 1 0
+
+check_endian 0 00 F0 0 4 0
+check_endian 1 01 F1 0 4 0
+check_endian 2 02 F2 0 4 0
+check_endian 3 03 F3 0 4 0
+check_endian 4 04 F4 0 4 0
+check_endian 8 08 F8 0 4 0
+check_endian A 0A FA 0 4 0
+check_endian F 0F FF 0 4 0
+
+check_endian 0 00 E1 1 4 0
+check_endian 0 00 C3 2 4 0
+check_endian 0 00 87 3 4 0
+check_endian 0 00 0F 4 4 0
+check_endian F 1E FF 1 4 0
+check_endian F 3C FF 2 4 0
+check_endian F 78 FF 3 4 0
+check_endian F F0 FF 4 4 0
+check_endian 0 0000 1FFE 5 4 0
+check_endian F E001 FFFF 5 4 0
+check_endian 0 0000 3FFC 6 4 0
+check_endian F C003 FFFF 6 4 0
+
+check_endian0 00 00 0 8 0
+check_endian0 10 10 0 8 0
+check_endian0 01 01 0 8 0
+check_endian0 80 80 0 8 0
+check_endian0 08 08 0 8 0
+check_endian0 FF FF 0 8 0
+
+check_endian 00 0000 01FE 1 8 0
+check_endian FF FE01 FFFF 1 8 0
+
+check_endian 000 0000 00FE 0 9 0
+check_endian 1FF FF01 FFFF 0 9 0
+
+check_endian 000 0000 00FC 0 10 0
+check_endian 3FF FF03 FFFF 0 10 0
+
+check_endian 000 0000 01FC 1 9 0
+check_endian 1FF FE03 FFFF 1 9 0
+
+check_endian 000 0000 01F8 1 10 0
+check_endian 3FF FE07 FFFF 1 10 0
+
+check_endian0 0000 0000 0 16 8 0
+check_endian0 FFFF FFFF 0 16 8 0
+check_endian0 1234 1234 0 16 8 0
+check_endian0 0800 0800 0 16 8 0
+
+check_endian0 0000 0000 0 16 0 8
+check_endian0 FFFF FFFF 0 16 0 8
+check_endian0 1234 3412 0 16 0 8
+check_endian0 0800 0008 0 16 0 8
+
+check_endian0 0000 0000 0 16 0
+check_endian0 FFFF FFFF 0 16 0
+check_endian0 1234 3412 0 16 0
+check_endian0 0800 0008 0 16 0
+
+check_endian0 000000 000000 0 24 16 8 0
+check_endian0 FFFFFF FFFFFF 0 24 16 8 0
+check_endian0 160800 160800 0 24 16 8 0
+
+check_endian0 000000 000000 0 24 16 0 8
+check_endian0 FFFFFF FFFFFF 0 24 16 0 8
+check_endian0 160800 160008 0 24 16 0 8
+
+check_endian0 000000 000000 0 24 0 8 16
+check_endian0 FFFFFF FFFFFF 0 24 0 8 16
+check_endian0 160800 000816 0 24 0 8 16
+
+check_endian0 000000 000000 0 24 8 0 16
+check_endian0 FFFFFF FFFFFF 0 24 8 0 16
+check_endian0 160800 080016 0 24 8 0 16
+
+check_endian0 000000 000000 0 24 0 16 8
+check_endian0 FFFFFF FFFFFF 0 24 0 16 8
+check_endian0 160800 001608 0 24 0 16 8
+
+check_endian0 000000 000000 0 24 8 16 0
+check_endian0 FFFFFF FFFFFF 0 24 8 16 0
+check_endian0 160800 081600 0 24 8 16 0
+
+check_endian0 00000000 00000000 0 32 24 16 8 0
+check_endian0 FFFFFFFF FFFFFFFF 0 32 24 16 8 0
+check_endian0 12345678 12345678 0 32 24 16 8 0
+check_endian0 24160800 24160800 0 32 24 16 8 0
+
+check_endian0 00000000 00000000 0 32 8 0 24 16
+check_endian0 FFFFFFFF FFFFFFFF 0 32 8 0 24 16
+check_endian0 12345678 56781234 0 32 8 0 24 16
+check_endian0 24160800 08002416 0 32 8 0 24 16
+
+check_endian0 00000000 00000000 0 32 0 8 16 24
+check_endian0 FFFFFFFF FFFFFFFF 0 32 0 8 16 24
+check_endian0 12345678 78563412 0 32 0 8 16 24
+check_endian0 24160800 00081624 0 32 0 8 16 24
+
+check_endian0 00000000 00000000 0 32 0 16 8 24
+check_endian0 FFFFFFFF FFFFFFFF 0 32 0 16 8 24
+check_endian0 12345678 78345612 0 32 0 16 8 24
+check_endian0 24160800 00160824 0 32 0 16 8 24
+
+check_endian0 0000000000000000 0000000000000000 0 64 56 48 40 32 24 16 8 0
+check_endian0 FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 0 64 56 48 40 32 24 16 8 0
+check_endian0 0123456789ABCDEF 0123456789ABCDEF 0 64 56 48 40 32 24 16 8 0
+check_endian0 5648403224160800 5648403224160800 0 64 56 48 40 32 24 16 8 0
+
+check_endian0 0000000000000000 0000000000000000 0 64 24 16 8 0 56 48 40 32
+check_endian0 FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 0 64 24 16 8 0 56 48 40 32
+check_endian0 0123456789ABCDEF 89ABCDEF01234567 0 64 24 16 8 0 56 48 40 32
+check_endian0 5648403224160800 2416080056484032 0 64 24 16 8 0 56 48 40 32
+
+check_endian0 0000000000000000 0000000000000000 0 64 8 0 24 16 40 32 56 48
+check_endian0 FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 0 64 8 0 24 16 40 32 56 48
+check_endian0 0123456789ABCDEF CDEF89AB45670123 0 64 8 0 24 16 40 32 56 48
+check_endian0 5648403224160800 0800241640325648 0 64 8 0 24 16 40 32 56 48
+
+check_endian0 0000000000000000 0000000000000000 0 64 0 8 16 24 32 40 48 56
+check_endian0 FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 0 64 0 8 16 24 32 40 48 56
+check_endian0 0123456789ABCDEF EFCDAB8967452301 0 64 0 8 16 24 32 40 48 56
+check_endian0 5648403224160800 0008162432404856 0 64 0 8 16 24 32 40 48 56
+
+check_endian 000 0000 00FE 0 9 0 8
+check_endian 1FF FF01 FFFF 0 9 0 8
+
+check_endian 000 0000 FE00 0 9 8 0
+check_endian 1FF 01FF FFFF 0 9 8 0
diff --git a/tests/errors b/tests/errors
index 8c74731..9e098d1 100644
--- a/tests/errors
+++ b/tests/errors
@@ -55,5 +55,6 @@ cat > $a <<.
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
+10 LIBSYSCALLS_E_ISNOTSTRUCT Type is not a structure or union
.
list-errors.tu | diff -u $a -
diff --git a/tests/fixed-array-types b/tests/fixed-array-types
index 070920e..06dcbb5 100644
--- a/tests/fixed-array-types
+++ b/tests/fixed-array-types
@@ -29,5 +29,14 @@ for os in $(getnamelist OS); do
| sed 's/^\(array_size\) = 1$/\1 = 2/' > $a
get-datatype-description.tu $osn $archn $(lookupnum "$types" $atype) $os $arch $atype > $b
diff -u $a $b
+
+ for n in 9 65; do
+ ptype=CHAR
+ atype=BUFFER_$n
+ get-datatype-description.tu $osn $archn $(lookupnum "$types" $ptype) $os $arch $ptype \
+ | sed 's/^\(array_size\) = 1$/\1 = '$n/ > $a
+ get-datatype-description.tu $osn $archn $(lookupnum "$types" $atype) $os $arch $atype > $b
+ diff -u $a $b
+ done
done
done
diff --git a/tests/load-archinfo b/tests/load-archinfo
index 09d472b..e5413b4 100644
--- a/tests/load-archinfo
+++ b/tests/load-archinfo
@@ -18,7 +18,7 @@ getbyteorder () {
printf '%s\n' "$byteorders" | grep "^$1$2 " | cut -d ' ' -f 2-
}
-sed '1,/LIST_ARCH_SPECS/d' < libsyscalls_get_datatype_description.c \
+sed '1,/LIST_ARCH_SPECS/d' < common.h \
| sed '/#include/q' \
| sed 's/\(TO''DO\)[[:space:]]*([^)]*)/\1/g' \
| sed -n 's/^[[:space:]]*[A-Z_]\{1,\}(LIBSYSCALLS_ARCH_\([^)]*\)).*$/\1/p' \
diff --git a/tests/load-functions b/tests/load-functions
index 2e9ddda..3436158 100644
--- a/tests/load-functions
+++ b/tests/load-functions
@@ -1,6 +1,30 @@
# -*- sh -*-
# See LICENSE file for copyright and license details.
+parallelindex=0
+p () {
+ (
+ set +ev
+ pid=$$-$parallelindex
+ a=.a-$pid.tmp
+ b=.b-$pid.tmp
+ log=.x-$pid.tmp
+ ( set -ev ; $t "$@" ) > $log 2>&1
+ r=$?
+ test $r = 0 || cat -- $log >&2
+ rm -f -- .?-$pid.tmp
+ exit $r
+ ) &
+ eval parallelpid$(( ++parallelindex ))=$!
+}
+await () {
+ while (( parallelindex )); do
+ parallelvar=parallelpid$(( parallelindex-- ))
+ eval wait '$'$parallelvar
+ done
+}
+
+
stderr () {
("$@") 2>&1 >/dev/null
}
diff --git a/tests/preamble b/tests/preamble
new file mode 100644
index 0000000..527a098
--- /dev/null
+++ b/tests/preamble
@@ -0,0 +1,41 @@
+# -*- sh -*-
+# See LICENSE file for copyright and license details.
+
+if test $# = 0; then
+ if "$0" fail for me; then
+ printf 'Testing is broken!\n' >&2
+ exit 2
+ fi
+ set +e
+ "$0" $$
+ r=$?
+ rm -f -- .?-$$.tmp
+ exit $r
+fi
+
+
+set -e
+test $# = 1
+pid=$1
+a=.a-$pid.tmp
+b=.b-$pid.tmp
+PATH="$(dirname -- "$0")/testutil:$PATH"
+export PATH
+
+
+if ! env | grep '^SUPPORTED_OSES=' >/dev/null; then
+ printf '%s\n' \
+ "The test's environment has not been set up;" \
+ 'you should run the test via `make check`'
+ exit 1
+fi
+
+. tests/load-functions
+
+alias t='$t'
+
+if ! (. tests/test-self-check) >/dev/null 2>/dev/null; then
+ printf '%s\n' \
+ "The test's self-check failed"
+ exit 1
+fi
diff --git a/tests/sections b/tests/sections
new file mode 100644
index 0000000..1574b8d
--- /dev/null
+++ b/tests/sections
@@ -0,0 +1,90 @@
+# -*- sh -*-
+# See LICENSE file for copyright and license details.
+
+check_section () {
+ sectionn=$1
+ whole=$2
+ splitinwhole=$3
+ split=$(printf '%s\n' $splitinwhole | tr -d -- -)
+ wholebits=$(( ( $(printf '%s\n' $whole | sed 's/./+1/g') ) * 4 ))
+ splitbits=$(( ( $(printf '%s\n' $split | sed 's/./+1/g') ) * 4 ))
+ ssplit=$(printf '%s\n' $split | sed 's/^0*//' | sed 's/^$/0/' )
+ ssplitinwhole=$(printf '%s\n' $splitinwhole | tr -- - 0 | sed 's/^0*//' | sed 's/^$/0/' )
+
+ test $(section-value.tu $sectionn $whole $wholebits) = $ssplit
+ test $(unsection-value.tu $sectionn $split $splitbits) = $ssplitinwhole
+}
+
+test $(section-value.tu 32767 0 8) = inval
+test $(unsection-value.tu 32767 0 8) = inval
+
+for section in $(getnamelist SECTION); do
+ sectionn=$(getnum SECTION $section)
+ if test $section = UNDETERMINED || test $section = WHOLE; then
+ check_section $sectionn 12 12
+ check_section $sectionn 1234 1234
+ check_section $sectionn 12345678 12345678
+ check_section $sectionn 123456789ABC 123456789ABC
+ check_section $sectionn 0123456789ABCDEF 0123456789ABCDEF
+
+ elif test $section = UPPER_HALF; then
+ check_section $sectionn 1234 12--
+ check_section $sectionn 12345678 1234----
+ check_section $sectionn 123456789ABC 123456------
+ check_section $sectionn 0123456789ABCDEF 01234567--------
+
+ elif test $section = LOWER_HALF; then
+ check_section $sectionn 1234 --34
+ check_section $sectionn 12345678 ----5678
+ check_section $sectionn 123456789ABC ------789ABC
+ check_section $sectionn 0123456789ABCDEF --------89ABCDEF
+
+ elif test $section = INNER_HALF; then
+ check_section $sectionn 12345678 --3456--
+ check_section $sectionn 0123456789ABCDEF ----456789AB----
+
+ elif test $section = OUTER_HALF; then
+ check_section $sectionn 12345678 12----78
+ check_section $sectionn 0123456789ABCDEF 0123--------CDEF
+
+ elif test $section = EVEN_QUARTERS_AS_HALF; then
+ check_section $sectionn 12345678 --34--78
+ check_section $sectionn 0123456789ABCDEF ----4567----CDEF
+
+ elif test $section = ODD_QUARTERS_AS_HALF; then
+ check_section $sectionn 12345678 12--56--
+ check_section $sectionn 0123456789ABCDEF 0123----89AB----
+
+ elif test $section = EVEN_BYTES_AS_HALF; then
+ check_section $sectionn 1234 --34
+ check_section $sectionn 12345678 --34--78
+ check_section $sectionn 123456789ABC --34--78--BC
+ check_section $sectionn 0123456789ABCDEF --23--67--AB--EF
+
+ elif test $section = ODD_BYTES_AS_HALF; then
+ check_section $sectionn 1234 12--
+ check_section $sectionn 12345678 12--56--
+ check_section $sectionn 123456789ABC 12--56--9A--
+ check_section $sectionn 0123456789ABCDEF 01--45--89--CD--
+
+ elif test $section = UPPER_QUARTER; then
+ check_section $sectionn 12345678 12------
+ check_section $sectionn 0123456789ABCDEF 0123------------
+
+ elif test $section = UPPER_MID_QUARTER; then
+ check_section $sectionn 12345678 --34----
+ check_section $sectionn 0123456789ABCDEF ----4567--------
+
+ elif test $section = LOWER_MID_QUARTER; then
+ check_section $sectionn 12345678 ----56--
+ check_section $sectionn 0123456789ABCDEF --------89AB----
+
+ elif test $section = LOWER_QUARTER; then
+ check_section $sectionn 12345678 ------78
+ check_section $sectionn 0123456789ABCDEF ------------CDEF
+
+ else
+ printf 'Missing test for LIBSYSCALLS_SECTION_%s in tests/sections\n' "$section" >&2
+ false
+ fi
+done
diff --git a/tests/signals b/tests/signals
index 4052402..733baa4 100644
--- a/tests/signals
+++ b/tests/signals
@@ -6,11 +6,11 @@ for os in $(getnamelist OS); do
for arch in $(getnamelist ARCH); do
archn=$(getnum ARCH $arch)
get-signals.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)
+ grep -v '^[0-9]\{1,\} -' >/dev/null < $a
+ grep -v '^-' < $a > $b
+ grep '^\([0-9]\{1,\}\) \1 ' < $a | diff -u $a -
if test "$os" = LINUX; then
signed=1
grep '^[0-9]\{1,\} [0-9]\{1,\} [A-Z0-9_+]\{1,\}$' >/dev/null < $a
diff --git a/tests/signness b/tests/signness
new file mode 100644
index 0000000..8c29fe4
--- /dev/null
+++ b/tests/signness
@@ -0,0 +1,296 @@
+# -*- sh -*-
+# See LICENSE file for copyright and license details.
+
+test $(parse-signed.tu 32767 32 0) = inval
+test $(make-signed.tu 32767 32 0) = inval
+
+check_signed () {
+ test $(parse-signed.tu $1 $2 $3) = $4
+ test $(make-signed.tu $1 $2 $4) = $3
+}
+
+ucheck_signed () {
+ check_signed "$@"
+ test $(make-signed.tu $1 $2 -$4) = $3
+}
+
+for sign in $(getnamelist SIGN); do
+ signn=$(getnum SIGN $sign)
+ if test $sign = UNDETERMINED; then
+ ucheck_signed $signn 1 0 0
+ ucheck_signed $signn 1 1 1
+ ucheck_signed $signn 2 0 0
+ ucheck_signed $signn 2 1 1
+ ucheck_signed $signn 2 2 2
+ ucheck_signed $signn 2 3 3
+ ucheck_signed $signn 4 4 4
+ ucheck_signed $signn 4 9 9
+ ucheck_signed $signn 4 A A
+ ucheck_signed $signn 4 C C
+ ucheck_signed $signn 4 F F
+ ucheck_signed $signn 7 00 00
+ ucheck_signed $signn 7 08 08
+ ucheck_signed $signn 7 70 70
+ ucheck_signed $signn 7 7F 7F
+ ucheck_signed $signn 8 00 00
+ ucheck_signed $signn 8 08 08
+ ucheck_signed $signn 8 80 80
+ ucheck_signed $signn 8 FF FF
+ ucheck_signed $signn 16 0001 0001
+ ucheck_signed $signn 16 0020 0020
+ ucheck_signed $signn 16 0300 0300
+ ucheck_signed $signn 16 4000 4000
+ ucheck_signed $signn 16 0008 0008
+ ucheck_signed $signn 16 0090 0090
+ ucheck_signed $signn 16 0A00 0A00
+ ucheck_signed $signn 16 B000 B000
+ ucheck_signed $signn 17 08100 08100
+ ucheck_signed $signn 17 00820 00820
+ ucheck_signed $signn 17 00083 00083
+ ucheck_signed $signn 17 04008 04008
+ ucheck_signed $signn 17 11008 11008
+ ucheck_signed $signn 17 10280 10280
+ ucheck_signed $signn 17 10830 10830
+ ucheck_signed $signn 17 18004 18004
+ ucheck_signed $signn 32 12345678 12345678
+ ucheck_signed $signn 32 9ABCDEF0 9ABCDEF0
+ ucheck_signed $signn 32 87654321 87654321
+ ucheck_signed $signn 32 0FEDCBA9 0FEDCBA9
+ ucheck_signed $signn 64 0123456789ABCDEF 0123456789ABCDEF
+ ucheck_signed $signn 64 123456789ABCDEF0 123456789ABCDEF0
+ ucheck_signed $signn 64 23456789ABCDEF01 23456789ABCDEF01
+ ucheck_signed $signn 64 3456789ABCDEF012 3456789ABCDEF012
+ ucheck_signed $signn 64 89ABCDEF01234567 89ABCDEF01234567
+ ucheck_signed $signn 64 9ABCDEF012345678 9ABCDEF012345678
+ ucheck_signed $signn 64 ABCDEF0123456789 ABCDEF0123456789
+ ucheck_signed $signn 64 BCDEF0123456789A BCDEF0123456789A
+ ucheck_signed $signn 64 0000000000000000 0000000000000000
+ ucheck_signed $signn 64 7FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF
+ ucheck_signed $signn 64 8000000000000000 8000000000000000
+ ucheck_signed $signn 64 FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
+
+ elif test $sign = SIGN_MAGNITUDE; then
+ check_signed $signn 1 0 0
+ check_signed $signn 1 1 -0
+ check_signed $signn 2 0 0
+ check_signed $signn 2 1 1
+ check_signed $signn 2 2 -0
+ check_signed $signn 2 3 -1
+ check_signed $signn 4 4 4
+ check_signed $signn 4 9 -1
+ check_signed $signn 4 A -2
+ check_signed $signn 4 C -4
+ check_signed $signn 4 F -7
+ check_signed $signn 7 00 00
+ check_signed $signn 7 08 08
+ check_signed $signn 7 70 -30
+ check_signed $signn 7 7F -3F
+ check_signed $signn 8 00 00
+ check_signed $signn 8 08 08
+ check_signed $signn 8 80 -00
+ check_signed $signn 8 FF -7F
+ check_signed $signn 16 0001 0001
+ check_signed $signn 16 0020 0020
+ check_signed $signn 16 0300 0300
+ check_signed $signn 16 4000 4000
+ check_signed $signn 16 0008 0008
+ check_signed $signn 16 0090 0090
+ check_signed $signn 16 0A00 0A00
+ check_signed $signn 16 B000 -3000
+ check_signed $signn 17 08100 08100
+ check_signed $signn 17 00820 00820
+ check_signed $signn 17 00083 00083
+ check_signed $signn 17 04008 04008
+ check_signed $signn 17 11008 -01008
+ check_signed $signn 17 10280 -00280
+ check_signed $signn 17 10830 -00830
+ check_signed $signn 17 18004 -08004
+ check_signed $signn 32 12345678 12345678
+ check_signed $signn 32 9ABCDEF0 -1ABCDEF0
+ check_signed $signn 32 87654321 -07654321
+ check_signed $signn 32 0FEDCBA9 0FEDCBA9
+ check_signed $signn 64 0123456789ABCDEF 0123456789ABCDEF
+ check_signed $signn 64 123456789ABCDEF0 123456789ABCDEF0
+ check_signed $signn 64 23456789ABCDEF01 23456789ABCDEF01
+ check_signed $signn 64 3456789ABCDEF012 3456789ABCDEF012
+ check_signed $signn 64 89ABCDEF01234567 -09ABCDEF01234567
+ check_signed $signn 64 9ABCDEF012345678 -1ABCDEF012345678
+ check_signed $signn 64 ABCDEF0123456789 -2BCDEF0123456789
+ check_signed $signn 64 BCDEF0123456789A -3CDEF0123456789A
+ check_signed $signn 64 0000000000000000 0000000000000000
+ check_signed $signn 64 7FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF
+ check_signed $signn 64 8000000000000000 -0000000000000000
+ check_signed $signn 64 FFFFFFFFFFFFFFFF -7FFFFFFFFFFFFFFF
+
+ elif test $sign = ONES_COMPLEMENT; then
+ check_signed $signn 1 0 0
+ check_signed $signn 1 1 -0
+ check_signed $signn 2 0 0
+ check_signed $signn 2 1 1
+ check_signed $signn 2 2 -1
+ check_signed $signn 2 3 -0
+ check_signed $signn 4 4 4
+ check_signed $signn 4 9 -6
+ check_signed $signn 4 A -5
+ check_signed $signn 4 C -3
+ check_signed $signn 4 F -0
+ check_signed $signn 7 00 00
+ check_signed $signn 7 08 08
+ check_signed $signn 7 70 -0F
+ check_signed $signn 7 7F -00
+ check_signed $signn 8 00 00
+ check_signed $signn 8 08 08
+ check_signed $signn 8 80 -7F
+ check_signed $signn 8 FF -00
+ check_signed $signn 16 0001 0001
+ check_signed $signn 16 0020 0020
+ check_signed $signn 16 0300 0300
+ check_signed $signn 16 4000 4000
+ check_signed $signn 16 0008 0008
+ check_signed $signn 16 0090 0090
+ check_signed $signn 16 0A00 0A00
+ check_signed $signn 16 B000 -4FFF
+ check_signed $signn 17 08100 08100
+ check_signed $signn 17 00820 00820
+ check_signed $signn 17 00083 00083
+ check_signed $signn 17 04008 04008
+ check_signed $signn 17 11008 -0EFF7
+ check_signed $signn 17 10280 -0FD7F
+ check_signed $signn 17 10830 -0F7CF
+ check_signed $signn 17 18004 -07FFB
+ check_signed $signn 32 12345678 12345678
+ check_signed $signn 32 9ABCDEF0 -6543210F
+ check_signed $signn 32 87654321 -789ABCDE
+ check_signed $signn 32 0FEDCBA9 0FEDCBA9
+ check_signed $signn 64 0123456789ABCDEF 0123456789ABCDEF
+ check_signed $signn 64 123456789ABCDEF0 123456789ABCDEF0
+ check_signed $signn 64 23456789ABCDEF01 23456789ABCDEF01
+ check_signed $signn 64 3456789ABCDEF012 3456789ABCDEF012
+ check_signed $signn 64 89ABCDEF01234567 -76543210FEDCBA98
+ check_signed $signn 64 9ABCDEF012345678 -6543210FEDCBA987
+ check_signed $signn 64 ABCDEF0123456789 -543210FEDCBA9876
+ check_signed $signn 64 BCDEF0123456789A -43210FEDCBA98765
+ check_signed $signn 64 0000000000000000 0000000000000000
+ check_signed $signn 64 7FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF
+ check_signed $signn 64 8000000000000000 -7FFFFFFFFFFFFFFF
+ check_signed $signn 64 FFFFFFFFFFFFFFFF -0000000000000000
+
+ elif test $sign = TWOS_COMPLEMENT; then
+ check_signed $signn 1 0 0
+ check_signed $signn 1 1 -1
+ check_signed $signn 2 0 0
+ check_signed $signn 2 1 1
+ check_signed $signn 2 2 -2
+ check_signed $signn 2 3 -1
+ check_signed $signn 4 4 4
+ check_signed $signn 4 9 -7
+ check_signed $signn 4 A -6
+ check_signed $signn 4 C -4
+ check_signed $signn 4 F -1
+ check_signed $signn 7 00 00
+ check_signed $signn 7 08 08
+ check_signed $signn 7 70 -10
+ check_signed $signn 7 7F -01
+ check_signed $signn 8 00 00
+ check_signed $signn 8 08 08
+ check_signed $signn 8 80 -80
+ check_signed $signn 8 FF -01
+ check_signed $signn 16 0001 0001
+ check_signed $signn 16 0020 0020
+ check_signed $signn 16 0300 0300
+ check_signed $signn 16 4000 4000
+ check_signed $signn 16 0008 0008
+ check_signed $signn 16 0090 0090
+ check_signed $signn 16 0A00 0A00
+ check_signed $signn 16 B000 -5000
+ check_signed $signn 17 08100 08100
+ check_signed $signn 17 00820 00820
+ check_signed $signn 17 00083 00083
+ check_signed $signn 17 04008 04008
+ check_signed $signn 17 11008 -0EFF8
+ check_signed $signn 17 10280 -0FD80
+ check_signed $signn 17 10830 -0F7D0
+ check_signed $signn 17 18004 -07FFC
+ check_signed $signn 32 12345678 12345678
+ check_signed $signn 32 9ABCDEF0 -65432110
+ check_signed $signn 32 87654321 -789ABCDF
+ check_signed $signn 32 0FEDCBA9 0FEDCBA9
+ check_signed $signn 64 0123456789ABCDEF 0123456789ABCDEF
+ check_signed $signn 64 123456789ABCDEF0 123456789ABCDEF0
+ check_signed $signn 64 23456789ABCDEF01 23456789ABCDEF01
+ check_signed $signn 64 3456789ABCDEF012 3456789ABCDEF012
+ check_signed $signn 64 89ABCDEF01234567 -76543210FEDCBA99
+ check_signed $signn 64 9ABCDEF012345678 -6543210FEDCBA988
+ check_signed $signn 64 ABCDEF0123456789 -543210FEDCBA9877
+ check_signed $signn 64 BCDEF0123456789A -43210FEDCBA98766
+ check_signed $signn 64 0000000000000000 0000000000000000
+ check_signed $signn 64 7FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF
+ check_signed $signn 64 8000000000000000 -8000000000000000
+ check_signed $signn 64 FFFFFFFFFFFFFFFF -0000000000000001
+ test $(make-signed.tu $signn 1 -0) = 0
+ test $(make-signed.tu $signn 4 -0) = 0
+
+ elif test $sign = EXCESS_HALF; then
+ check_signed $signn 1 0 -1
+ check_signed $signn 1 1 0
+ check_signed $signn 2 0 -2
+ check_signed $signn 2 1 -1
+ check_signed $signn 2 2 0
+ check_signed $signn 2 3 1
+ check_signed $signn 4 4 -4
+ check_signed $signn 4 9 1
+ check_signed $signn 4 A 2
+ check_signed $signn 4 C 4
+ check_signed $signn 4 F 7
+ check_signed $signn 7 00 -40
+ check_signed $signn 7 08 -38
+ check_signed $signn 7 70 30
+ check_signed $signn 7 7F 3F
+ check_signed $signn 8 00 -80
+ check_signed $signn 8 08 -78
+ check_signed $signn 8 80 00
+ check_signed $signn 8 FF 7F
+ check_signed $signn 16 0001 -7FFF
+ check_signed $signn 16 0020 -7FE0
+ check_signed $signn 16 0300 -7D00
+ check_signed $signn 16 4000 -4000
+ check_signed $signn 16 0008 -7FF8
+ check_signed $signn 16 0090 -7F70
+ check_signed $signn 16 0A00 -7600
+ check_signed $signn 16 B000 3000
+ check_signed $signn 17 08100 -07F00
+ check_signed $signn 17 00820 -0F7E0
+ check_signed $signn 17 00083 -0FF7D
+ check_signed $signn 17 04008 -0BFF8
+ check_signed $signn 17 11008 01008
+ check_signed $signn 17 10280 00280
+ check_signed $signn 17 10830 00830
+ check_signed $signn 17 18004 08004
+ check_signed $signn 32 12345678 -6DCBA988
+ check_signed $signn 32 9ABCDEF0 1ABCDEF0
+ check_signed $signn 32 87654321 07654321
+ check_signed $signn 32 0FEDCBA9 -70123457
+ check_signed $signn 64 0123456789ABCDEF -7EDCBA9876543211
+ check_signed $signn 64 123456789ABCDEF0 -6DCBA98765432110
+ check_signed $signn 64 23456789ABCDEF01 -5CBA9876543210FF
+ check_signed $signn 64 3456789ABCDEF012 -4BA9876543210FEE
+ check_signed $signn 64 89ABCDEF01234567 09ABCDEF01234567
+ check_signed $signn 64 9ABCDEF012345678 1ABCDEF012345678
+ check_signed $signn 64 ABCDEF0123456789 2BCDEF0123456789
+ check_signed $signn 64 BCDEF0123456789A 3CDEF0123456789A
+ check_signed $signn 64 0000000000000000 -8000000000000000
+ check_signed $signn 64 7FFFFFFFFFFFFFFF -0000000000000001
+ check_signed $signn 64 8000000000000000 0000000000000000
+ check_signed $signn 64 FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF
+ test $(make-signed.tu $signn 1 -0) = 1
+ test $(make-signed.tu $signn 4 -0) = 8
+
+ else
+ printf 'Missing test for LIBSYSCALLS_SIGN_%s in tests/signness\n' "$sign" >&2
+ false
+ fi
+ test $(parse-signed.tu $signn 0 0) = inval
+ test $(parse-signed.tu $signn 32767 0) = inval
+ test $(make-signed.tu $signn 0 0) = inval
+ test $(make-signed.tu $signn 32767 0) = inval
+done
diff --git a/tests/syscall-errors b/tests/syscall-errors
index 8d85ded..4608fe7 100644
--- a/tests/syscall-errors
+++ b/tests/syscall-errors
@@ -6,11 +6,11 @@ for os in $(getnamelist OS); do
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)
+ grep -v '^[0-9]\{1,\} -' >/dev/null < $a
+ grep -v '^-' < $a > $b
+ grep '^\([0-9]\{1,\}\) \1 ' < $a | diff -u $a -
if test "$os" = LINUX; then
signed=1
grep '^[0-9]\{1,\} [0-9]\{1,\} [A-Z0-9_]\{1,\}$' >/dev/null < $a
diff --git a/tests/test-self-check b/tests/test-self-check
index 8e42f18..c0e1d0d 100644
--- a/tests/test-self-check
+++ b/tests/test-self-check
@@ -9,6 +9,9 @@ stderr_printf () {
test "$(stderr_printf 'hello\n')" = ''
test "$(stderr stderr_printf 'hello\n' 2>&1)" = 'hello'
+failing_function () { false; true; } # use of { } rather than ( ) is important
+( ! failing_function )
+
(! (false > $a) )
getname OS 0
@@ -39,6 +42,10 @@ printf 'a\n' > $a
printf 'a\n' > $b
diff -u $a $b
+true & wait $!
+( false & ! wait $! )
+await
+
for os in ${SUPPORTED_OSES}; do
issupported $os
for arch in $(env | sed -n 's/^SUPPORTED_'"$os"'_ARCHES=//p' | xargs printf '%s\n'); do