summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorart <art@openbsd.org>2002-01-04 13:48:52 +0000
committerart <art@openbsd.org>2002-01-04 13:48:52 +0000
commiteaf4cf29660e81ebe3c0cd869f8701fb13fbcbf9 (patch)
treef5c7eab431b3a9268b7e53278114a8ee4309b72d
parentMore explicit tests of longjmp. (diff)
downloadwireguard-openbsd-eaf4cf29660e81ebe3c0cd869f8701fb13fbcbf9.tar.xz
wireguard-openbsd-eaf4cf29660e81ebe3c0cd869f8701fb13fbcbf9.zip
Test _longjmp too. (Don't hate me for the '_' option).
sigsetjmp should be tested too, but that wasn't as easy to fit in here (and it wasn't broken on alpha anyway).
-rw-r--r--regress/lib/libc/longjmp/Makefile7
-rw-r--r--regress/lib/libc/longjmp/longjmp.c34
2 files changed, 35 insertions, 6 deletions
diff --git a/regress/lib/libc/longjmp/Makefile b/regress/lib/libc/longjmp/Makefile
index 1444cd43746..d17a94182e0 100644
--- a/regress/lib/libc/longjmp/Makefile
+++ b/regress/lib/libc/longjmp/Makefile
@@ -1,3 +1,10 @@
PROG= longjmp
+do-longjmp: ${PROG}
+ ./longjmp
+do-_longjmp: ${PROG}
+ ./longjmp -_
+
+REGRESSTARGETS=do-longjmp do-_longjmp
+
.include <bsd.regress.mk>
diff --git a/regress/lib/libc/longjmp/longjmp.c b/regress/lib/libc/longjmp/longjmp.c
index 4d8edb47162..9940dc5b9ae 100644
--- a/regress/lib/libc/longjmp/longjmp.c
+++ b/regress/lib/libc/longjmp/longjmp.c
@@ -1,8 +1,11 @@
-/* $OpenBSD: longjmp.c,v 1.2 2002/01/04 13:33:17 art Exp $ */
+/* $OpenBSD: longjmp.c,v 1.3 2002/01/04 13:48:52 art Exp $ */
/*
* Artur Grabowski <art@openbsd.org> Public Domain.
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <setjmp.h>
#include <err.h>
#include <sys/types.h>
@@ -19,10 +22,29 @@ jmp_buf buf;
* The rlimit is here in case we start spinning.
*/
int
-main()
+main(int argc, char **argv)
{
struct rlimit rl;
volatile int i, expect;
+ int (*sj)(jmp_buf);
+ void (*lj)(jmp_buf, int);
+ int ch;
+ extern char *__progname;
+
+ sj = setjmp;
+ lj = longjmp;
+
+ while ((ch = getopt(argc, argv, "_")) != -1) {
+ switch (ch) {
+ case '_':
+ sj = _setjmp;
+ lj = _longjmp;
+ break;
+ default:
+ fprintf(stderr, "Usage: %s [-_]\n", __progname);
+ exit(1);
+ }
+ }
rl.rlim_cur = 2;
rl.rlim_max = 2;
@@ -30,20 +52,20 @@ main()
err(1, "setrlimit");
expect = 0;
- i = setjmp(buf);
+ i = (*sj)(buf);
if (i == 0 && expect != 0)
errx(1, "setjmp returns 0 on longjmp(.., 0)");
if (expect == 0) {
expect = -1;
- longjmp(buf, 0);
+ (*lj)(buf, 0);
}
expect = 0;
- i = setjmp(buf);
+ i = (*sj)(buf);
if (i != expect)
errx(1, "bad return from setjmp %d/%d", expect, i);
if (expect < 1000)
- longjmp(buf, expect += 2);
+ (*lj)(buf, expect += 2);
return 0;
}