summaryrefslogtreecommitdiff
path: root/regress/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2002-02-08 21:33:33 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2002-02-08 21:33:33 +0000
commit7b0a7458761aedfc0f4404a4b006eb478758bded (patch)
treee12711cff8709f439f4d6f70c587c0b9593ab534 /regress/sys
parentde9c8f8d7ba280b4756634e8d62a4926ee65e65e (diff)
simple test for syscall(2)
Diffstat (limited to 'regress/sys')
-rw-r--r--regress/sys/kern/syscall/Makefile5
-rw-r--r--regress/sys/kern/syscall/syscall.c35
2 files changed, 40 insertions, 0 deletions
diff --git a/regress/sys/kern/syscall/Makefile b/regress/sys/kern/syscall/Makefile
new file mode 100644
index 00000000000..1b22f581d76
--- /dev/null
+++ b/regress/sys/kern/syscall/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2002/02/08 21:33:32 art Exp $
+
+PROG= syscall
+
+.include <bsd.regress.mk>
diff --git a/regress/sys/kern/syscall/syscall.c b/regress/sys/kern/syscall/syscall.c
new file mode 100644
index 00000000000..3f46729515f
--- /dev/null
+++ b/regress/sys/kern/syscall/syscall.c
@@ -0,0 +1,35 @@
+/* $OpenBSD: syscall.c,v 1.1 2002/02/08 21:33:32 art Exp $ */
+/*
+ * Written by Artur Grabowski <art@openbsd.org> 2002 Public Domain.
+ */
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <err.h>
+
+int
+main()
+{
+ int status;
+
+ switch(fork()) {
+ case -1:
+ err(1, "fork");
+ case 0:
+ syscall(SYS_exit, 17);
+ abort();
+ }
+
+ if (wait(&status) < 0)
+ err(1, "wait");
+
+ if (!WIFEXITED(status))
+ errx(1, "child didn't exit gracefully");
+
+ if (WEXITSTATUS(status) != 17)
+ errx(1, "wrong exit status");
+
+ return 0;
+}