[libcxx-commits] [libcxx] 3be7968 - [libcxx] [test] Ifdef out uses of create_fifo on windows
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 25 14:11:09 PST 2021
Author: Martin Storsjö
Date: 2021-02-26T00:10:47+02:00
New Revision: 3be7968c36c313b0de1baca0a87be2b98cb7f7c1
URL: https://github.com/llvm/llvm-project/commit/3be7968c36c313b0de1baca0a87be2b98cb7f7c1
DIFF: https://github.com/llvm/llvm-project/commit/3be7968c36c313b0de1baca0a87be2b98cb7f7c1.diff
LOG: [libcxx] [test] Ifdef out uses of create_fifo on windows
Restructure code in directory_entry.obs/file_type_obs.pass.cpp
and directory_entry.obs/hard_link_count.pass.cpp to reduce the
amount of ifdeffery needed.
In file_type_obs.pass.cpp, we can't inline the calls to
env.create_* into the lambda calls (e.g. "test_path(env.create_*())"),
because the lambda removes the referenced file, and the hardlink
must be created while the earlier test file exists.
In hard_link_count.pass.cpp, move restoration of the original
directory permissions to the end of the lambda, so that new
directory entries can be created after the lambda has run once.
Differential Revision: https://reviews.llvm.org/D89948
Added:
Modified:
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
index 34dea7243db5..1d0e6f1b8bab 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
@@ -83,7 +83,9 @@ TEST_CASE(not_regular_file) {
std::errc expected_err;
} TestCases[] = {
{env.create_dir("dir"), std::errc::is_a_directory},
+#ifndef _WIN32
{env.create_fifo("fifo"), std::errc::not_supported},
+#endif
{env.create_directory_symlink("dir", "sym"), std::errc::is_a_directory}};
for (auto const& TC : TestCases) {
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
index 59fc005c93e9..52c6afa39494 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
@@ -65,9 +65,8 @@ TEST_CASE(test_without_ec) {
scoped_test_env env;
path f = env.create_file("foo", 42);
path d = env.create_dir("dir");
- path fifo = env.create_fifo("fifo");
path hl = env.create_hardlink("foo", "hl");
- for (auto p : {hl, f, d, fifo}) {
+ auto test_path = [=](const path &p) {
directory_entry e(p);
file_status st = status(p);
file_status sym_st = symlink_status(p);
@@ -83,7 +82,14 @@ TEST_CASE(test_without_ec) {
TEST_CHECK(e.is_regular_file() == is_regular_file(st));
TEST_CHECK(e.is_socket() == is_socket(st));
TEST_CHECK(e.is_symlink() == is_symlink(sym_st));
- }
+ };
+ test_path(f);
+ test_path(d);
+ test_path(hl);
+#ifndef _WIN32
+ path fifo = env.create_fifo("fifo");
+ test_path(fifo);
+#endif
}
TEST_CASE(test_with_ec) {
@@ -95,9 +101,8 @@ TEST_CASE(test_with_ec) {
scoped_test_env env;
path f = env.create_file("foo", 42);
path d = env.create_dir("dir");
- path fifo = env.create_fifo("fifo");
path hl = env.create_hardlink("foo", "hl");
- for (auto p : {hl, f, d, fifo}) {
+ auto test_path = [=](const path &p) {
directory_entry e(p);
std::error_code status_ec = GetTestEC();
std::error_code sym_status_ec = GetTestEC(1);
@@ -141,7 +146,14 @@ TEST_CASE(test_with_ec) {
TEST_CHECK(e.is_symlink(ec) == is_symlink(sym_st));
TEST_CHECK(CheckEC(sym_status_ec));
- }
+ };
+ test_path(f);
+ test_path(d);
+ test_path(hl);
+#ifndef _WIN32
+ path fifo = env.create_fifo("fifo");
+ test_path(fifo);
+#endif
}
TEST_CASE(test_with_ec_dne) {
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
index f24d2a797c80..078dd35a00d4 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
@@ -84,13 +84,10 @@ TEST_CASE(not_regular_file) {
scoped_test_env env;
const path dir = env.create_dir("dir");
const path dir2 = env.create_dir("dir/dir2");
- const path fifo = env.create_fifo("dir/fifo");
- const path sym_to_fifo = env.create_symlink("dir/fifo", "dir/sym");
const perms old_perms = status(dir).permissions();
- for (auto p : {dir2, fifo, sym_to_fifo}) {
- permissions(dir, old_perms);
+ auto test_path = [=](const path &p) {
std::error_code dummy_ec = GetTestEC();
directory_entry ent(p, dummy_ec);
TEST_CHECK(!dummy_ec);
@@ -103,7 +100,15 @@ TEST_CASE(not_regular_file) {
TEST_CHECK(ent.hard_link_count(ec) == expect);
TEST_CHECK(!ec);
TEST_CHECK_NO_THROW(ent.hard_link_count());
- }
+ permissions(dir, old_perms);
+ };
+ test_path(dir2);
+#ifndef _WIN32
+ const path fifo = env.create_fifo("dir/fifo");
+ const path sym_to_fifo = env.create_symlink("dir/fifo", "dir/sym");
+ test_path(fifo);
+ test_path(sym_to_fifo);
+#endif
}
TEST_CASE(error_reporting) {
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
index 798c3187eb12..3f9574de0bb0 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
@@ -67,8 +67,10 @@ TEST_CASE(test_error_reporting)
scoped_test_env env;
const path file = env.create_file("file1", 42);
const path dir = env.create_dir("dir");
+#ifndef _WIN32
const path fifo = env.create_fifo("fifo");
TEST_REQUIRE(is_other(fifo));
+#endif
const auto test_ec = GetTestEC();
@@ -96,6 +98,7 @@ TEST_CASE(test_error_reporting)
TEST_REQUIRE(ec != test_ec);
TEST_CHECK(checkThrow(dir, file, ec));
}
+#ifndef _WIN32
{ // is_other(from)
std::error_code ec = test_ec;
fs::copy(fifo, dir, ec);
@@ -110,6 +113,7 @@ TEST_CASE(test_error_reporting)
TEST_REQUIRE(ec != test_ec);
TEST_CHECK(checkThrow(file, fifo, ec));
}
+#endif
}
TEST_CASE(from_is_symlink)
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp
index 368fd7fe01e6..dfccfb28ea11 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp
@@ -73,6 +73,7 @@ TEST_CASE(test_error_reporting) {
}
}
+#ifndef _WIN32
TEST_CASE(non_regular_file_test) {
scoped_test_env env;
const path fifo = env.create_fifo("fifo");
@@ -94,6 +95,7 @@ TEST_CASE(non_regular_file_test) {
}
}
+#endif
TEST_CASE(test_attributes_get_copied) {
scoped_test_env env;
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp
index ddd3a2cb7b0a..5fe888609a92 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp
@@ -97,6 +97,7 @@ TEST_CASE(equivalent_hardlink_succeeds) {
TEST_CHECK(equivalent(hl1, hl2));
}
+#ifndef _WIN32
TEST_CASE(equivalent_is_other_succeeds) {
scoped_test_env env;
path const file = env.create_file("file", 42);
@@ -109,5 +110,6 @@ TEST_CASE(equivalent_is_other_succeeds) {
TEST_CHECK(!equivalent(fifo1, fifo2));
TEST_CHECK(equivalent(fifo1, fifo1));
}
+#endif
TEST_SUITE_END()
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
index b58e3db4dd21..8cbdf13b7b73 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
@@ -95,6 +95,7 @@ TEST_CASE(test_directory_access_denied)
}
+#ifndef _WIN32
TEST_CASE(test_fifo_fails)
{
scoped_test_env env;
@@ -107,5 +108,6 @@ TEST_CASE(test_fifo_fails)
TEST_CHECK_THROW(filesystem_error, is_empty(fifo));
}
+#endif
TEST_SUITE_END()
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp
index 8a4e352738e8..6abd218e9a20 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp
@@ -114,7 +114,9 @@ TEST_CASE(status_file_types_test)
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(_WIN32) // No support for domain sockets
{env.create_socket("socket"), file_type::socket},
#endif
+#ifndef _WIN32
{env.create_fifo("fifo"), file_type::fifo}
+#endif
};
for (const auto& TC : cases) {
// test non-throwing case
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp
index 1e71bf7a01d5..d93e46f750f6 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp
@@ -123,7 +123,9 @@ TEST_CASE(symlink_status_file_types_test)
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(_WIN32) // No support for domain sockets
{env.create_socket("socket"), file_type::socket},
#endif
+#ifndef _WIN32
{env.create_fifo("fifo"), file_type::fifo}
+#endif
};
for (const auto& TC : cases) {
// test non-throwing case
More information about the libcxx-commits
mailing list