From owner-svn-src-head@FreeBSD.ORG Wed Mar 12 10:45:23 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7002EB5E; Wed, 12 Mar 2014 10:45:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4FB84A84; Wed, 12 Mar 2014 10:45:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2CAjNRo025639; Wed, 12 Mar 2014 10:45:23 GMT (envelope-from jmmv@svn.freebsd.org) Received: (from jmmv@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2CAjMGJ025637; Wed, 12 Mar 2014 10:45:22 GMT (envelope-from jmmv@svn.freebsd.org) Message-Id: <201403121045.s2CAjMGJ025637@svn.freebsd.org> From: Julio Merino Date: Wed, 12 Mar 2014 10:45:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263085 - head/tools/regression/lib/libc/string X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Mar 2014 10:45:23 -0000 Author: jmmv Date: Wed Mar 12 10:45:22 2014 New Revision: 263085 URL: http://svnweb.freebsd.org/changeset/base/263085 Log: Make the strerror tests work without libtap. Just replace the simple calls to the library with ad-hoc code. We should later rewrite these with the ATF libraries anyway, which are part of the base system. Modified: head/tools/regression/lib/libc/string/Makefile head/tools/regression/lib/libc/string/test-strerror.c Modified: head/tools/regression/lib/libc/string/Makefile ============================================================================== --- head/tools/regression/lib/libc/string/Makefile Wed Mar 12 10:42:58 2014 (r263084) +++ head/tools/regression/lib/libc/string/Makefile Wed Mar 12 10:45:22 2014 (r263085) @@ -1,9 +1,5 @@ # $FreeBSD$ -CFLAGS+= -I/usr/local/include -LDFLAGS+= -L/usr/local/lib -LDLIBS= -ltap - TESTS= test-stpncpy test-strerror test-wcscasecmp test-wcsnlen .PHONY: tests Modified: head/tools/regression/lib/libc/string/test-strerror.c ============================================================================== --- head/tools/regression/lib/libc/string/test-strerror.c Wed Mar 12 10:42:58 2014 (r263084) +++ head/tools/regression/lib/libc/string/test-strerror.c Wed Mar 12 10:45:22 2014 (r263085) @@ -33,7 +33,19 @@ #include #include -#include +static int test_count = 1; +static int exit_status = EXIT_SUCCESS; + +#define CHECK(x) \ + do { \ + if (x) { \ + printf("ok %d\n", test_count); \ + } else { \ + printf("not ok %d # %s\n", test_count, #x); \ + exit_status = EXIT_FAILURE; \ + } \ + ++test_count; \ + } while (0) int main(void) @@ -42,7 +54,7 @@ main(void) char *sret; int iret; - plan_tests(27); + printf("1..27\n"); /* * strerror() failure tests. @@ -50,86 +62,86 @@ main(void) errno = 0; sret = strerror(INT_MAX); snprintf(buf, sizeof(buf), "Unknown error: %d", INT_MAX); - ok1(strcmp(sret, buf) == 0); - ok1(errno == EINVAL); + CHECK(strcmp(sret, buf) == 0); + CHECK(errno == EINVAL); /* * strerror() success tests. */ errno = 0; sret = strerror(0); - ok1(strcmp(sret, "No error: 0") == 0); - ok1(errno == 0); + CHECK(strcmp(sret, "No error: 0") == 0); + CHECK(errno == 0); errno = 0; sret = strerror(EPERM); - ok1(strcmp(sret, "Operation not permitted") == 0); - ok1(errno == 0); + CHECK(strcmp(sret, "Operation not permitted") == 0); + CHECK(errno == 0); errno = 0; sret = strerror(EPFNOSUPPORT); - ok1(strcmp(sret, "Protocol family not supported") == 0); - ok1(errno == 0); + CHECK(strcmp(sret, "Protocol family not supported") == 0); + CHECK(errno == 0); errno = 0; sret = strerror(ELAST); - ok1(errno == 0); + CHECK(errno == 0); /* * strerror_r() failure tests. */ memset(buf, '*', sizeof(buf)); iret = strerror_r(-1, buf, sizeof(buf)); - ok1(strcmp(buf, "Unknown error: -1") == 0); - ok1(iret == EINVAL); + CHECK(strcmp(buf, "Unknown error: -1") == 0); + CHECK(iret == EINVAL); memset(buf, '*', sizeof(buf)); /* One byte too short. */ iret = strerror_r(EPERM, buf, strlen("Operation not permitted")); - ok1(strcmp(buf, "Operation not permitte") == 0); - ok1(iret == ERANGE); + CHECK(strcmp(buf, "Operation not permitte") == 0); + CHECK(iret == ERANGE); memset(buf, '*', sizeof(buf)); /* One byte too short. */ iret = strerror_r(-1, buf, strlen("Unknown error: -1")); - ok1(strcmp(buf, "Unknown error: -") == 0); - ok1(iret == EINVAL); + CHECK(strcmp(buf, "Unknown error: -") == 0); + CHECK(iret == EINVAL); memset(buf, '*', sizeof(buf)); /* Two bytes too short. */ iret = strerror_r(-2, buf, strlen("Unknown error: -2") - 1); - ok1(strcmp(buf, "Unknown error: ") == 0); - ok1(iret == EINVAL); + CHECK(strcmp(buf, "Unknown error: ") == 0); + CHECK(iret == EINVAL); memset(buf, '*', sizeof(buf)); /* Three bytes too short. */ iret = strerror_r(-2, buf, strlen("Unknown error: -2") - 2); - ok1(strcmp(buf, "Unknown error:") == 0); - ok1(iret == EINVAL); + CHECK(strcmp(buf, "Unknown error:") == 0); + CHECK(iret == EINVAL); memset(buf, '*', sizeof(buf)); /* One byte too short. */ iret = strerror_r(12345, buf, strlen("Unknown error: 12345")); - ok1(strcmp(buf, "Unknown error: 1234") == 0); - ok1(iret == EINVAL); + CHECK(strcmp(buf, "Unknown error: 1234") == 0); + CHECK(iret == EINVAL); /* * strerror_r() success tests. */ memset(buf, '*', sizeof(buf)); iret = strerror_r(0, buf, sizeof(buf)); - ok1(strcmp(buf, "No error: 0") == 0); - ok1(iret == 0); + CHECK(strcmp(buf, "No error: 0") == 0); + CHECK(iret == 0); memset(buf, '*', sizeof(buf)); iret = strerror_r(EDEADLK, buf, sizeof(buf)); - ok1(strcmp(buf, "Resource deadlock avoided") == 0); - ok1(iret == 0); + CHECK(strcmp(buf, "Resource deadlock avoided") == 0); + CHECK(iret == 0); memset(buf, '*', sizeof(buf)); iret = strerror_r(EPROCLIM, buf, sizeof(buf)); - ok1(strcmp(buf, "Too many processes") == 0); - ok1(iret == 0); + CHECK(strcmp(buf, "Too many processes") == 0); + CHECK(iret == 0); - return exit_status(); + return exit_status; }