summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-02-15 05:32:13 +0300
committerAndrei Karas <akaras@inbox.ru>2017-02-15 05:32:13 +0300
commit1143bd9318023eee83ab2481098092ecf6f26143 (patch)
treec1691d3006266b2224c53d27dca0d375e77be049 /src/utils
parente37ca5c5f55a4351889fb0c95b8604a02ae8760e (diff)
downloadplus-1143bd9318023eee83ab2481098092ecf6f26143.tar.gz
plus-1143bd9318023eee83ab2481098092ecf6f26143.tar.bz2
plus-1143bd9318023eee83ab2481098092ecf6f26143.tar.xz
plus-1143bd9318023eee83ab2481098092ecf6f26143.zip
Fix random tests failures.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/virtfs_unittest.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/utils/virtfs_unittest.cc b/src/utils/virtfs_unittest.cc
index e00aaac51..7265c4a8e 100644
--- a/src/utils/virtfs_unittest.cc
+++ b/src/utils/virtfs_unittest.cc
@@ -20,8 +20,6 @@
#include "catch.hpp"
-#include "configuration.h"
-
#include "utils/checkutils.h"
#include "utils/virtfs.h"
#include "utils/virtfstools.h"
@@ -79,24 +77,35 @@ TEST_CASE("VirtFs exists")
VirtFs::removeDirFromSearchPath("../data");
}
+static void removeTemp(StringVect &restrict list)
+{
+ FOR_EACH (StringVectIter, it, list)
+ {
+ if (*it == "serverlistplus.xml.part")
+ {
+ list.erase(it);
+ return;
+ }
+ }
+}
+
TEST_CASE("VirtFs enumerateFiles")
{
VirtFs::addDirToSearchPath("data", Append_false);
VirtFs::addDirToSearchPath("../data", Append_false);
- ::remove("data/test/serverlistplus.xml.part");
- ::remove("../data/test/serverlistplus.xml.part");
-// VirtFs::remove("test/serverlistplus.xml.part");
VirtList *list = nullptr;
VirtFs::permitLinks(false);
list = VirtFs::enumerateFiles("test");
+ removeTemp(list->names);
const size_t sz = list->names.size();
REQUIRE(sz == 22);
VirtFs::freeList(list);
VirtFs::permitLinks(true);
list = VirtFs::enumerateFiles("test");
+ removeTemp(list->names);
REQUIRE(list->names.size() > sz);
REQUIRE(list->names.size() - sz == 1);
REQUIRE(list->names.size() == 23);
@@ -104,6 +113,7 @@ TEST_CASE("VirtFs enumerateFiles")
VirtFs::permitLinks(false);
list = VirtFs::enumerateFiles("test");
+ removeTemp(list->names);
REQUIRE(list->names.size() == sz);
REQUIRE(list->names.size() == 22);
VirtFs::freeList(list);
@@ -307,19 +317,17 @@ TEST_CASE("VirtFs permitLinks")
VirtFs::addDirToSearchPath("data", Append_false);
VirtFs::addDirToSearchPath("../data", Append_false);
- ::remove("data/test/serverlistplus.xml.part");
- ::remove("../data/test/serverlistplus.xml.part");
-// VirtFs::remove("test/serverlistplus.xml.part");
-
StringVect list;
VirtFs::permitLinks(false);
VirtFs::getFiles("test", list);
+ removeTemp(list);
const size_t sz = list.size();
REQUIRE(sz == 21);
list.clear();
VirtFs::permitLinks(true);
VirtFs::getFiles("test", list);
+ removeTemp(list);
REQUIRE(list.size() > sz);
REQUIRE(list.size() - sz == 1);
REQUIRE(list.size() == 22);
@@ -327,6 +335,7 @@ TEST_CASE("VirtFs permitLinks")
list.clear();
VirtFs::permitLinks(false);
VirtFs::getFiles("test", list);
+ removeTemp(list);
REQUIRE(list.size() == sz);
REQUIRE(list.size() == 21);