summaryrefslogtreecommitdiffstats
path: root/lib/libc/tests/stdio/fmemopen2_test.c
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2015-12-05 04:17:40 +0000
committerngie <ngie@FreeBSD.org>2015-12-05 04:17:40 +0000
commitfde15bf9a66c2d1600fc39cc4f6c9616516a8743 (patch)
treedb28c4c2a0cb15c8423039892892e5756178c96d /lib/libc/tests/stdio/fmemopen2_test.c
parent233987c6df823b923e5622392372c4a05c615b6f (diff)
downloadFreeBSD-src-fde15bf9a66c2d1600fc39cc4f6c9616516a8743.zip
FreeBSD-src-fde15bf9a66c2d1600fc39cc4f6c9616516a8743.tar.gz
MFC r290537,r290540,r290560,r290856,r290871,r291839:
r290537: Integrate tools/regression/lib/libc/stdio into the FreeBSD test suite as lib/libc/tests/stdio - Fix some whitespace - Convert the testcases to ATF - Convert "/dev/null" to _PATH_DEVNULL Sponsored by: EMC / Isilon Storage Division r290540: printfloat_test and scanfloat_test need symbols from msun; these are automatically provided on amd64, but not i386. Add libm to DPADD/LDADD to unbreak the i386 tinderbox Pointyhat to: ngie Sponsored by: EMC / Isilon Storage Division r290560: Convert print_positional_test over to ATF Somehow missed in r290537 Sponsored by: EMC / Isilon Storage Division r290856 (by bapt): also skip the definition of ':fopen_regular' to avoid the build to fail due to unused variables defined by ATF macros r290871: Disable -Wformat with scanfloat_test when compiling with gcc to avoid a "use of assignment suppression and length modifier together in scanf format" warning on line 90 (it's intentional) Sponsored by: EMC / Isilon Storage Division r291839: Initialize errno to 0 in the nul testcase before testing it For some odd reason stable/10 requires this, otherwise it always fails the errno == 0 check on line 196. Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'lib/libc/tests/stdio/fmemopen2_test.c')
-rw-r--r--lib/libc/tests/stdio/fmemopen2_test.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/lib/libc/tests/stdio/fmemopen2_test.c b/lib/libc/tests/stdio/fmemopen2_test.c
index d137780..d4a14a8 100644
--- a/lib/libc/tests/stdio/fmemopen2_test.c
+++ b/lib/libc/tests/stdio/fmemopen2_test.c
@@ -35,15 +35,13 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <string.h>
#include <strings.h>
+
#include <atf-c.h>
ATF_TC_WITHOUT_HEAD(test_preexisting);
ATF_TC_BODY(test_preexisting, tc)
{
- /*
- * Use a pre-existing buffer.
- */
-
+ /* Use a pre-existing buffer. */
char buf[512];
char buf2[512];
char str[] = "Test writing some stuff";
@@ -74,7 +72,7 @@ ATF_TC_BODY(test_preexisting, tc)
nofr = fread(buf2, 1, sizeof(buf2), fp);
ATF_REQUIRE(nofr == sizeof(buf2));
- /*
+ /*
* Since a write on a FILE * retrieved by fmemopen
* will add a '\0' (if there's space), we can check
* the strings for equality.
@@ -105,10 +103,7 @@ ATF_TC_BODY(test_preexisting, tc)
ATF_TC_WITHOUT_HEAD(test_autoalloc);
ATF_TC_BODY(test_autoalloc, tc)
{
- /*
- * Let fmemopen allocate the buffer.
- */
-
+ /* Let fmemopen allocate the buffer. */
char str[] = "A quick test";
FILE *fp;
long pos;
@@ -129,9 +124,7 @@ ATF_TC_BODY(test_autoalloc, tc)
pos = ftell(fp);
ATF_REQUIRE(pos == 512);
- /*
- * Try to write past the end, we should get a short object count (0)
- */
+ /* Try to write past the end, we should get a short object count (0) */
nofw = fwrite("a", 1, 1, fp);
ATF_REQUIRE(nofw == 0);
@@ -172,10 +165,7 @@ ATF_TC_BODY(test_data_length, tc)
nofw = fwrite(str, 1, sizeof(str), fp);
ATF_REQUIRE(nofw == sizeof(str));
- /*
- * Now seek to the end and check that ftell
- * gives us sizeof(str).
- */
+ /* Now seek to the end and check that ftell gives us sizeof(str). */
rc = fseek(fp, 0, SEEK_END);
ATF_REQUIRE(rc == 0);
pos = ftell(fp);
@@ -263,9 +253,7 @@ ATF_TC_BODY(test_append_binary_pos, tc)
ATF_REQUIRE(ftell(fp) == 0L);
fclose(fp);
- /*
- * Make sure that a pre-allocated buffer behaves correctly.
- */
+ /* Make sure that a pre-allocated buffer behaves correctly. */
char buf[] = "Hello";
fp = fmemopen(buf, sizeof(buf), "ab+");
ATF_REQUIRE(ftell(fp) == strlen(buf));
@@ -275,9 +263,7 @@ ATF_TC_BODY(test_append_binary_pos, tc)
ATF_TC_WITHOUT_HEAD(test_size_0);
ATF_TC_BODY(test_size_0, tc)
{
- /*
- * POSIX mandates that we return EINVAL if size is 0.
- */
+ /* POSIX mandates that we return EINVAL if size is 0. */
FILE *fp;
OpenPOWER on IntegriCloud