summaryrefslogtreecommitdiffstats
path: root/testutil
diff options
context:
space:
mode:
Diffstat (limited to 'testutil')
-rw-r--r--testutil/get-datatype-description.c52
-rw-r--r--testutil/get-error.c27
-rw-r--r--testutil/get-section-fraction.c24
-rw-r--r--testutil/get-signals.c43
-rw-r--r--testutil/get-syscall-errors.c43
-rw-r--r--testutil/get-syscall-range.c41
-rw-r--r--testutil/is-datatype-struct.c29
-rw-r--r--testutil/is-section-half.c14
-rw-r--r--testutil/is-section-quarter.c14
-rw-r--r--testutil/list-errors.c21
-rw-r--r--testutil/perror-all.c23
-rw-r--r--testutil/perror-bad.c23
-rw-r--r--testutil/strerror-all.c25
-rw-r--r--testutil/strerror-bad.c25
14 files changed, 404 insertions, 0 deletions
diff --git a/testutil/get-datatype-description.c b/testutil/get-datatype-description.c
new file mode 100644
index 0000000..0bec618
--- /dev/null
+++ b/testutil/get-datatype-description.c
@@ -0,0 +1,52 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <limits.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ enum libsyscalls_os os = (enum libsyscalls_os)atoi(argv[1]);
+ enum libsyscalls_arch arch = (enum libsyscalls_arch)atoi(argv[2]);
+ enum libsyscalls_datatype type = (enum libsyscalls_datatype)atoi(argv[3]);
+ struct libsyscalls_datatype_description desc;
+ enum libsyscalls_error err;
+ size_t i;
+
+ err = libsyscalls_get_datatype_description(os, arch, type, &desc);
+ if (err) {
+ fprintf(stderr, "libsyscalls_get_datatype_description %s %s %s: ", argv[4], argv[5], argv[6]);
+ libsyscalls_perror(NULL, err);
+ return 1;
+ }
+
+ printf("width_in_bits = %u\n", desc.width_in_bits);
+ printf("array_size = %u\n", desc.array_size);
+ printf("relative_position_of_array_size = %i\n", desc.relative_position_of_array_size);
+ printf("absolute_position_of_array_size = %i\n", desc.absolute_position_of_array_size);
+ printf("fill_is_known = %u\n", desc.fill_is_known);
+ printf("is_signed = %u\n", desc.is_signed);
+ printf("is_unsigned = %u\n", desc.is_unsigned);
+ printf("min_is_minus_max = %u\n", desc.min_is_minus_max);
+ printf("sign_representation = %lli\n", (long long int)desc.sign_representation);
+ printf("annotation = %lli\n", (long long int)desc.annotation);
+ printf("section = %lli\n", (long long int)desc.section);
+ printf("byteorder =");
+ for (i = 0; i < sizeof(desc.byteorder) / sizeof(*desc.byteorder); i++) {
+ if (LIBSYSCALLS_IS_BYTEORDER_END(desc.byteorder[i]))
+ goto end_of_byteorder;
+ printf(" %u", desc.byteorder[i]);
+ }
+end_of_byteorder:
+ printf("\n");
+
+ if (fflush(stdout) || fclose(stdout)) {
+ perror(NULL);
+ return 1;
+ }
+ return 0;
+}
diff --git a/testutil/get-error.c b/testutil/get-error.c
new file mode 100644
index 0000000..8f066d7
--- /dev/null
+++ b/testutil/get-error.c
@@ -0,0 +1,27 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++) {
+#define X(N, S)\
+ if (!strcmp(argv[i], #N))\
+ printf("%s\n", S)
+ LIBSYSCALLS_LIST_ERRORS(X, ;);
+#undef X
+ }
+
+ if (fflush(stdout) || fclose(stdout)) {
+ perror(NULL);
+ return 1;
+ }
+ return 0;
+}
diff --git a/testutil/get-section-fraction.c b/testutil/get-section-fraction.c
new file mode 100644
index 0000000..cdb1530
--- /dev/null
+++ b/testutil/get-section-fraction.c
@@ -0,0 +1,24 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ enum libsyscalls_datatype_section sec;
+
+ (void) argc;
+
+ sec = (enum libsyscalls_datatype_section)atoi(argv[1]);
+ printf("%u\n", LIBSYSCALLS_GET_SECTION_FRACTION(sec));
+
+ if (fflush(stdout) || fclose(stdout)) {
+ perror(NULL);
+ return 1;
+ }
+ return 0;
+}
diff --git a/testutil/get-signals.c b/testutil/get-signals.c
new file mode 100644
index 0000000..846a0c1
--- /dev/null
+++ b/testutil/get-signals.c
@@ -0,0 +1,43 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ enum libsyscalls_os os;
+ enum libsyscalls_arch arch;
+ const struct libsyscalls_named_number *signals;
+ size_t i, nsignals;
+ enum libsyscalls_error err;
+
+ (void) argc;
+
+ os = (enum libsyscalls_os)atoi(argv[1]);
+ arch = (enum libsyscalls_arch)atoi(argv[2]);
+
+ libsyscalls_get_signals(os, arch, &signals, &nsignals);
+ if (err == LIBSYSCALLS_E_OSNOSUP || err == LIBSYSCALLS_E_ARCHNOSUP) {
+ printf("x\n");
+ return 0;
+ } else if (err == LIBSYSCALLS_E_NOSIGNALS) {
+ return 0;
+ } else if (err) {
+ fprintf(stderr, "test-get-syscall-signals %s %s: ", argv[3], argv[4]);
+ libsyscalls_perror(NULL, err);
+ return 1;
+ }
+
+ for (i = 0; i < nsignals; i++)
+ printf("%lli %llu %s\n", signals[i].number.s, signals[i].number.u, signals[i].name);
+
+ if (fflush(stdout) || fclose(stdout)) {
+ perror(NULL);
+ return 1;
+ }
+ return 0;
+}
diff --git a/testutil/get-syscall-errors.c b/testutil/get-syscall-errors.c
new file mode 100644
index 0000000..c97e556
--- /dev/null
+++ b/testutil/get-syscall-errors.c
@@ -0,0 +1,43 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ enum libsyscalls_os os;
+ enum libsyscalls_arch arch;
+ const struct libsyscalls_named_number *errors;
+ size_t i, nerrors;
+ enum libsyscalls_error err;
+
+ (void) argc;
+
+ os = (enum libsyscalls_os)atoi(argv[1]);
+ arch = (enum libsyscalls_arch)atoi(argv[2]);
+
+ libsyscalls_get_syscall_errors(os, arch, &errors, &nerrors);
+ if (err == LIBSYSCALLS_E_OSNOSUP || err == LIBSYSCALLS_E_ARCHNOSUP) {
+ printf("x\n");
+ return 0;
+ } else if (err == LIBSYSCALLS_E_NOERRORS) {
+ return 0;
+ } else if (err) {
+ fprintf(stderr, "test-get-syscall-errors %s %s: ", argv[3], argv[4]);
+ libsyscalls_perror(NULL, err);
+ return 1;
+ }
+
+ for (i = 0; i < nerrors; i++)
+ printf("%lli %llu %s\n", errors[i].number.s, errors[i].number.u, errors[i].name);
+
+ if (fflush(stdout) || fclose(stdout)) {
+ perror(NULL);
+ return 1;
+ }
+ return 0;
+}
diff --git a/testutil/get-syscall-range.c b/testutil/get-syscall-range.c
new file mode 100644
index 0000000..9f26b8e
--- /dev/null
+++ b/testutil/get-syscall-range.c
@@ -0,0 +1,41 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ enum libsyscalls_os os;
+ enum libsyscalls_arch arch;
+ long long int min, max;
+ enum libsyscalls_error err;
+
+ (void) argc;
+
+ os = (enum libsyscalls_os)atoi(argv[1]);
+ arch = (enum libsyscalls_arch)atoi(argv[2]);
+
+ err = libsyscalls_get_syscall_range(os, arch, &min, &max);
+ if (err == LIBSYSCALLS_E_OSNOSUP || err == LIBSYSCALLS_E_ARCHNOSUP) {
+ printf("min: x\n");
+ printf("max: x\n");
+ return 0;
+ } else if (err) {
+ fprintf(stderr, "test-get-syscall-range %s %s: ", argv[3], argv[4]);
+ libsyscalls_perror(NULL, err);
+ return 1;
+ }
+
+ printf("min: %lli\n", min);
+ printf("max: %lli\n", max);
+
+ if (fflush(stdout) || fclose(stdout)) {
+ perror(NULL);
+ return 1;
+ }
+ return 0;
+}
diff --git a/testutil/is-datatype-struct.c b/testutil/is-datatype-struct.c
new file mode 100644
index 0000000..f1c7675
--- /dev/null
+++ b/testutil/is-datatype-struct.c
@@ -0,0 +1,29 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <limits.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ enum libsyscalls_os os = (enum libsyscalls_os)atoi(argv[1]);
+ enum libsyscalls_arch arch = (enum libsyscalls_arch)atoi(argv[2]);
+ enum libsyscalls_datatype type = (enum libsyscalls_datatype)atoi(argv[3]);
+ struct libsyscalls_datatype_description desc;
+ enum libsyscalls_error err;
+ size_t i;
+
+ err = libsyscalls_get_datatype_description(os, arch, type, &desc);
+ if (err == LIBSYSCALLS_E_ISSTRUCT) {
+ return 0;
+ } else if (err) {
+ fprintf(stderr, "libsyscalls_get_datatype_description %s %s %s: ", argv[4], argv[5], argv[6]);
+ libsyscalls_perror(NULL, err);
+ return 2;
+ }
+ return 1;
+}
diff --git a/testutil/is-section-half.c b/testutil/is-section-half.c
new file mode 100644
index 0000000..ee6ef50
--- /dev/null
+++ b/testutil/is-section-half.c
@@ -0,0 +1,14 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <stdlib.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ enum libsyscalls_datatype_section sec;
+ (void) argc;
+ sec = (enum libsyscalls_datatype_section)atoi(argv[1]);
+ return !LIBSYSCALLS_IS_SECTION_HALF(sec);
+}
diff --git a/testutil/is-section-quarter.c b/testutil/is-section-quarter.c
new file mode 100644
index 0000000..1fe28d2
--- /dev/null
+++ b/testutil/is-section-quarter.c
@@ -0,0 +1,14 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <stdlib.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ enum libsyscalls_datatype_section sec;
+ (void) argc;
+ sec = (enum libsyscalls_datatype_section)atoi(argv[1]);
+ return !LIBSYSCALLS_IS_SECTION_QUARTER(sec);
+}
diff --git a/testutil/list-errors.c b/testutil/list-errors.c
new file mode 100644
index 0000000..5738b06
--- /dev/null
+++ b/testutil/list-errors.c
@@ -0,0 +1,21 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <stddef.h>
+#include <stdio.h>
+
+
+int
+main(void)
+{
+#define X(N, S)\
+ printf("%li %s %s\n", (long int)N, #N, S)
+ LIBSYSCALLS_LIST_ERRORS(X, ;);
+#undef X
+
+ if (fflush(stdout) || fclose(stdout)) {
+ perror(NULL);
+ return 1;
+ }
+ return 0;
+}
diff --git a/testutil/perror-all.c b/testutil/perror-all.c
new file mode 100644
index 0000000..2b37cff
--- /dev/null
+++ b/testutil/perror-all.c
@@ -0,0 +1,23 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <stddef.h>
+#include <stdio.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ size_t i, count;
+
+ (void) argc;
+
+#define X(...) 1
+ count = (LIBSYSCALLS_LIST_ERRORS(X, +));
+#undef X
+
+ for (i = 0; i < count; i++)
+ libsyscalls_perror(argv[1], (enum libsyscalls_error)i);
+
+ return fflush(stderr) || fclose(stderr);
+}
diff --git a/testutil/perror-bad.c b/testutil/perror-bad.c
new file mode 100644
index 0000000..55d36d3
--- /dev/null
+++ b/testutil/perror-bad.c
@@ -0,0 +1,23 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <stddef.h>
+#include <stdio.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ size_t count;
+
+ (void) argc;
+
+#define X(...) 1
+ count = (LIBSYSCALLS_LIST_ERRORS(X, +));
+#undef X
+
+ libsyscalls_perror(argv[1], (enum libsyscalls_error)-1);
+ libsyscalls_perror(argv[1], (enum libsyscalls_error)count);
+
+ return fflush(stderr) || fclose(stderr);
+}
diff --git a/testutil/strerror-all.c b/testutil/strerror-all.c
new file mode 100644
index 0000000..b875392
--- /dev/null
+++ b/testutil/strerror-all.c
@@ -0,0 +1,25 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <stddef.h>
+#include <stdio.h>
+
+
+int
+main(void)
+{
+ size_t i, count;
+
+#define X(...) 1
+ count = (LIBSYSCALLS_LIST_ERRORS(X, +));
+#undef X
+
+ for (i = 0; i < count; i++)
+ printf("%s\n", libsyscalls_strerror((enum libsyscalls_error)i));
+
+ if (fflush(stdout) || fclose(stdout)) {
+ perror(NULL);
+ return 1;
+ }
+ return 0;
+}
diff --git a/testutil/strerror-bad.c b/testutil/strerror-bad.c
new file mode 100644
index 0000000..23d8836
--- /dev/null
+++ b/testutil/strerror-bad.c
@@ -0,0 +1,25 @@
+/* See LICENSE file for copyright and license details. */
+#include "../libsyscalls.h"
+
+#include <stddef.h>
+#include <stdio.h>
+
+
+int
+main(void)
+{
+ size_t count;
+
+#define X(...) 1
+ count = (LIBSYSCALLS_LIST_ERRORS(X, +));
+#undef X
+
+ printf("%s\n", libsyscalls_strerror((enum libsyscalls_error)-1));
+ printf("%s\n", libsyscalls_strerror((enum libsyscalls_error)count));
+
+ if (fflush(stdout) || fclose(stdout)) {
+ perror(NULL);
+ return 1;
+ }
+ return 0;
+}