diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2019-01-23 11:45:30 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2019-01-23 11:48:50 +0100 |
commit | 2da2b82dce0f6ebdc7f9d27a5815cdcba77abaab (patch) | |
tree | b1d6992895693624564cc05161f8347828311c98 /storage | |
parent | 8372a883c5a5fa100f88fc9b80824359b5bb70cd (diff) |
Reduce use of system() in storage unit tests.
Diffstat (limited to 'storage')
-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( |