diff options
Diffstat (limited to 'regress/lib')
-rw-r--r-- | regress/lib/libc/longjmp/Makefile | 3 | ||||
-rw-r--r-- | regress/lib/libc/longjmp/longjmp.c | 36 |
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; +} |