summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2002-01-04 13:02:58 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2002-01-04 13:02:58 +0000
commit79cb121ab13273d637bb9dcd006259247570c62f (patch)
tree4da87ee7f027068c6c3e9c1e6e9b19a7d56b23a3
parent08127c6e00f298ed276c42448552b95bb6fc2721 (diff)
test for what longjmp(.., 0) does
-rw-r--r--regress/lib/libc/longjmp/Makefile3
-rw-r--r--regress/lib/libc/longjmp/longjmp.c36
2 files changed, 39 insertions, 0 deletions
diff --git a/regress/lib/libc/longjmp/Makefile b/regress/lib/libc/longjmp/Makefile
new file mode 100644
index 00000000000..1444cd43746
--- /dev/null
+++ b/regress/lib/libc/longjmp/Makefile
@@ -0,0 +1,3 @@
+PROG= longjmp
+
+.include <bsd.regress.mk>
diff --git a/regress/lib/libc/longjmp/longjmp.c b/regress/lib/libc/longjmp/longjmp.c
new file mode 100644
index 00000000000..d8b9fe86bd6
--- /dev/null
+++ b/regress/lib/libc/longjmp/longjmp.c
@@ -0,0 +1,36 @@
+/* $OpenBSD: longjmp.c,v 1.1 2002/01/04 13:02:57 art Exp $ */
+/*
+ * Artur Grabowski <art@openbsd.org> Public Domain.
+ */
+
+#include <setjmp.h>
+#include <err.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+
+jmp_buf buf;
+
+/*
+ * When longjmp is passed the incorrect arg (0), it should translate it into
+ * something better.
+ *
+ * Test is simple. rlimit the cpu time and throw an incorrect longjmp. If 0
+ * is not translated we'll spin until we hit the cpu time limit.
+ */
+int
+main()
+{
+ struct rlimit rl;
+
+ rl.rlim_cur = 2;
+ rl.rlim_max = 2;
+ if (setrlimit(RLIMIT_CPU, &rl) < 0)
+ err(1, "setrlimit");
+
+ if (setjmp(buf) == 0)
+ longjmp(buf, 0);
+
+ return 0;
+}