summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-01-03 20:13:33 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-01-03 20:13:33 +0000
commitcd2a6a845bbdeb13e177e63e32a3d8e2cf859e79 (patch)
tree26ef2b363d0e5b25f22df4b62296a079352fa576
parentInternal functions should grab the lock as well (diff)
downloadnetfs-cd2a6a845bbdeb13e177e63e32a3d8e2cf859e79.tar.bz2
netfs-cd2a6a845bbdeb13e177e63e32a3d8e2cf859e79.tar.xz
netfs-cd2a6a845bbdeb13e177e63e32a3d8e2cf859e79.zip
Use std::atomic<>s for thread test, count failures, sleep inside loop
-rw-r--r--netfs/unittests/testEdgeCases.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/netfs/unittests/testEdgeCases.cpp b/netfs/unittests/testEdgeCases.cpp
index 01eb6b7..28e0f4c 100644
--- a/netfs/unittests/testEdgeCases.cpp
+++ b/netfs/unittests/testEdgeCases.cpp
@@ -89,10 +89,10 @@ BOOST_AUTO_TEST_CASE(manyThreads)
MockDaemonHost daemon(testEndpoint, {"--NetFSD.ConfigPath=" + (rootDir / "defaultDaemon.xml").string()});
FuseMockHost fuse(testEndpoint, {(rootDir / "defaultFuse.xml:testvol").string(), (rootDir / "test").string()});
- bool running = true;
+ std::atomic<bool> running {true};
std::vector<std::thread> ths;
ths.reserve(20);
- std::atomic_uint success = 0;
+ std::atomic<unsigned int> success {0}, failure {0};
for (int x = 0; x < 20; x++) {
ths.emplace_back([&] {
struct statvfs s {
@@ -101,8 +101,11 @@ BOOST_AUTO_TEST_CASE(manyThreads)
if (fuse.fuse->statfs("/", &s) == 0) {
success++;
}
+ else {
+ failure++;
+ }
+ usleep(10000);
}
- usleep(10000);
});
}
@@ -116,4 +119,5 @@ BOOST_AUTO_TEST_CASE(manyThreads)
}
BOOST_CHECK_GT(success, 800);
+ BOOST_CHECK_EQUAL(failure, 0);
}