diff options
Diffstat (limited to '')
-rwxr-xr-x | test | 23 | ||||
-rw-r--r-- | tests/default-integers | 21 | ||||
-rw-r--r-- | tests/load-functions | 4 | ||||
-rw-r--r-- | tests/os-dependent-integers | 9 | ||||
-rw-r--r-- | testutil/get-integer-alignment.c | 45 |
5 files changed, 88 insertions, 14 deletions
@@ -29,11 +29,15 @@ alias t=. # have already been written and passed, set to . otherwise -set -v - -test -n "${SUPPORTED_OSES}" # This check that the test's environment has set up, if this fails, run through `make check` +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/test-self-check;) >/dev/null 2>/dev/null +set -v +(. tests/test-self-check) >/dev/null 2>/dev/null @@ -41,31 +45,22 @@ t tests/enums . tests/load-types t tests/errors - t tests/syscall-ranges - t tests/syscall-errors - t tests/signals - t tests/split-register-classes . tests/load-archinfo t tests/archinfo t tests/fundamental-primitives - t tests/is-struct - t tests/array-types - t tests/fixed-array-types - t tests/split-register-types - t tests/os-dependent-primitives - t tests/os-dependent-arrays +t tests/os-dependent-integers diff --git a/tests/default-integers b/tests/default-integers new file mode 100644 index 0000000..12faa5a --- /dev/null +++ b/tests/default-integers @@ -0,0 +1,21 @@ +# -*- sh -*- +# See LICENSE file for copyright and license details. + +for arch in $(getnamelist ARCH); do + archn=$(getnum ARCH $arch) + if ! issupported $os $arch; then + continue + fi + + if test $arch = M68K; then + maxalign=16 + elif test $arch = I386; then + maxalign=32 + else + maxalign=64 + fi + + for width in 8 16 32 64; do + test "$(get-integer-alignment.tu $osn $archn $width $os $arch)" = $(min $maxalign $width) + done +done diff --git a/tests/load-functions b/tests/load-functions index f0c5311..a31f236 100644 --- a/tests/load-functions +++ b/tests/load-functions @@ -58,3 +58,7 @@ issupported () { cpp_enum_clean () { $CPP < libsyscalls.h 2>/dev/null | grep -v '#' | tr '\n,{}' ' \n\n\n' } + +min () { + printf '%s\n' "$@" | tr -d + | sort -n | sed -n 1p +} diff --git a/tests/os-dependent-integers b/tests/os-dependent-integers new file mode 100644 index 0000000..09a11e3 --- /dev/null +++ b/tests/os-dependent-integers @@ -0,0 +1,9 @@ +# -*- sh -*- +# See LICENSE file for copyright and license details. + +for os in $(getnamelist OS); do + osn=$(getnum OS $os) + if issupported $os; then + . $(printf '%s\n' $os | tr '[A-Z]' '[a-z]')/tests/os-dependent-integers + fi +done diff --git a/testutil/get-integer-alignment.c b/testutil/get-integer-alignment.c new file mode 100644 index 0000000..6c91824 --- /dev/null +++ b/testutil/get-integer-alignment.c @@ -0,0 +1,45 @@ +/* See LICENSE file for copyright and license details. */ +#include "../libsyscalls.h" + +#include <limits.h> +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> + +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + + +int +main(int argc, char **argv) +{ + int os, arch, width; + unsigned alignment = -1; + enum libsyscalls_error err; + + if (argc != 6) { + fprintf(stderr, "usage error\n"); + return 3; + } + + os = atoi(argv[1]); + arch = atoi(argv[2]); + width = atoi(argv[3]); + + err = libsyscalls_get_integer_alignment((enum libsyscalls_os)os, (enum libsyscalls_arch)arch, + (unsigned)width, &alignment); + if (err) { + fprintf(stderr, "libsyscalls_get_integer_alignment %s %s %s: ", argv[4], argv[5], argv[3]); + libsyscalls_perror(NULL, err); + return 1; + } + + printf("%u\n", alignment); + + if (fflush(stdout) || fclose(stdout)) { + perror(NULL); + return 1; + } + return 0; +} |