From owner-svn-src-head@freebsd.org Sun Nov 8 21:38:48 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 23FC5A29549; Sun, 8 Nov 2015 21:38:48 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 D6AA714E2; Sun, 8 Nov 2015 21:38:47 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tA8LckqW011016; Sun, 8 Nov 2015 21:38:46 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tA8Lck5m011015; Sun, 8 Nov 2015 21:38:46 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201511082138.tA8Lck5m011015@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sun, 8 Nov 2015 21:38:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290560 - head/lib/libc/tests/stdio 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.20 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, 08 Nov 2015 21:38:48 -0000 Author: ngie Date: Sun Nov 8 21:38:46 2015 New Revision: 290560 URL: https://svnweb.freebsd.org/changeset/base/290560 Log: Convert print_positional_test over to ATF Somehow missed in r290537 X-MFC with: r290537 MFC after: 1 week Sponsored by: EMC / Isilon Storage Division Modified: head/lib/libc/tests/stdio/print_positional_test.c Modified: head/lib/libc/tests/stdio/print_positional_test.c ============================================================================== --- head/lib/libc/tests/stdio/print_positional_test.c Sun Nov 8 21:22:24 2015 (r290559) +++ head/lib/libc/tests/stdio/print_positional_test.c Sun Nov 8 21:38:46 2015 (r290560) @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + const char correct[] = "|xx 01 02 03 04\n" "|xx 05 06 07 08\n" @@ -53,15 +55,13 @@ const char correct[] = const char correct2[] = "b bs BSD"; +static char buf[1024]; +static wchar_t wbuf1[1024], wbuf2[1024]; +static const char *temp; -int -main(int argc, char *argv[]) +ATF_TC_WITHOUT_HEAD(positional_normal); +ATF_TC_BODY(positional_normal, tc) { - char buf[1024]; - wchar_t wbuf1[1024], wbuf2[1024]; - const char *temp; - - printf("1..4\n"); /* Test positional arguments */ snprintf(buf, sizeof buf, @@ -86,8 +86,13 @@ main(int argc, char *argv[]) "37", "38", "39", "40", "41", "42", "43", "44", 45, -1L, 1LL, -1, 1LL ); - printf("%sok 1 - print-positional normal\n", - strcmp(buf, correct) == 0 ? "" : "not "); + ATF_REQUIRE_MSG(wcscmp(wbuf1, wbuf2) == 0, + "buffers didn't match"); +} + +ATF_TC_WITHOUT_HEAD(positional_wide); +ATF_TC_BODY(positional_wide, tc) +{ swprintf(wbuf1, sizeof wbuf1, L"|xx %1$s %2$s %3$s %4$s\n" @@ -113,20 +118,39 @@ main(int argc, char *argv[]) ); temp = correct; mbsrtowcs(wbuf2, &temp, sizeof wbuf2, NULL); - printf("%sok 2 - print-positional wide\n", - wcscmp(wbuf1, wbuf2) == 0 ? "" : "not "); + ATF_REQUIRE_MSG(wcscmp(wbuf1, wbuf2) == 0, + "buffers didn't match"); +} + +ATF_TC_WITHOUT_HEAD(positional_precision); +ATF_TC_BODY(positional_precision, tc) +{ snprintf(buf, sizeof buf, "%2$.*4$s %2$.*3$s %1$s", "BSD", "bsd", 2, 1); - printf("%sok 3 - print-positional precision\n", - strcmp(buf, correct2) == 0 ? "" : "not "); + ATF_REQUIRE_MSG(strcmp(buf, correct2) == 0, + "buffers didn't match"); +} + +ATF_TC_WITHOUT_HEAD(positional_precision_wide); +ATF_TC_BODY(positional_precision_wide, tc) +{ swprintf(wbuf1, sizeof buf, L"%2$.*4$s %2$.*3$s %1$s", "BSD", "bsd", 2, 1); temp = correct2; mbsrtowcs(wbuf2, &temp, sizeof wbuf2, NULL); - printf("%sok 4 - print-positional precision wide\n", - wcscmp(wbuf1, wbuf2) == 0 ? "" : "not "); + ATF_REQUIRE_MSG(wcscmp(wbuf1, wbuf2) == 0, + "buffers didn't match"); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, positional_normal); + ATF_TP_ADD_TC(tp, positional_wide); + ATF_TP_ADD_TC(tp, positional_precision); + ATF_TP_ADD_TC(tp, positional_precision_wide); - exit(0); + return (atf_no_error()); }