diff options
Diffstat (limited to 'src/regress/lib/libc/stdio_threading/fgets')
-rw-r--r-- | src/regress/lib/libc/stdio_threading/fgets/Makefile | 6 | ||||
-rwxr-xr-x | src/regress/lib/libc/stdio_threading/fgets/fgets_test.c | 69 |
2 files changed, 0 insertions, 75 deletions
diff --git a/src/regress/lib/libc/stdio_threading/fgets/Makefile b/src/regress/lib/libc/stdio_threading/fgets/Makefile deleted file mode 100644 index 52310fd429..0000000000 --- a/src/regress/lib/libc/stdio_threading/fgets/Makefile +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | TOPDIR=${.CURDIR} | ||
2 | PROG=fgets_test | ||
3 | CFLAGS+=-I${TOPDIR}/../include/ | ||
4 | LDFLAGS+=-lpthread | ||
5 | |||
6 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/stdio_threading/fgets/fgets_test.c b/src/regress/lib/libc/stdio_threading/fgets/fgets_test.c deleted file mode 100755 index 7c5008e2ad..0000000000 --- a/src/regress/lib/libc/stdio_threading/fgets/fgets_test.c +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2008 Bret S. Lambert <blambert@openbsd.org> | ||
3 | * | ||
4 | * Permission to use, copy, modify, and distribute this software for any | ||
5 | * purpose with or without fee is hereby granted, provided that the above | ||
6 | * copyright notice and this permission notice appear in all copies. | ||
7 | * | ||
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
15 | */ | ||
16 | |||
17 | #include "local.h" | ||
18 | |||
19 | void | ||
20 | fgets_thread(void *v) | ||
21 | { | ||
22 | char buf[sizeof(TEXT_N) + 1]; | ||
23 | FILE *file = v; | ||
24 | int i; | ||
25 | |||
26 | for (i = 0; i < 4096; i++) { | ||
27 | if (fgets(buf, sizeof(buf), file) == NULL) { | ||
28 | |||
29 | if (feof(file)) | ||
30 | break; | ||
31 | |||
32 | printf("OMG!!!\n"); | ||
33 | fflush(stdout); | ||
34 | break; | ||
35 | } | ||
36 | if (strncmp(buf, TEXT, sizeof(TEXT))) | ||
37 | err(1, "Read not atomic!!!"); | ||
38 | } | ||
39 | } | ||
40 | |||
41 | int | ||
42 | main(void) | ||
43 | { | ||
44 | char sfn[24]; | ||
45 | FILE *sfp; | ||
46 | int fd, i; | ||
47 | |||
48 | strlcpy(sfn, "/tmp/barnacles.XXXXXXXX", sizeof(sfn)); | ||
49 | if ((fd = mkstemp(sfn)) == -1 || | ||
50 | (sfp = fdopen(fd, "w+")) == NULL) { | ||
51 | int saved_errno = errno; | ||
52 | if (fd != -1) { | ||
53 | unlink(sfn); | ||
54 | close(fd); | ||
55 | } | ||
56 | errc(1, saved_errno, "could not open temporary file"); | ||
57 | } | ||
58 | |||
59 | for (i = 0; i < 4096 * THREAD_COUNT; i++) | ||
60 | if (fwrite(TEXT_N, sizeof(char), strlen(TEXT_N), sfp) == 0) | ||
61 | err(1, "Could not populate test file"); | ||
62 | |||
63 | run_threads(fgets_thread, sfp); | ||
64 | |||
65 | unlink(sfn); | ||
66 | close(fd); | ||
67 | |||
68 | exit(0); | ||
69 | } | ||