summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2015-11-08 21:38:46 +0000
committerngie <ngie@FreeBSD.org>2015-11-08 21:38:46 +0000
commit9367721dc3e4034224f3b5a710c848e39bb2c1df (patch)
tree23e805590414e2cbab8dacaf2c4fb403a5d305fb
parent6dbf9b92d94ac99671a10ceaa84bb4958ad2ed75 (diff)
downloadFreeBSD-src-9367721dc3e4034224f3b5a710c848e39bb2c1df.zip
FreeBSD-src-9367721dc3e4034224f3b5a710c848e39bb2c1df.tar.gz
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
-rw-r--r--lib/libc/tests/stdio/print_positional_test.c56
1 files changed, 40 insertions, 16 deletions
diff --git a/lib/libc/tests/stdio/print_positional_test.c b/lib/libc/tests/stdio/print_positional_test.c
index 6eeb8f1..1de43a1 100644
--- a/lib/libc/tests/stdio/print_positional_test.c
+++ b/lib/libc/tests/stdio/print_positional_test.c
@@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <wchar.h>
+#include <atf-c.h>
+
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());
}
OpenPOWER on IntegriCloud