diff options
author | Tor Brede Vekterli <vekterli@oath.com> | 2019-01-24 13:35:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-24 13:35:32 +0100 |
commit | 9845bfcc1be9960efa47b0593f92189cec7b8a51 (patch) | |
tree | 99719ac5d166eabcff3dcd3e4173d3309ff0583e | |
parent | d85f35c15d1beb3268da315fa2aad00fc7044229 (diff) | |
parent | 2da2b82dce0f6ebdc7f9d27a5815cdcba77abaab (diff) |
Merge pull request #8211 from vespa-engine/toregge/reduce-use-of-system-in-storage-unit-tests
Reduce use of system() in storage unit tests. [recheck merge]
-rw-r--r-- | storage/src/tests/persistence/persistencetestutils.cpp | 5 | ||||
-rw-r--r-- | storage/src/tests/visiting/visitortest.cpp | 10 |
2 files changed, 9 insertions, 6 deletions
diff --git a/storage/src/tests/persistence/persistencetestutils.cpp b/storage/src/tests/persistence/persistencetestutils.cpp index 368eae104e8..327deaf7e82 100644 --- a/storage/src/tests/persistence/persistencetestutils.cpp +++ b/storage/src/tests/persistence/persistencetestutils.cpp @@ -9,6 +9,7 @@ #include <vespa/persistence/spi/test.h> #include <vespa/document/update/assignvalueupdate.h> #include <vespa/document/update/documentupdate.h> +#include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/util/exceptions.h> @@ -25,9 +26,9 @@ namespace { vdstestlib::DirConfig initialize(uint32_t numDisks, const std::string & rootOfRoot) { vdstestlib::DirConfig config(getStandardConfig(true, rootOfRoot)); std::string rootFolder = getRootFolder(config); - system(vespalib::make_string("rm -rf %s", rootFolder.c_str()).c_str()); + vespalib::rmdir(rootFolder, true); for (uint32_t i = 0; i < numDisks; i++) { - system(vespalib::make_string("mkdir -p %s/disks/d%d", rootFolder.c_str(), i).c_str()); + vespalib::mkdir(vespalib::make_string("%s/disks/d%d", rootFolder.c_str(), i), true); } return config; } diff --git a/storage/src/tests/visiting/visitortest.cpp b/storage/src/tests/visiting/visitortest.cpp index 46b0f4d830d..51ce1c11e55 100644 --- a/storage/src/tests/visiting/visitortest.cpp +++ b/storage/src/tests/visiting/visitortest.cpp @@ -16,8 +16,10 @@ #include <vespa/documentapi/messagebus/messages/putdocumentmessage.h> #include <vespa/documentapi/messagebus/messages/removedocumentmessage.h> #include <vespa/documentapi/messagebus/messages/visitor.h> +#include <vespa/vespalib/io/fileutil.h> #include <vespa/config/common/exceptions.h> #include <thread> +#include <sys/stat.h> using namespace std::chrono_literals; using document::test::makeBucketSpace; @@ -185,10 +187,10 @@ VisitorTest::initializeTest(const TestParams& params) std::string rootFolder = getRootFolder(config); - system(vespalib::make_string("chmod 755 %s 2>/dev/null", rootFolder.c_str()).c_str()); - system(vespalib::make_string("rm -rf %s* 2>/dev/null", rootFolder.c_str()).c_str()); - assert(system(vespalib::make_string("mkdir -p %s/disks/d0", rootFolder.c_str()).c_str()) == 0); - assert(system(vespalib::make_string("mkdir -p %s/disks/d1", rootFolder.c_str()).c_str()) == 0); + ::chmod(rootFolder.c_str(), 0755); + vespalib::rmdir(rootFolder, true); + vespalib::mkdir(vespalib::make_string("%s/disks/d0", rootFolder.c_str()), true); + vespalib::mkdir(vespalib::make_string("%s/disks/d1", rootFolder.c_str()), true); try { _messageSessionFactory.reset( |