-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc][stdio] Separate temporary files for unit test and hermetic test in stdio test suite. #149740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…t in stdio test suite.
|
@llvm/pr-subscribers-libc Author: None (lntue) ChangesPatch is 21.01 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/149740.diff 21 Files Affected:
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 3fb62788c1168..267c32e956945 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -71,6 +71,7 @@ endfunction()
function(_get_hermetic_test_compile_options output_var)
_get_common_test_compile_options(compile_options "" "")
+ list(APPEND compile_options "-DLIBC_TEST=HERMETIC")
# null check tests are death tests, remove from hermetic tests for now.
if(LIBC_ADD_NULL_CHECKS)
@@ -232,6 +233,7 @@ function(create_libc_unittest fq_target_name)
_get_common_test_compile_options(compile_options "${LIBC_UNITTEST_C_TEST}"
"${LIBC_UNITTEST_FLAGS}")
+ list(APPEND compile_options "-DLIBC_TEST=UNIT")
# TODO: Ideally we would have a separate function for link options.
set(link_options
${compile_options}
diff --git a/libc/test/UnitTest/Test.h b/libc/test/UnitTest/Test.h
index a5a2a3c7cf58e..e70fc51869624 100644
--- a/libc/test/UnitTest/Test.h
+++ b/libc/test/UnitTest/Test.h
@@ -52,4 +52,13 @@
libc_errno = 0; \
} while (0)
+// Some macro utility to append file names with LIBC_TEST macro's value to be
+// used in stdio tests.
+#undef STR
+#undef EVAL_THEN_STR
+#define STR(X) #X
+#define EVAL_THEN_STR(X) STR(X)
+
+#define APPEND_LIBC_TEST(X) X "." EVAL_THEN_STR(LIBC_TEST)
+
#endif // LLVM_LIBC_TEST_UNITTEST_TEST_H
diff --git a/libc/test/src/__support/File/platform_file_test.cpp b/libc/test/src/__support/File/platform_file_test.cpp
index 6b2be2a149329..425da6ce2ad86 100644
--- a/libc/test/src/__support/File/platform_file_test.cpp
+++ b/libc/test/src/__support/File/platform_file_test.cpp
@@ -21,7 +21,8 @@ LIBC_INLINE File *openfile(const char *file_name, const char *mode) {
}
TEST(LlvmLibcPlatformFileTest, CreateWriteCloseAndReadBack) {
- constexpr char FILENAME[] = "testdata/create_write_close_and_readback.test";
+ constexpr char FILENAME[] =
+ APPEND_LIBC_TEST("testdata/create_write_close_and_readback.test");
File *file = openfile(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
ASSERT_EQ(file->write(TEXT, TEXT_SIZE).value, TEXT_SIZE);
@@ -42,7 +43,8 @@ TEST(LlvmLibcPlatformFileTest, CreateWriteCloseAndReadBack) {
}
TEST(LlvmLibcPlatformFileTest, CreateWriteSeekAndReadBack) {
- constexpr char FILENAME[] = "testdata/create_write_seek_and_readback.test";
+ constexpr char FILENAME[] =
+ APPEND_LIBC_TEST("testdata/create_write_seek_and_readback.test");
File *file = openfile(FILENAME, "w+");
ASSERT_FALSE(file == nullptr);
ASSERT_EQ(file->write(TEXT, TEXT_SIZE).value, TEXT_SIZE);
@@ -62,7 +64,8 @@ TEST(LlvmLibcPlatformFileTest, CreateWriteSeekAndReadBack) {
}
TEST(LlvmLibcPlatformFileTest, CreateAppendCloseAndReadBack) {
- constexpr char FILENAME[] = "testdata/create_append_close_and_readback.test";
+ constexpr char FILENAME[] =
+ APPEND_LIBC_TEST("testdata/create_append_close_and_readback.test");
File *file = openfile(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
ASSERT_EQ(file->write(TEXT, TEXT_SIZE).value, TEXT_SIZE);
@@ -91,7 +94,8 @@ TEST(LlvmLibcPlatformFileTest, CreateAppendCloseAndReadBack) {
}
TEST(LlvmLibcPlatformFileTest, CreateAppendSeekAndReadBack) {
- constexpr char FILENAME[] = "testdata/create_append_seek_and_readback.test";
+ constexpr char FILENAME[] =
+ APPEND_LIBC_TEST("testdata/create_append_seek_and_readback.test");
File *file = openfile(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
ASSERT_EQ(file->write(TEXT, TEXT_SIZE).value, TEXT_SIZE);
@@ -124,7 +128,7 @@ TEST(LlvmLibcPlatformFileTest, LargeFile) {
for (size_t i = 0; i < DATA_SIZE; ++i)
write_data[i] = BYTE;
- constexpr char FILENAME[] = "testdata/large_file.test";
+ constexpr char FILENAME[] = APPEND_LIBC_TEST("testdata/large_file.test");
File *file = openfile(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
@@ -151,7 +155,8 @@ TEST(LlvmLibcPlatformFileTest, LargeFile) {
}
TEST(LlvmLibcPlatformFileTest, ReadSeekCurAndRead) {
- constexpr char FILENAME[] = "testdata/read_seek_cur_and_read.test";
+ constexpr char FILENAME[] =
+ APPEND_LIBC_TEST("testdata/read_seek_cur_and_read.test");
File *file = openfile(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
constexpr char CONTENT[] = "1234567890987654321";
@@ -178,7 +183,8 @@ TEST(LlvmLibcPlatformFileTest, ReadSeekCurAndRead) {
}
TEST(LlvmLibcPlatformFileTest, IncorrectOperation) {
- constexpr char FILENAME[] = "testdata/incorrect_operation.test";
+ constexpr char FILENAME[] =
+ APPEND_LIBC_TEST("testdata/incorrect_operation.test");
char data[1] = {123};
File *file = openfile(FILENAME, "w");
diff --git a/libc/test/src/stdio/fdopen_test.cpp b/libc/test/src/stdio/fdopen_test.cpp
index b53184c30be36..bab1d33edcb04 100644
--- a/libc/test/src/stdio/fdopen_test.cpp
+++ b/libc/test/src/stdio/fdopen_test.cpp
@@ -24,7 +24,8 @@ using LlvmLibcStdioFdopenTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcStdioFdopenTest, WriteAppendRead) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
- constexpr const char *TEST_FILE_NAME = "testdata/write_read_append.test";
+ constexpr const char *TEST_FILE_NAME =
+ APPEND_LIBC_TEST("testdata/write_read_append.test");
auto TEST_FILE = libc_make_test_file_path(TEST_FILE_NAME);
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
auto *fp = LIBC_NAMESPACE::fdopen(fd, "w");
@@ -54,7 +55,8 @@ TEST_F(LlvmLibcStdioFdopenTest, WriteAppendRead) {
}
TEST_F(LlvmLibcStdioFdopenTest, InvalidFd) {
- constexpr const char *TEST_FILE_NAME = "testdata/invalid_fd.test";
+ constexpr const char *TEST_FILE_NAME =
+ APPEND_LIBC_TEST("testdata/invalid_fd.test");
auto TEST_FILE = libc_make_test_file_path(TEST_FILE_NAME);
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_CREAT | O_TRUNC);
LIBC_NAMESPACE::close(fd);
@@ -65,7 +67,8 @@ TEST_F(LlvmLibcStdioFdopenTest, InvalidFd) {
}
TEST_F(LlvmLibcStdioFdopenTest, InvalidMode) {
- constexpr const char *TEST_FILE_NAME = "testdata/invalid_mode.test";
+ constexpr const char *TEST_FILE_NAME =
+ APPEND_LIBC_TEST("testdata/invalid_mode.test");
auto TEST_FILE = libc_make_test_file_path(TEST_FILE_NAME);
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_CREAT | O_RDONLY, S_IRWXU);
ASSERT_ERRNO_SUCCESS();
diff --git a/libc/test/src/stdio/fgetc_test.cpp b/libc/test/src/stdio/fgetc_test.cpp
index be2e50271b510..1d242a0475aba 100644
--- a/libc/test/src/stdio/fgetc_test.cpp
+++ b/libc/test/src/stdio/fgetc_test.cpp
@@ -56,9 +56,10 @@ class LlvmLibcGetcTest : public LIBC_NAMESPACE::testing::ErrnoCheckingTest {
};
TEST_F(LlvmLibcGetcTest, WriteAndReadCharactersWithFgetc) {
- test_with_func(&LIBC_NAMESPACE::fgetc, "testdata/fgetc.test");
+ test_with_func(&LIBC_NAMESPACE::fgetc,
+ APPEND_LIBC_TEST("testdata/fgetc.test"));
}
TEST_F(LlvmLibcGetcTest, WriteAndReadCharactersWithGetc) {
- test_with_func(&LIBC_NAMESPACE::getc, "testdata/getc.test");
+ test_with_func(&LIBC_NAMESPACE::getc, APPEND_LIBC_TEST("testdata/getc.test"));
}
diff --git a/libc/test/src/stdio/fgetc_unlocked_test.cpp b/libc/test/src/stdio/fgetc_unlocked_test.cpp
index bef9dafd3d87c..16d79211f5e8f 100644
--- a/libc/test/src/stdio/fgetc_unlocked_test.cpp
+++ b/libc/test/src/stdio/fgetc_unlocked_test.cpp
@@ -62,9 +62,10 @@ class LlvmLibcGetcTest : public LIBC_NAMESPACE::testing::ErrnoCheckingTest {
TEST_F(LlvmLibcGetcTest, WriteAndReadCharactersWithFgetcUnlocked) {
test_with_func(&LIBC_NAMESPACE::fgetc_unlocked,
- "testdata/fgetc_unlocked.test");
+ APPEND_LIBC_TEST("testdata/fgetc_unlocked.test"));
}
TEST_F(LlvmLibcGetcTest, WriteAndReadCharactersWithGetcUnlocked) {
- test_with_func(&LIBC_NAMESPACE::getc_unlocked, "testdata/getc_unlocked.test");
+ test_with_func(&LIBC_NAMESPACE::getc_unlocked,
+ APPEND_LIBC_TEST("testdata/getc_unlocked.test"));
}
diff --git a/libc/test/src/stdio/fgets_test.cpp b/libc/test/src/stdio/fgets_test.cpp
index 8fc38b0659181..14f054eee1339 100644
--- a/libc/test/src/stdio/fgets_test.cpp
+++ b/libc/test/src/stdio/fgets_test.cpp
@@ -20,7 +20,7 @@ using LlvmLibcFgetsTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
TEST_F(LlvmLibcFgetsTest, WriteAndReadCharacters) {
- constexpr char FILENAME[] = "testdata/fgets.test";
+ constexpr char FILENAME[] = APPEND_LIBC_TEST("testdata/fgets.test");
::FILE *file = LIBC_NAMESPACE::fopen(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
constexpr char CONTENT[] = "123456789\n"
diff --git a/libc/test/src/stdio/fileop_test.cpp b/libc/test/src/stdio/fileop_test.cpp
index e097785832d56..02328042b92b3 100644
--- a/libc/test/src/stdio/fileop_test.cpp
+++ b/libc/test/src/stdio/fileop_test.cpp
@@ -29,7 +29,8 @@ using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::NE;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::returns;
TEST_F(LlvmLibcFILETest, SimpleFileOperations) {
- constexpr char FILENAME[] = "testdata/simple_operations.test";
+ constexpr char FILENAME[] =
+ APPEND_LIBC_TEST("testdata/simple_operations.test");
::FILE *file = LIBC_NAMESPACE::fopen(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
ASSERT_GE(LIBC_NAMESPACE::fileno(file), 0);
@@ -127,7 +128,7 @@ TEST_F(LlvmLibcFILETest, SimpleFileOperations) {
}
TEST_F(LlvmLibcFILETest, FFlush) {
- constexpr char FILENAME[] = "testdata/fflush.test";
+ constexpr char FILENAME[] = APPEND_LIBC_TEST("testdata/fflush.test");
::FILE *file = LIBC_NAMESPACE::fopen(FILENAME, "w+");
ASSERT_FALSE(file == nullptr);
constexpr char CONTENT[] = "1234567890987654321";
@@ -154,7 +155,7 @@ TEST_F(LlvmLibcFILETest, FOpenFWriteSizeGreaterThanOne) {
};
constexpr MyStruct WRITE_DATA[] = {{'a', 1}, {'b', 2}, {'c', 3}};
constexpr size_t WRITE_NMEMB = sizeof(WRITE_DATA) / sizeof(MyStruct);
- constexpr char FILENAME[] = "testdata/fread_fwrite.test";
+ constexpr char FILENAME[] = APPEND_LIBC_TEST("testdata/fread_fwrite.test");
FILE *file = LIBC_NAMESPACE::fopen(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
diff --git a/libc/test/src/stdio/fopen_test.cpp b/libc/test/src/stdio/fopen_test.cpp
index 42e7c57cffe04..3f651f755e7f3 100644
--- a/libc/test/src/stdio/fopen_test.cpp
+++ b/libc/test/src/stdio/fopen_test.cpp
@@ -17,7 +17,8 @@
TEST(LlvmLibcFOpenTest, PrintToFile) {
int result;
- FILE *file = LIBC_NAMESPACE::fopen("./testdata/test_data.txt", "w");
+ FILE *file =
+ LIBC_NAMESPACE::fopen(APPEND_LIBC_TEST("testdata/test.txt"), "w");
ASSERT_FALSE(file == nullptr);
static constexpr char STRING[] = "A simple string written to a file\n";
@@ -26,7 +27,8 @@ TEST(LlvmLibcFOpenTest, PrintToFile) {
ASSERT_EQ(0, LIBC_NAMESPACE::fclose(file));
- FILE *new_file = LIBC_NAMESPACE::fopen("./testdata/test_data.txt", "r");
+ FILE *new_file =
+ LIBC_NAMESPACE::fopen(APPEND_LIBC_TEST("testdata/test.txt"), "r");
ASSERT_FALSE(new_file == nullptr);
static char data[64] = {0};
diff --git a/libc/test/src/stdio/fprintf_test.cpp b/libc/test/src/stdio/fprintf_test.cpp
index 82a3e039d9baa..6799323cc6ad9 100644
--- a/libc/test/src/stdio/fprintf_test.cpp
+++ b/libc/test/src/stdio/fprintf_test.cpp
@@ -32,7 +32,7 @@ using ::fread;
} // namespace printf_test
TEST(LlvmLibcFPrintfTest, WriteToFile) {
- const char *FILENAME = "fprintf_output.test";
+ const char *FILENAME = APPEND_LIBC_TEST("fprintf_output.test");
auto FILE_PATH = libc_make_test_file_path(FILENAME);
::FILE *file = printf_test::fopen(FILE_PATH, "w");
diff --git a/libc/test/src/stdio/fscanf_test.cpp b/libc/test/src/stdio/fscanf_test.cpp
index e5b8c4f422bac..451ff94055ea5 100644
--- a/libc/test/src/stdio/fscanf_test.cpp
+++ b/libc/test/src/stdio/fscanf_test.cpp
@@ -34,7 +34,7 @@ using ::fwrite;
} // namespace scanf_test
TEST(LlvmLibcFScanfTest, WriteToFile) {
- const char *FILENAME = "fscanf_output.test";
+ const char *FILENAME = APPEND_LIBC_TEST("fscanf_output.test");
auto FILE_PATH = libc_make_test_file_path(FILENAME);
::FILE *file = scanf_test::fopen(FILE_PATH, "w");
ASSERT_FALSE(file == nullptr);
diff --git a/libc/test/src/stdio/ftell_test.cpp b/libc/test/src/stdio/ftell_test.cpp
index 01ff071f2ee78..1f762f38585bc 100644
--- a/libc/test/src/stdio/ftell_test.cpp
+++ b/libc/test/src/stdio/ftell_test.cpp
@@ -21,7 +21,7 @@
class LlvmLibcFTellTest : public LIBC_NAMESPACE::testing::Test {
protected:
void test_with_bufmode(int bufmode) {
- constexpr char FILENAME[] = "testdata/ftell.test";
+ constexpr char FILENAME[] = APPEND_LIBC_TEST("testdata/ftell.test");
// We will set a special buffer to the file so that we guarantee buffering.
constexpr size_t BUFFER_SIZE = 1024;
char buffer[BUFFER_SIZE];
diff --git a/libc/test/src/stdio/putc_test.cpp b/libc/test/src/stdio/putc_test.cpp
index e881a0e2d0108..6bf482794f0b8 100644
--- a/libc/test/src/stdio/putc_test.cpp
+++ b/libc/test/src/stdio/putc_test.cpp
@@ -16,7 +16,7 @@
#include "test/UnitTest/Test.h"
TEST(LlvmLibcPutcTest, WriteToFile) {
- constexpr char FILENAME[] = "testdata/putc_output.test";
+ constexpr char FILENAME[] = APPEND_LIBC_TEST("testdata/putc_output.test");
::FILE *file = LIBC_NAMESPACE::fopen(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
diff --git a/libc/test/src/stdio/remove_test.cpp b/libc/test/src/stdio/remove_test.cpp
index 296bff1f5dc15..20d166f0acb2f 100644
--- a/libc/test/src/stdio/remove_test.cpp
+++ b/libc/test/src/stdio/remove_test.cpp
@@ -25,7 +25,7 @@ TEST_F(LlvmLibcRemoveTest, CreateAndRemoveFile) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
- constexpr const char *FILENAME = "remove.test.file";
+ constexpr const char *FILENAME = APPEND_LIBC_TEST("remove.test.file");
auto TEST_FILE = libc_make_test_file_path(FILENAME);
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
ASSERT_ERRNO_SUCCESS();
@@ -42,7 +42,7 @@ TEST_F(LlvmLibcRemoveTest, CreateAndRemoveDir) {
// it was removed.
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
- constexpr const char *FILENAME = "remove.test.dir";
+ constexpr const char *FILENAME = APPEND_LIBC_TEST("remove.test.dir");
auto TEST_DIR = libc_make_test_file_path(FILENAME);
ASSERT_THAT(LIBC_NAMESPACE::mkdirat(AT_FDCWD, TEST_DIR, S_IRWXU),
Succeeds(0));
diff --git a/libc/test/src/stdio/rename_test.cpp b/libc/test/src/stdio/rename_test.cpp
index 135fb98c07fbb..af957e0fcbf79 100644
--- a/libc/test/src/stdio/rename_test.cpp
+++ b/libc/test/src/stdio/rename_test.cpp
@@ -24,7 +24,7 @@ TEST_F(LlvmLibcRenameTest, CreateAndRenameFile) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
- constexpr const char *FILENAME0 = "rename.test.file0";
+ constexpr const char *FILENAME0 = APPEND_LIBC_TEST("rename.test.file0");
auto TEST_FILEPATH0 = libc_make_test_file_path(FILENAME0);
int fd = LIBC_NAMESPACE::open(TEST_FILEPATH0, O_WRONLY | O_CREAT, S_IRWXU);
@@ -33,7 +33,7 @@ TEST_F(LlvmLibcRenameTest, CreateAndRenameFile) {
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::access(TEST_FILEPATH0, F_OK), Succeeds(0));
- constexpr const char *FILENAME1 = "rename.test.file1";
+ constexpr const char *FILENAME1 = APPEND_LIBC_TEST("rename.test.file1");
auto TEST_FILEPATH1 = libc_make_test_file_path(FILENAME1);
ASSERT_THAT(LIBC_NAMESPACE::rename(TEST_FILEPATH0, TEST_FILEPATH1),
Succeeds(0));
@@ -44,7 +44,7 @@ TEST_F(LlvmLibcRenameTest, CreateAndRenameFile) {
TEST_F(LlvmLibcRenameTest, RenameNonExistent) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
- constexpr const char *FILENAME1 = "rename.test.file1";
+ constexpr const char *FILENAME1 = APPEND_LIBC_TEST("rename.test.file1");
auto TEST_FILEPATH1 = libc_make_test_file_path(FILENAME1);
ASSERT_THAT(LIBC_NAMESPACE::rename("non-existent", TEST_FILEPATH1),
diff --git a/libc/test/src/stdio/setbuf_test.cpp b/libc/test/src/stdio/setbuf_test.cpp
index 25fea59076626..f1f98f7040402 100644
--- a/libc/test/src/stdio/setbuf_test.cpp
+++ b/libc/test/src/stdio/setbuf_test.cpp
@@ -18,7 +18,8 @@
TEST(LlvmLibcSetbufTest, DefaultBufsize) {
// The idea in this test is to change the buffer after opening a file and
// ensure that read and write work as expected.
- constexpr char FILENAME[] = "testdata/setbuf_test_default_bufsize.test";
+ constexpr char FILENAME[] =
+ APPEND_LIBC_TEST("testdata/setbuf_test_default_bufsize.test");
::FILE *file = LIBC_NAMESPACE::fopen(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
char buffer[BUFSIZ];
@@ -41,7 +42,8 @@ TEST(LlvmLibcSetbufTest, DefaultBufsize) {
TEST(LlvmLibcSetbufTest, NullBuffer) {
// The idea in this test is that we set a null buffer and ensure that
// everything works correctly.
- constexpr char FILENAME[] = "testdata/setbuf_test_null_buffer.test";
+ constexpr char FILENAME[] =
+ APPEND_LIBC_TEST("testdata/setbuf_test_null_buffer.test");
::FILE *file = LIBC_NAMESPACE::fopen(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
LIBC_NAMESPACE::setbuf(file, nullptr);
diff --git a/libc/test/src/stdio/setvbuf_test.cpp b/libc/test/src/stdio/setvbuf_test.cpp
index a0936ba79ef73..f55b8e2c3c722 100644
--- a/libc/test/src/stdio/setvbuf_test.cpp
+++ b/libc/test/src/stdio/setvbuf_test.cpp
@@ -23,7 +23,7 @@ TEST_F(LlvmLibcSetvbufTest, SetNBFBuffer) {
// then set a NBF buffer to the write handle. Since it is NBF, the data
// written using the write handle should be immediately readable by the read
// handle.
- constexpr char FILENAME[] = "testdata/setvbuf_nbf.test";
+ constexpr char FILENAME[] = APPEND_LIBC_TEST("testdata/setvbuf_nbf.test");
::FILE *fw = LIBC_NAMESPACE::fopen(FILENAME, "w");
ASSERT_FALSE(fw == nullptr);
@@ -59,7 +59,7 @@ TEST_F(LlvmLibcSetvbufTest, SetLBFBuffer) {
// then set a LBF buffer to the write handle. Since it is LBF, the data
// written using the write handle should be available right after a '\n' is
// written.
- constexpr char FILENAME[] = "testdata/setvbuf_lbf.test";
+ constexpr char FILENAME[] = APPEND_LIBC_TEST("testdata/setvbuf_lbf.test");
::FILE *fw = LIBC_NAMESPACE::fopen(FILENAME, "w");
ASSERT_FALSE(fw == nullptr);
@@ -96,7 +96,8 @@ TEST_F(LlvmLibcSetvbufTest, SetLBFBuffer) {
}
TEST(LlvmLibcSetbufTest, InvalidBufferMode) {
- constexpr char FILENAME[] = "testdata/setvbuf_invalid_bufmode.test";
+ constexpr char FILENAME[] =
+ APPEND_LIBC_TEST("testdata/setvbuf_invalid_bufmode.test");
::FILE *f = LIBC_NAMESPACE::fopen(FILENAME, "w");
ASSERT_FALSE(f == nullptr);
char buf[BUFSIZ];
diff --git a/libc/test/src/stdio/ungetc_test.cpp b/libc/test/src/stdio/ungetc_test.cpp
index b9d7530fc7177..917dbc2a77ab4 100644
--- a/libc/test/src/stdio/ungetc_test.cpp
+++ b/libc/test/src/stdio/ungetc_test.cpp
@@ -17,7 +17,7 @@
#include "test/UnitTest/Test.h"
TEST(LlvmLibcUngetcTest, UngetAndReadBack) {
- constexpr char FILENAME[] = "testdata/ungetc_test.test";
+ constexpr char FILENAME[] = APPEND_LIBC_TEST("testdata/ungetc_test.test");
::FILE *file = LIBC_NAMESPACE::fopen(FILENAME, "w");
ASSERT_FALSE(file == nullptr);
constexpr char CONTENT[] = "abcdef";
diff --git a/libc/test/src/stdio/unlocked_fileop_test.cpp b/libc/test/src/stdio/unlocked_fileop_test.cpp
index e99b382d12112..7af7eca46a1ec 100644
--- a/libc/test/src/stdio/unlocked_fileop_test.cpp
+++ b/libc/test/src/stdio/unlocked_fileop_test.cpp
@@ -21,7 +21,8 @@
using LlvmLibcFILETest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcFILETest, UnlockedReadAndWrite) {
- constexpr char fNAME[] = "testdata/unlocked_read_and_write.test";
+ constexpr char fNAME[] =
+ APPEND_LIBC_TEST("testdata/unlocked_read_and_write.test");
::FILE *f = LIBC_NAMESPACE::fopen(fNAME, "w");
ASSERT_FALSE(f == nullptr);
constexpr char CONTENT[] = "1234567890987654321";
diff --git a/libc/test/src/stdio/vfprintf_test.cpp b/libc/test/src/stdio/vfprintf_test.cpp
index 80d484500d5f2..f50565a0f68ca 100644
--- a/libc/test/src/stdio/vfprintf_test.cpp
+++ ...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
Is this intended to fix #144131? |
No, this is for a recent precommit flakiness from |
| #define STR(X) #X | ||
| #define EVAL_THEN_STR(X) STR(X) | ||
|
|
||
| #define APPEND_LIBC_TEST(X) X "." EVAL_THEN_STR(LIBC_TEST) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably be combined with libc_make_test_file_path in future
…t in stdio test suite. (llvm#149740)
No description provided.