summaryrefslogtreecommitdiffstats
path: root/testutil/get-syscall-errors.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-12-05 00:03:04 +0100
committerMattias Andrée <maandree@kth.se>2023-12-05 00:03:04 +0100
commit58dd684c4e86944301959a140dbed9746df35779 (patch)
treea2702ea4f66b2a58711ee22eb7449c74b1ecf0d1 /testutil/get-syscall-errors.c
parentFirst commit (diff)
downloadlibsyscalls-58dd684c4e86944301959a140dbed9746df35779.tar.gz
libsyscalls-58dd684c4e86944301959a140dbed9746df35779.tar.bz2
libsyscalls-58dd684c4e86944301959a140dbed9746df35779.tar.xz
Second commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--testutil/get-syscall-errors.c43
1 files changed, 43 insertions, 0 deletions
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;
+}