diff options
author | Mattias Andrée <maandree@kth.se> | 2023-12-05 20:10:48 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2023-12-05 20:10:48 +0100 |
commit | 6d77b155bcd4725e09837604e6ea86f5f124ba9c (patch) | |
tree | 7cfdf466bb94bbbe3e7929432bc048da5eaa2349 /tests/fundamental-primitives | |
parent | Second commit (diff) | |
download | libsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.gz libsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.bz2 libsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.xz |
Third commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'tests/fundamental-primitives')
-rw-r--r-- | tests/fundamental-primitives | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/tests/fundamental-primitives b/tests/fundamental-primitives new file mode 100644 index 0000000..4068934 --- /dev/null +++ b/tests/fundamental-primitives @@ -0,0 +1,161 @@ +# -*- sh -*- +# See LICENSE file for copyright and license details. + +whole=$(getnum SECTION WHOLE) +noannotation=$(getnum ANNOTATION NONE) +for os in $(getnamelist OS); do + osn=$(getnum OS $os) + for arch in $(getnamelist ARCH); do + archn=$(getnum ARCH $arch) + if ! issupported $os $arch; then + continue + fi + + endian=$(getendian $arch) + + sign_representation=$(getsign $arch) + if test ${sign_representation} = TWOS_COMPLEMENT; then + min_is_minus_max=0 + elif test ${sign_representation} = ONES_COMPLEMENT; then + min_is_minus_max=1 + elif test ${sign_representation} = SIGN_MAGNITUDE; then + min_is_minus_max=1 + elif test ${sign_representation} = EXCESS_HALF; then + min_is_minus_max=0 + else + false # that's all we have for now + fi + sign_representation=$(getnum SIGN ${sign_representation}) + + for n in $intsizes; do + type=INT$n + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a + grep "^width_in_bits = ${n}"\$ < $a >/dev/null + grep "^array_size = 1"\$ < $a >/dev/null + grep "^relative_position_of_array_size = 0"\$ < $a >/dev/null + grep "^absolute_position_of_array_size = -1"\$ < $a >/dev/null + grep "^is_signed = 1"\$ < $a >/dev/null + grep "^is_unsigned = 0"\$ < $a >/dev/null + grep "^min_is_minus_max = ${min_is_minus_max}"\$ < $a >/dev/null + grep "^sign_representation = ${sign_representation}"\$ < $a >/dev/null + grep "^annotation = ${noannotation}"\$ < $a >/dev/null + grep "^section = ${whole}"\$ < $a >/dev/null + grep "^byteorder = $(getbyteorder $n $endian)"\$ < $a >/dev/null + + type=UINT$n + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a + grep "^width_in_bits = ${n}"\$ < $a >/dev/null + grep "^array_size = 1"\$ < $a >/dev/null + grep "^relative_position_of_array_size = 0"\$ < $a >/dev/null + grep "^absolute_position_of_array_size = -1"\$ < $a >/dev/null + grep "^is_signed = 0"\$ < $a >/dev/null + grep "^is_unsigned = 1"\$ < $a >/dev/null + grep "^annotation = ${noannotation}"\$ < $a >/dev/null + grep "^section = ${whole}"\$ < $a >/dev/null + grep "^byteorder = $(getbyteorder $n $endian)"\$ < $a >/dev/null + done + + type=INT$(getaddrsize $arch) + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a + type=INTPTR + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b + diff -u $a $b + + type=INT$(getsizesize $arch) + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a + type=SSIZE + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b + diff -u $a $b + + type=VOID + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a + grep "^width_in_bits = 0"\$ < $a >/dev/null + grep "^array_size = 1"\$ < $a >/dev/null + grep "^relative_position_of_array_size = 0"\$ < $a >/dev/null + grep "^absolute_position_of_array_size = -1"\$ < $a >/dev/null + grep "^is_signed = 0"\$ < $a >/dev/null + grep "^is_unsigned = 0"\$ < $a >/dev/null + grep "^annotation = ${noannotation}"\$ < $a >/dev/null + grep "^section = ${whole}"\$ < $a >/dev/null + grep "^byteorder =\s*"\$ < $a >/dev/null + type=NO_RETURN + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type | diff -u $a - + + type=INT + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a + type=INT_SIGNAL + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b + sed 's/^\(annotation\) .*$/\1 = '"$(getnum ANNOTATION SIGNAL)"'/' < $a | diff -u - $b + type=INT_FD + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b + sed 's/^\(annotation\) .*$/\1 = '"$(getnum ANNOTATION FD)"'/' < $a | diff -u - $b + type=INT_ATFD + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b + sed 's/^\(annotation\) .*$/\1 = '"$(getnum ANNOTATION ATFD)"'/' < $a | diff -u - $b + + type=LONG + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a + type=LONG_FD + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b + sed 's/^\(annotation\) .*$/\1 = '"$(getnum ANNOTATION FD)"'/' < $a | diff -u - $b + type=LONG_ATFD + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b + sed 's/^\(annotation\) .*$/\1 = '"$(getnum ANNOTATION ATFD)"'/' < $a | diff -u - $b + + for type in SCHAR SHORT INT LONG LLONG PTRDIFF INTPTR SSIZE; do + if test $type = SCHAR; then + utype=UCHAR + elif test $type = SSIZE; then + utype=SIZE + else + utype=U$type + fi + + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a + grep "^width_in_bits = ." < $a >/dev/null + grep "^array_size = 1"\$ < $a >/dev/null + grep "^relative_position_of_array_size = 0"\$ < $a >/dev/null + grep "^absolute_position_of_array_size = -1"\$ < $a >/dev/null + grep "^is_signed = 1"\$ < $a >/dev/null + grep "^is_unsigned = 0"\$ < $a >/dev/null + grep "^min_is_minus_max = ${min_is_minus_max}"\$ < $a >/dev/null + grep "^sign_representation = ${sign_representation}"\$ < $a >/dev/null + grep "^annotation = ${noannotation}"\$ < $a >/dev/null + grep "^section = ${whole}"\$ < $a >/dev/null + n="$(grep "^width_in_bits = ." < $a | cut -d ' ' -f 3)" + grep "^byteorder = $(getbyteorder $n $endian)"\$ < $a >/dev/null + + sed -e 's/^\(is_signed =\) .$/\1 0/' -e 's/^\(is_unsigned =\) .$/\1 1/' < $a > $b + ( ! diff -u $b $a > /dev/null) + grep -v '^\(min_is_minus_max\|sign_representation\) = ' < $b > $a + ( ! diff -u $a $b > /dev/null) + get-datatype-description.tu $osn $archn $(lookupnum "$types" $utype) $os $arch $utype > $b + grep -v '^\(min_is_minus_max\|sign_representation\) = ' < $b | diff -u $a - + + if test $type = SCHAR; then + xtypes=CHAR + elif test $type = INTPTR; then + xtypes="MEMORY_ADDRESS STRING STRINGS_THEN_NULL" + else + xtypes= + fi + for xtype in $xtypes; do + get-datatype-description.tu $osn $archn $(lookupnum "$types" $xtype) $os $arch $xtype \ + | grep -v '^\(min_is_minus_max\|sign_representation\) = ' > $b + sed 's/^\(is_\(un\)signed =\) .$/\1 0/' < $a | diff -u - $b + done + done + + type=INTPTR + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a + type=PTRDIFF + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b + diff -u $a $b + + type=DYNAMIC + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a + type=UNKNOWN + get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b + diff -u $a $b + done +done |