diff options
Diffstat (limited to '')
-rw-r--r-- | tests/signness | 296 |
1 files changed, 296 insertions, 0 deletions
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 |