diff options
author | Mattias Andrée <maandree@kth.se> | 2023-12-16 12:40:10 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2023-12-16 12:40:10 +0100 |
commit | 683f205402a99cfc8cea46c83ce9b46a42616d42 (patch) | |
tree | f6ee1619454a6ec8b9e31770bbbc2abf36aae2fd /tests/sections | |
parent | Improve portability (diff) | |
download | libsyscalls-683f205402a99cfc8cea46c83ce9b46a42616d42.tar.gz libsyscalls-683f205402a99cfc8cea46c83ce9b46a42616d42.tar.bz2 libsyscalls-683f205402a99cfc8cea46c83ce9b46a42616d42.tar.xz |
All kinds of stuff
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'tests/sections')
-rw-r--r-- | tests/sections | 90 |
1 files changed, 90 insertions, 0 deletions
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 |