diff options
| author | art <> | 2002-01-04 13:33:17 +0000 |
|---|---|---|
| committer | art <> | 2002-01-04 13:33:17 +0000 |
| commit | 327f214c26abf9d44fd57d9bf6c2cc8f2bb8e4a0 (patch) | |
| tree | 7a457c05556ba406ce6ed90e517729caa4937c81 /src/regress/lib/libc | |
| parent | ade97ccb075fc58ae21a1877632b1a7f1d14c216 (diff) | |
| download | openbsd-327f214c26abf9d44fd57d9bf6c2cc8f2bb8e4a0.tar.gz openbsd-327f214c26abf9d44fd57d9bf6c2cc8f2bb8e4a0.tar.bz2 openbsd-327f214c26abf9d44fd57d9bf6c2cc8f2bb8e4a0.zip | |
More explicit tests of longjmp.
Diffstat (limited to 'src/regress/lib/libc')
| -rw-r--r-- | src/regress/lib/libc/longjmp/longjmp.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/regress/lib/libc/longjmp/longjmp.c b/src/regress/lib/libc/longjmp/longjmp.c index d8b9fe86bd..4d8edb4716 100644 --- a/src/regress/lib/libc/longjmp/longjmp.c +++ b/src/regress/lib/libc/longjmp/longjmp.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: longjmp.c,v 1.1 2002/01/04 13:02:57 art Exp $ */ | 1 | /* $OpenBSD: longjmp.c,v 1.2 2002/01/04 13:33:17 art Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Artur Grabowski <art@openbsd.org> Public Domain. | 3 | * Artur Grabowski <art@openbsd.org> Public Domain. |
| 4 | */ | 4 | */ |
| @@ -16,21 +16,34 @@ jmp_buf buf; | |||
| 16 | * When longjmp is passed the incorrect arg (0), it should translate it into | 16 | * When longjmp is passed the incorrect arg (0), it should translate it into |
| 17 | * something better. | 17 | * something better. |
| 18 | * | 18 | * |
| 19 | * Test is simple. rlimit the cpu time and throw an incorrect longjmp. If 0 | 19 | * The rlimit is here in case we start spinning. |
| 20 | * is not translated we'll spin until we hit the cpu time limit. | ||
| 21 | */ | 20 | */ |
| 22 | int | 21 | int |
| 23 | main() | 22 | main() |
| 24 | { | 23 | { |
| 25 | struct rlimit rl; | 24 | struct rlimit rl; |
| 25 | volatile int i, expect; | ||
| 26 | 26 | ||
| 27 | rl.rlim_cur = 2; | 27 | rl.rlim_cur = 2; |
| 28 | rl.rlim_max = 2; | 28 | rl.rlim_max = 2; |
| 29 | if (setrlimit(RLIMIT_CPU, &rl) < 0) | 29 | if (setrlimit(RLIMIT_CPU, &rl) < 0) |
| 30 | err(1, "setrlimit"); | 30 | err(1, "setrlimit"); |
| 31 | 31 | ||
| 32 | if (setjmp(buf) == 0) | 32 | expect = 0; |
| 33 | i = setjmp(buf); | ||
| 34 | if (i == 0 && expect != 0) | ||
| 35 | errx(1, "setjmp returns 0 on longjmp(.., 0)"); | ||
| 36 | if (expect == 0) { | ||
| 37 | expect = -1; | ||
| 33 | longjmp(buf, 0); | 38 | longjmp(buf, 0); |
| 39 | } | ||
| 40 | |||
| 41 | expect = 0; | ||
| 42 | i = setjmp(buf); | ||
| 43 | if (i != expect) | ||
| 44 | errx(1, "bad return from setjmp %d/%d", expect, i); | ||
| 45 | if (expect < 1000) | ||
| 46 | longjmp(buf, expect += 2); | ||
| 34 | 47 | ||
| 35 | return 0; | 48 | return 0; |
| 36 | } | 49 | } |
