From: Josh Gao Date: Tue, 10 Jan 2017 21:00:37 +0000 (-0800) Subject: Improve fmemopen tests. X-Git-Tag: android-x86-8.1-r1~224^2^2~42^2~25^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=2f06e1028037c63d517e45b4055f946aa79dc5ee;p=android-x86%2Fbionic.git Improve fmemopen tests. Tag fmemopen_NULL as a known failure, and make it reliably fail by memsetting the buffer we read to. Bug: http://b/33251022 Test: bionic-unit-tests/bionic-unit-tests64 on bullhead Test: bionic-unit-tests-glibc --gtest_filter="*memopen*" Change-Id: I381783282359851c9de47146dafbb5a291960c2a --- diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp index 63da9e040..da70d2138 100644 --- a/tests/stdio_test.cpp +++ b/tests/stdio_test.cpp @@ -31,6 +31,7 @@ #include "BionicDeathTest.h" #include "TemporaryFile.h" +#include "utils.h" #if defined(NOFORTIFY) #define STDIO_TEST stdio_nofortify @@ -47,6 +48,7 @@ static void AssertFileIs(FILE* fp, const char* expected, bool is_fmemopen = fals rewind(fp); char line[1024]; + memset(line, 0xff, sizeof(line)); ASSERT_EQ(line, fgets(line, sizeof(line), fp)); ASSERT_STREQ(expected, line); @@ -938,7 +940,7 @@ TEST(STDIO_TEST, fmemopen) { fclose(fp); } -TEST(STDIO_TEST, fmemopen_NULL) { +TEST(STDIO_TEST, KNOWN_FAILURE_ON_BIONIC(fmemopen_NULL)) { FILE* fp = fmemopen(nullptr, 128, "r+"); ASSERT_NE(EOF, fputs("xyz\n", fp)); diff --git a/tests/utils.h b/tests/utils.h index 4c3aef4cd..79eed10b9 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -32,6 +32,12 @@ #include "private/ScopeGuard.h" +#if defined(__BIONIC__) +#define KNOWN_FAILURE_ON_BIONIC(x) xfail_ ## x +#else +#define KNOWN_FAILURE_ON_BIONIC(x) x +#endif + #if defined(__linux__) struct map_record {