diff options
author | David Leonard <d@cvs.openbsd.org> | 2000-01-04 00:18:16 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 2000-01-04 00:18:16 +0000 |
commit | 7d8382839d14b221968f9d9a238de581aba6c79f (patch) | |
tree | 764c64a5874c41185c83505b04ec7384fadc6249 /lib | |
parent | 0d49cb5f8d661e8ddc78ec9624deaf2ab5437d1e (diff) |
Test stdarg for fgsch@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc_r/TEST/test_stdarg.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/libc_r/TEST/test_stdarg.c b/lib/libc_r/TEST/test_stdarg.c new file mode 100644 index 00000000000..0621d8daa83 --- /dev/null +++ b/lib/libc_r/TEST/test_stdarg.c @@ -0,0 +1,69 @@ +/* $OpenBSD: test_stdarg.c,v 1.1 2000/01/04 00:18:15 d Exp $ */ +/* + * Test <stdarg.h> + */ + +#include <pthread.h> +#include <stdio.h> +#include <stdarg.h> +#include "test.h" + +int thing; + +int +test1(char *fmt, ...) +{ + va_list ap; + + int i; + char c; + long l; + void * p; + + va_start(ap, fmt); + for (; *fmt; fmt++) + switch (*fmt++) { + case 'i': + i = va_arg(ap, int); + ASSERT(i == 1234); + break; + case 'c': + c = va_arg(ap, char); + ASSERT(c == 'x'); + break; + case 'l': + l = va_arg(ap, long); + ASSERT(l == 123456789L); + break; + case 'p': + p = va_arg(ap, void *); + ASSERT(p == &thing); + break; + default: + ASSERT(0); + } + va_end(ap); + return 9; +} + +void * +run_test(arg) + void *arg; +{ + char *msg = (char *)arg; + + printf("Testing stdarg: %s\n", msg); + ASSERT(test1("iclp", 1234, 'x', 123456789L, &thing) == 9); + return NULL; +} + +int +main() +{ + pthread_t thread; + + run_test("in main thread"); + CHECKr(pthread_create(&thread, NULL, run_test, "in child thread")); + CHECKr(pthread_join(thread, NULL)); + SUCCEED; +} |