Fix bug in proc_test.

TestNoDuplicates is racy as it tries to read the /proc file system
while the test is running. But it's possible that from the time a
directory entries are read and each entry processed something could
change and in some cases the entry being processed could have been
deleted. In such cases we should not fail the test but just
ignore the error and move on.

PiperOrigin-RevId: 267483094
This commit is contained in:
Bhasker Hariharan
2019-09-05 16:40:46 -07:00
committed by gVisor bot
parent fbdd3ff1da
commit eb074a61f2
+3 -1
View File
@@ -1882,7 +1882,9 @@ void CheckDuplicatesRecursively(std::string path) {
errno = 0;
DIR* dir = opendir(path.c_str());
if (dir == nullptr) {
ASSERT_THAT(errno, ::testing::AnyOf(EPERM, EACCES)) << path;
// Ignore any directories we can't read or missing directories as the
// directory could have been deleted/mutated from the time the parent
// directory contents were read.
return;
}
auto dir_closer = Cleanup([&dir]() { closedir(dir); });