# -*- 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