From 1143bd9318023eee83ab2481098092ecf6f26143 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 15 Feb 2017 05:32:13 +0300 Subject: Fix random tests failures. --- src/utils/virtfs_unittest.cc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/utils') 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); -- cgit v1.2.3-70-g09d2