From owner-svn-src-head@FreeBSD.ORG Sun Nov 16 07:55:29 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9C9149F7; Sun, 16 Nov 2014 07:55:29 +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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7D5D988E; Sun, 16 Nov 2014 07:55:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAG7tTrT033875; Sun, 16 Nov 2014 07:55:29 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAG7tTKR033873; Sun, 16 Nov 2014 07:55:29 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201411160755.sAG7tTKR033873@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sun, 16 Nov 2014 07:55:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r274581 - in head: lib/libc/tests/gen tools/regression/lib/libc/gen 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.18-1 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: Sun, 16 Nov 2014 07:55:29 -0000 Author: ngie Date: Sun Nov 16 07:55:28 2014 New Revision: 274581 URL: https://svnweb.freebsd.org/changeset/base/274581 Log: Convert tools/regression/lib/libc/gen/test-arc4random into an ATF testcase and rename as lib/libc/gen/arc4random_test Sponsored by: EMC / Isilon Storage Division Added: head/lib/libc/tests/gen/arc4random_test.c - copied, changed from r274390, head/tools/regression/lib/libc/gen/test-arc4random.c Deleted: head/tools/regression/lib/libc/gen/test-arc4random.c Modified: head/lib/libc/tests/gen/Makefile Modified: head/lib/libc/tests/gen/Makefile ============================================================================== --- head/lib/libc/tests/gen/Makefile Sun Nov 16 07:03:19 2014 (r274580) +++ head/lib/libc/tests/gen/Makefile Sun Nov 16 07:55:28 2014 (r274581) @@ -4,6 +4,8 @@ TESTSDIR= ${TESTSBASE}/lib/libc/gen +ATF_TESTS_C= arc4random_test + # TODO: t_closefrom, t_cpuset, t_fmtcheck, t_randomid, t_sleep # TODO: t_siginfo (fixes require further inspection) # TODO: t_sethostname_test (consistently screws up the hostname) Copied and modified: head/lib/libc/tests/gen/arc4random_test.c (from r274390, head/tools/regression/lib/libc/gen/test-arc4random.c) ============================================================================== --- head/tools/regression/lib/libc/gen/test-arc4random.c Tue Nov 11 18:15:05 2014 (r274390, copy source) +++ head/lib/libc/tests/gen/arc4random_test.c Sun Nov 16 07:55:28 2014 (r274581) @@ -27,13 +27,14 @@ #include __FBSDID("$FreeBSD$"); -#include #include +#include #include #include #include #include #include +#include /* * BUFSIZE is the number of bytes of rc4 output to compare. The probability @@ -45,7 +46,9 @@ __FBSDID("$FreeBSD$"); * Test whether arc4random_buf() returns the same sequence of bytes in both * parent and child processes. (Hint: It shouldn't.) */ -int main(int argc, char *argv[]) { +ATF_TC_WITHOUT_HEAD(test_arc4random); +ATF_TC_BODY(test_arc4random, tc) +{ struct shared_page { char parentbuf[BUFSIZE]; char childbuf[BUFSIZE]; @@ -65,10 +68,7 @@ int main(int argc, char *argv[]) { arc4random_buf(&c, 1); pid = fork(); - if (pid < 0) { - printf("fail 1 - fork\n"); - exit(1); - } + ATF_REQUIRE(0 <= pid); if (pid == 0) { /* child */ arc4random_buf(page->childbuf, BUFSIZE); @@ -79,11 +79,14 @@ int main(int argc, char *argv[]) { arc4random_buf(page->parentbuf, BUFSIZE); wait(&status); } - if (memcmp(page->parentbuf, page->childbuf, BUFSIZE) == 0) { - printf("fail 1 - sequences are the same\n"); - exit(1); - } + ATF_CHECK_MSG(memcmp(page->parentbuf, page->childbuf, BUFSIZE) != 0, + "sequences are the same"); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, test_arc4random); - printf("ok 1 - sequences are different\n"); - exit(0); + return (atf_no_error()); }