diff options
author | nik <nik@FreeBSD.org> | 2005-02-01 01:53:35 +0000 |
---|---|---|
committer | nik <nik@FreeBSD.org> | 2005-02-01 01:53:35 +0000 |
commit | 41b0884fdce4a75b86cfa44a6211235d62e07225 (patch) | |
tree | 5ff72ad5d1c42a94653493950822c8b75d833174 | |
parent | a52292b594fa4bb7a0c7120e270809cb6dbcbf65 (diff) | |
download | FreeBSD-src-41b0884fdce4a75b86cfa44a6211235d62e07225.zip FreeBSD-src-41b0884fdce4a75b86cfa44a6211235d62e07225.tar.gz |
Link against libtap (ports/devel/libtap). Replace the calls to assert()
with calls to libtap::ok1(), and make sure the correct number of tests is
planned for, and that the exit code is correct.
-rw-r--r-- | tools/regression/lib/libc/string/Makefile | 3 | ||||
-rw-r--r-- | tools/regression/lib/libc/string/test-strerror.c | 60 |
2 files changed, 32 insertions, 31 deletions
diff --git a/tools/regression/lib/libc/string/Makefile b/tools/regression/lib/libc/string/Makefile index 5c136e9..469042f 100644 --- a/tools/regression/lib/libc/string/Makefile +++ b/tools/regression/lib/libc/string/Makefile @@ -1,5 +1,8 @@ # $FreeBSD$ +CFLAGS= -I/usr/local/include -L/usr/local/lib +LDFLAGS= -ltap + TESTS= test-strerror .PHONY: tests diff --git a/tools/regression/lib/libc/string/test-strerror.c b/tools/regression/lib/libc/string/test-strerror.c index 6c429c3..f5274ed 100644 --- a/tools/regression/lib/libc/string/test-strerror.c +++ b/tools/regression/lib/libc/string/test-strerror.c @@ -33,6 +33,8 @@ #include <stdlib.h> #include <string.h> +#include <tap.h> + int main(void) { @@ -40,93 +42,89 @@ main(void) char *sret; int iret; - printf("1..2\n"); + plan_tests(25); /* * strerror() failure tests. */ errno = 0; sret = strerror(0); - assert(strcmp(sret, "Unknown error: 0") == 0); - assert(errno == EINVAL); + ok1(strcmp(sret, "Unknown error: 0") == 0); + ok1(errno == EINVAL); errno = 0; sret = strerror(INT_MAX); snprintf(buf, sizeof(buf), "Unknown error: %d", INT_MAX); - assert(strcmp(sret, buf) == 0); - assert(errno == EINVAL); + ok1(strcmp(sret, buf) == 0); + ok1(errno == EINVAL); /* * strerror() success tests. */ errno = 0; sret = strerror(EPERM); - assert(strcmp(sret, "Operation not permitted") == 0); - assert(errno == 0); + ok1(strcmp(sret, "Operation not permitted") == 0); + ok1(errno == 0); errno = 0; sret = strerror(EPFNOSUPPORT); - assert(strcmp(sret, "Protocol family not supported") == 0); - assert(errno == 0); + ok1(strcmp(sret, "Protocol family not supported") == 0); + ok1(errno == 0); errno = 0; sret = strerror(ELAST); - assert(errno == 0); - - printf("ok 1 - strerror()\n"); + ok1(errno == 0); /* * strerror_r() failure tests. */ memset(buf, '*', sizeof(buf)); iret = strerror_r(0, buf, sizeof(buf)); - assert(strcmp(buf, "Unknown error: 0") == 0); - assert(iret == EINVAL); + ok1(strcmp(buf, "Unknown error: 0") == 0); + ok1(iret == EINVAL); memset(buf, '*', sizeof(buf)); /* One byte too short. */ iret = strerror_r(EPERM, buf, strlen("Operation not permitted")); - assert(strcmp(buf, "Operation not permitte") == 0); - assert(iret == ERANGE); + ok1(strcmp(buf, "Operation not permitte") == 0); + ok1(iret == ERANGE); memset(buf, '*', sizeof(buf)); /* One byte too short. */ iret = strerror_r(-1, buf, strlen("Unknown error: -1")); - assert(strcmp(buf, "Unknown error: -") == 0); - assert(iret == EINVAL); + ok1(strcmp(buf, "Unknown error: -") == 0); + ok1(iret == EINVAL); memset(buf, '*', sizeof(buf)); /* Two bytes too short. */ iret = strerror_r(-2, buf, strlen("Unknown error: -2") - 1); - assert(strcmp(buf, "Unknown error: ") == 0); - assert(iret == EINVAL); + ok1(strcmp(buf, "Unknown error: ") == 0); + ok1(iret == EINVAL); memset(buf, '*', sizeof(buf)); /* Three bytes too short. */ iret = strerror_r(-2, buf, strlen("Unknown error: -2") - 2); - assert(strcmp(buf, "Unknown error:") == 0); - assert(iret == EINVAL); + ok1(strcmp(buf, "Unknown error:") == 0); + ok1(iret == EINVAL); memset(buf, '*', sizeof(buf)); /* One byte too short. */ iret = strerror_r(12345, buf, strlen("Unknown error: 12345")); - assert(strcmp(buf, "Unknown error: 1234") == 0); - assert(iret == EINVAL); + ok1(strcmp(buf, "Unknown error: 1234") == 0); + ok1(iret == EINVAL); /* * strerror_r() success tests. */ memset(buf, '*', sizeof(buf)); iret = strerror_r(EDEADLK, buf, sizeof(buf)); - assert(strcmp(buf, "Resource deadlock avoided") == 0); - assert(iret == 0); + ok1(strcmp(buf, "Resource deadlock avoided") == 0); + ok1(iret == 0); memset(buf, '*', sizeof(buf)); iret = strerror_r(EPROCLIM, buf, sizeof(buf)); - assert(strcmp(buf, "Too many processes") == 0); - assert(iret == 0); - - printf("ok 2 - strerror_r()\n"); + ok1(strcmp(buf, "Too many processes") == 0); + ok1(iret == 0); - exit(0); + return exit_status(); } |