On windows, one can't use perms::none on a directory to trigger failures to read the directory entries.
This fixes 23 tests on windows.
Paths
| Differential D97538
[libcxx] [test] Ifdef out tests that rely on perms::none on directories for triggering errors ClosedPublic Authored by mstorsjo on Feb 26 2021, 3:25 AM.
Details
Summary On windows, one can't use perms::none on a directory to trigger failures to read the directory entries. This fixes 23 tests on windows.
Diff Detail Event TimelineComment Actions So actually, I think those tests are the same that fail when we run under sudo. I believe it would be useful to find an alternative way to trigger those failures. This would allow us to both run the tests on Windows and also would remove this weird quirk about running under sudo (which is useful e.g. when running in a Docker image). Can you think of another way to do this? Could we change the owner of the directory? This revision now requires changes to proceed.Mar 2 2021, 9:27 AM Comment Actions Tagging @curdeius and @amccarth for input and ideas
If a process running as root can iterate over a directory even after chmod 000, I don't think changing the owner would help. Dunno about windows - on the API level we operate so far, permissions only consist of a boolean readonly flag, not much more. On some other level, windows filesystems have full ACLs for controlling access though. Comment Actions @curdeius Any ideas on this one? There's lots of tests that test the error cases when unable to read a directory, by giving those directories perms::none, which doesn't stop them from being read on windows. (On windows, the perms we have available essentially is only a binary readonly-flag.) And if I understand things right, these tests also fail if running the tests as root or in sudo, as one apparently ends up able to read the directories regardless, in those cases. Comment Actions
I can't think of a way to trigger a permission denied error with anything less than an ACL. And it might be hard for the owner that just created the directory to then lock itself out. And if it succeeded, then the test might have trouble cleaning up afterwards. I having a hard time even thinking of a Windows directory that would block permission to list contents. The best I can come up with is C:\Users\SomebodyElse, but that's not guaranteed to exist on any other machine, and you couldn't temporarily change the permissions to set up the rest of the scenario being tested. I tried thinking of something other than an access problem that would temporarily interfere with iterating directory contents, but I'm not coming up with any good options. Comment Actions Unfortunately I haven't found anything really satisfying that will provoke this or similar behaviour on Windows without, as Adrian noted, accessing other user's folder or changing ACLs. Anyway, speaking of C:\Users\SomebodyElse and stuff. That's not really nice to do some setup using a different user. Comment Actions
Thanks! That does indeed seem to work. Ideally I'd like to first check that it exists before proceeding with a test that assumes its existence and behaviour, but exists("C:\System Volume Information") fails as we don't really have access to access the directory much at all. We can iterate over C:\ and see that it's listed as one of the entries there though. Converting all these instances to use that does feel like overkill, and most of these tests are kinda redundant with other tests, but there's at least a few instances where it can make sense to use this. And this did uncover a bug regarding the handling of the skip_permission_denied flag. I'll post a separate patch for that and a few tests to use that dir, and then we can update this one to ifdef out other cases that are less necessary. Comment Actions Updated after splitting out changes that use GetWindowsInaccessibleDir(). These remaining tests can't use GetWindowsInaccessibleDir() sensibly, e.g. for tests that rely on toggling accessibility back and forth during the test, or where the semantics of the dir provided by GetWindowsInaccessibleDir() doesn't allow for running the ifdeffed tests meaningfully. Comment Actions @ldionne - TL;DR: Nobody has so far come up with a reliable crossplatform way of making those tests work under sudo. For windows, there's a special directory with suitable characteristics that work for some tests. (If it turns out the special dir doesn't exist or doesn't behave as we need it to, we use TEST_UNSUPPORTED() to bail out of that particular test - maybe such an approach could be used to waive failures when run under sudo, too? That's a separate effort anyway.) This patch now ifdefs out the remaining few cases where the special dir couldn't be used (e.g. where the test requires changing permissions back and forth during the test). Comment Actions This LGTM, but can we perhaps define a macro like TEST_WIN_NO_FAILURES_WITH_PERMISSIONS defined when _WIN32 is defined (pick a better name) and use that instead? Just to avoid sprinkling naked _WIN32's in the test suite if we can. No need for review either way, but please consider my suggestion. This revision is now accepted and ready to land.Apr 19 2021, 11:49 AM Closed by commit rGf9ddb81d79b2: [libcxx] [test] Ifdef out tests that rely on perms::none on directories for… (authored by mstorsjo). · Explain WhyApr 19 2021, 1:03 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 326643 libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/refresh.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp
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/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory/create_directory_with_attributes.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.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.is_fifo/is_fifo.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove/remove.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove_all/remove_all.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
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
|