diff options
author | Arnstein Ressem <aressem@gmail.com> | 2016-11-02 23:26:40 +0100 |
---|---|---|
committer | Arnstein Ressem <aressem@gmail.com> | 2016-11-02 23:26:40 +0100 |
commit | 99480b4d72abf3688060d7643816680a30963f74 (patch) | |
tree | 966d8494bca9292e6be2877d91ed838953856f0f | |
parent | 3d18773cf5357250cb2d35d6e8c13477db6e20a3 (diff) |
Removed TestApp::GetSourceDirectory
68 files changed, 169 insertions, 215 deletions
diff --git a/config/src/tests/configgen/configgen.cpp b/config/src/tests/configgen/configgen.cpp index a1e891e19fa..bd8aea0a89a 100644 --- a/config/src/tests/configgen/configgen.cpp +++ b/config/src/tests/configgen/configgen.cpp @@ -3,7 +3,6 @@ #include <vespa/log/log.h> LOG_SETUP("configgen"); #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/vespalib/testkit/testapp.h> #include <vespa/config/config.h> #include "config-motd.h" @@ -11,7 +10,7 @@ using namespace config; TEST("require that config type can be compiled") { std::unique_ptr<MotdConfig> cfg = ConfigGetter<MotdConfig>::getConfig("motd", - FileSpec(vespalib::TestApp::GetSourceDirectory() + "motd.cfg")); + FileSpec(TEST_PATH("motd.cfg"))); } TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/config/src/tests/file_subscription/file_subscription.cpp b/config/src/tests/file_subscription/file_subscription.cpp index 19aa43297a6..c770d8da349 100644 --- a/config/src/tests/file_subscription/file_subscription.cpp +++ b/config/src/tests/file_subscription/file_subscription.cpp @@ -5,7 +5,6 @@ #include <vespa/config/common/configholder.h> #include <vespa/config/file/filesource.h> #include <vespa/vespalib/util/sync.h> -#include <vespa/vespalib/testkit/testapp.h> #include <fstream> #include <config-my.h> #include <config-foo.h> @@ -131,7 +130,7 @@ TEST("requireThatMultipleSubscribersCanSubscribeToSameFile") { } TEST("requireThatCanSubscribeToDirectory") { - DirSpec spec(vespalib::TestApp::GetSourceDirectory() + "cfgdir"); + DirSpec spec(TEST_PATH("cfgdir")); ConfigSubscriber s(spec); ConfigHandle<FooConfig>::UP fooHandle = s.subscribe<FooConfig>(""); ConfigHandle<BarConfig>::UP barHandle = s.subscribe<BarConfig>(""); @@ -147,7 +146,7 @@ TEST("requireThatCanSubscribeToDirectory") { } TEST("requireThatCanSubscribeToDirectoryWithEmptyCfgFile") { - DirSpec spec(vespalib::TestApp::GetSourceDirectory() + "cfgemptyfile"); + DirSpec spec(TEST_PATH("cfgemptyfile")); ConfigSubscriber s(spec); ConfigHandle<FoodefaultConfig>::UP fooHandle = s.subscribe<FoodefaultConfig>(""); ConfigHandle<BarConfig>::UP barHandle = s.subscribe<BarConfig>(""); @@ -163,7 +162,7 @@ TEST("requireThatCanSubscribeToDirectoryWithEmptyCfgFile") { } TEST("requireThatCanSubscribeToDirectoryWithNonExistingCfgFile") { - DirSpec spec(vespalib::TestApp::GetSourceDirectory() + "cfgnonexistingfile"); + DirSpec spec(TEST_PATH("cfgnonexistingfile")); ConfigSubscriber s(spec); ConfigHandle<FoodefaultConfig>::UP fooHandle = s.subscribe<FoodefaultConfig>(""); ConfigHandle<BarConfig>::UP barHandle = s.subscribe<BarConfig>(""); @@ -179,7 +178,7 @@ TEST("requireThatCanSubscribeToDirectoryWithNonExistingCfgFile") { } TEST_F("requireThatDirSpecDoesNotMixNames", - DirSpec(vespalib::TestApp::GetSourceDirectory() + "cfgdir2")) { + DirSpec(TEST_PATH("cfgdir2"))) { ConfigSubscriber s(f); ConfigHandle<BarConfig>::UP barHandle = s.subscribe<BarConfig>(""); ConfigHandle<FoobarConfig>::UP foobarHandle = s.subscribe<FoobarConfig>(""); @@ -193,7 +192,7 @@ TEST_F("requireThatDirSpecDoesNotMixNames", } TEST_F("require that can subscribe multiple config ids of same config", - DirSpec(vespalib::TestApp::GetSourceDirectory() + "cfgdir3")) { + DirSpec(TEST_PATH("cfgdir3"))) { ConfigSubscriber s(f1); ConfigHandle<BarConfig>::UP fooHandle = s.subscribe<BarConfig>("foo"); ConfigHandle<BarConfig>::UP barHandle = s.subscribe<BarConfig>("bar"); diff --git a/config/src/tests/functiontest/functiontest.cpp b/config/src/tests/functiontest/functiontest.cpp index 444ba776f27..24d50b44ca4 100644 --- a/config/src/tests/functiontest/functiontest.cpp +++ b/config/src/tests/functiontest/functiontest.cpp @@ -6,8 +6,8 @@ #include <fstream> #include <vespa/log/log.h> -#include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/data/slime/slime.h> +#include <vespa/vespalib/testkit/test_kit.h> LOG_SETUP("functiontest_test"); @@ -95,7 +95,7 @@ struct LazyTestFixture std::unique_ptr<FunctionTestConfig> _config; LazyTestFixture(const std::string & dirName) - : _spec(vespalib::TestApp::GetSourceDirectory() + dirName), + : _spec(TEST_PATH(dirName)), _subscriber(_spec), _handle(_subscriber.subscribe<FunctionTestConfig>("")) { @@ -130,7 +130,7 @@ struct ErrorFixture }; void attemptLacking(const std::string& param, bool isArray) { - std::ifstream in(vespalib::TestApp::GetSourceDirectory() + "defaultvalues/function-test.cfg", std::ios_base::in); + std::ifstream in(TEST_PATH("defaultvalues/function-test.cfg"), std::ios_base::in); std::ostringstream config; std::string s; while (std::getline(in, s)) { @@ -172,7 +172,7 @@ TEST_F("testVariableAccess", TestFixture("variableaccess")) { TEST("test variable access from slime") { vespalib::Slime slime; - std::string json(readFile(vespalib::TestApp::GetSourceDirectory() + "slime-payload.json")); + std::string json(readFile(TEST_PATH("slime-payload.json"))); vespalib::slime::JsonFormat::decode(json, slime); FunctionTestConfig config(config::ConfigPayload(slime.get())); checkVariableAccess(config); diff --git a/config/src/tests/getconfig/getconfig.cpp b/config/src/tests/getconfig/getconfig.cpp index 27f4fcf7505..77e2f57dbc8 100644 --- a/config/src/tests/getconfig/getconfig.cpp +++ b/config/src/tests/getconfig/getconfig.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/fastos.h> #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/vespalib/testkit/testapp.h> #include <vespa/config/config.h> #include <vespa/config/raw/rawsource.h> #include "config-my.h" @@ -35,7 +34,7 @@ TEST("requireThatGetConfigReturnsCorrectConfig") TEST("requireThatGetConfigReturnsCorrectConfig") { - FileSpec spec(vespalib::TestApp::GetSourceDirectory() + "my.cfg"); + FileSpec spec(TEST_PATH("my.cfg")); std::unique_ptr<MyConfig> cfg = ConfigGetter<MyConfig>::getConfig("", spec); ASSERT_TRUE(cfg.get() != NULL); ASSERT_EQUAL("my", cfg->defName()); diff --git a/config/src/tests/legacysubscriber/legacysubscriber.cpp b/config/src/tests/legacysubscriber/legacysubscriber.cpp index 031f3f76f00..feae0a1d1a4 100644 --- a/config/src/tests/legacysubscriber/legacysubscriber.cpp +++ b/config/src/tests/legacysubscriber/legacysubscriber.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/fastos.h> #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/vespalib/testkit/testapp.h> #include <vespa/config/helper/legacysubscriber.h> #include <fstream> #include <config-my.h> @@ -28,8 +27,7 @@ struct ConfigIdGenerator { static std::string id(const std::string &type, const std::string &name) { - return std::string(type + ":" + - vespalib::TestApp::GetSourceDirectory() + name); + return std::string(type + ":" + TEST_PATH(name)); } }; diff --git a/config/src/tests/print/print.cpp b/config/src/tests/print/print.cpp index f0f0570f2a9..761a3b32f73 100644 --- a/config/src/tests/print/print.cpp +++ b/config/src/tests/print/print.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/fastos.h> #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/vespalib/testkit/testapp.h> #include <vespa/config/config.h> #include <vespa/config/print.h> #include <vespa/config/print/fileconfigreader.h> @@ -84,7 +83,7 @@ TEST_F("requireThatCanLoadWrittenWithConfigFormat", RawFixture<MyConfig>) { TEST("requireThatAllFieldsArePrintedCorrectly") { std::unique_ptr<MotdConfig> cfg = ConfigGetter<MotdConfig>::getConfig( - "motd", FileSpec(vespalib::TestApp::GetSourceDirectory() + "motd.cfg")); + "motd", FileSpec(TEST_PATH("motd.cfg"))); FileConfigWriter writer("motd2.cfg"); ASSERT_TRUE(writer.write(*cfg, FileConfigFormatter())); std::unique_ptr<MotdConfig> cfg2 = ConfigGetter<MotdConfig>::getConfig( diff --git a/configutil/src/tests/model_inspect/model_inspect_test.cpp b/configutil/src/tests/model_inspect/model_inspect_test.cpp index a2d07fcaedf..3273e07653e 100644 --- a/configutil/src/tests/model_inspect/model_inspect_test.cpp +++ b/configutil/src/tests/model_inspect/model_inspect_test.cpp @@ -1,6 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/fastos.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <lib/modelinspect.h> #include <iostream> @@ -33,8 +33,7 @@ public: static config::ConfigUri configUri(const std::string &type, const std::string &name) { - return config::ConfigUri(type + ":" + - vespalib::TestApp::GetSourceDirectory() + "/" + name); + return config::ConfigUri(type + ":" + TEST_PATH(name)); } }; diff --git a/document/src/tests/documentidtest.cpp b/document/src/tests/documentidtest.cpp index b3da80ba958..2e3300b692c 100644 --- a/document/src/tests/documentidtest.cpp +++ b/document/src/tests/documentidtest.cpp @@ -5,7 +5,7 @@ #include <vespa/document/serialization/vespadocumentdeserializer.h> #include <vespa/document/serialization/vespadocumentserializer.h> #include <vespa/vespalib/objects/nbostream.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <sstream> #include <string> #include <vespa/document/bucket/bucketidfactory.h> @@ -82,7 +82,7 @@ void DocumentIdTest::generateJavaComplianceFile() writeGlobalIdBucketId(ost, "id:np:type:g=agroup:another"); writeGlobalIdBucketId(ost, "id:ns:type:g=another:specific"); FastOS_File file; - CPPUNIT_ASSERT(file.OpenWriteOnlyTruncate((vespalib::TestApp::GetSourceDirectory() + "cpp-globalidbucketids.txt").c_str())); + CPPUNIT_ASSERT(file.OpenWriteOnlyTruncate(TEST_PATH("cpp-globalidbucketids.txt").c_str())); std::string content(ost.str()); CPPUNIT_ASSERT(file.CheckedWrite(content.c_str(), content.size())); CPPUNIT_ASSERT(file.Close()); diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp index 352c22bd3fd..c42697843db 100644 --- a/document/src/tests/documenttestcase.cpp +++ b/document/src/tests/documenttestcase.cpp @@ -15,8 +15,8 @@ #include <vespa/document/serialization/vespadocumentdeserializer.h> #include <vespa/document/serialization/vespadocumentserializer.h> #include <vespa/vespalib/objects/nbostream.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <fstream> -#include <vespa/vespalib/testkit/testapp.h> using vespalib::nbostream; @@ -590,10 +590,10 @@ void verifyJavaDocument(Document& doc) void DocumentTest::testReadSerializedFile() { // Reads a file serialized from java - const std::string file_name = vespalib::TestApp::GetSourceDirectory() + "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string file_name = TEST_PATH("data/crossplatform-java-cpp-doctypes.cfg"); DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); - int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serializejava.dat").c_str(), O_RDONLY); + int fd = open(TEST_PATH("data/serializejava.dat").c_str(), O_RDONLY); size_t len = lseek(fd,0,SEEK_END); ByteBuffer buf(len); @@ -624,11 +624,10 @@ void DocumentTest::testReadSerializedFile() void DocumentTest::testReadSerializedFileCompressed() { // Reads a file serialized from java - const std::string file_name = vespalib::TestApp::GetSourceDirectory() + - "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string file_name = TEST_PATH("data/crossplatform-java-cpp-doctypes.cfg"); DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); - int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serializejava-compressed.dat").c_str(), O_RDONLY); + int fd = open(TEST_PATH("data/serializejava-compressed.dat").c_str(), O_RDONLY); int len = lseek(fd,0,SEEK_END); ByteBuffer buf(len); @@ -745,7 +744,7 @@ void DocumentTest::testReadSerializedAllVersions() //doc.setCompression(CompressionConfig(CompressionConfig::NONE, 0, 0)); std::unique_ptr<ByteBuffer> buf = doc.serialize(); CPPUNIT_ASSERT_EQUAL(buf->getLength(), buf->getPos()); - int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/document-cpp-currentversion-uncompressed.dat").c_str(), + int fd = open(TEST_PATH("data/document-cpp-currentversion-uncompressed.dat").c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644); CPPUNIT_ASSERT(fd > 0); size_t len = write(fd, buf->getBuffer(), buf->getPos()); @@ -758,7 +757,7 @@ void DocumentTest::testReadSerializedAllVersions() const_cast<StructDataType &>(doc.getType().getFieldsType()).setCompressionConfig(newCfg); std::unique_ptr<ByteBuffer> buf = doc.serialize(); CPPUNIT_ASSERT(buf->getPos() <= buf->getLength()); - int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/document-cpp-currentversion-lz4-9.dat").c_str(), + int fd = open(TEST_PATH("data/document-cpp-currentversion-lz4-9.dat").c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644); CPPUNIT_ASSERT(fd > 0); size_t len = write(fd, buf->getBuffer(), buf->getPos()); @@ -768,12 +767,12 @@ void DocumentTest::testReadSerializedAllVersions() } } - std::string jpath = vespalib::TestApp::GetSourceDirectory() + "../test/serializeddocuments/"; + std::string jpath = TEST_PATH("../test/serializeddocuments/"); std::vector<TestDoc> tests; - tests.push_back(TestDoc(vespalib::TestApp::GetSourceDirectory() + "data/document-cpp-v8-uncompressed.dat", 8)); - tests.push_back(TestDoc(vespalib::TestApp::GetSourceDirectory() + "data/document-cpp-v7-uncompressed.dat", 7)); - tests.push_back(TestDoc(vespalib::TestApp::GetSourceDirectory() + "data/serializev6.dat", 6)); + tests.push_back(TestDoc(TEST_PATH("data/document-cpp-v8-uncompressed.dat"), 8)); + tests.push_back(TestDoc(TEST_PATH("data/document-cpp-v7-uncompressed.dat"), 7)); + tests.push_back(TestDoc(TEST_PATH("data/serializev6.dat"), 6)); tests.push_back(TestDoc(jpath + "document-java-v8-uncompressed.dat", 8)); for (uint32_t i=0; i<tests.size(); ++i) { int version = tests[i]._createdVersion; @@ -869,7 +868,7 @@ size_t getSerializedSizeBody(const Document &doc) { void DocumentTest::testGenerateSerializedFile() { - const std::string file_name = vespalib::TestApp::GetSourceDirectory() + "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string file_name = TEST_PATH("data/crossplatform-java-cpp-doctypes.cfg"); DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); Document doc(*repo.getDocumentType("serializetest"), DocumentId(DocIdString("serializetest", @@ -908,7 +907,7 @@ void DocumentTest::testGenerateSerializedFile() std::unique_ptr<ByteBuffer> buf = doc.serialize(); - const std::string serializedDir = vespalib::TestApp::GetSourceDirectory() + "../test/document/"; + const std::string serializedDir = TEST_PATH("../test/document/"); int fd = open((serializedDir + "/serializecpp.dat").c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0644); if (write(fd, buf->getBuffer(), buf->getPos()) != (ssize_t)buf->getPos()) { @@ -927,7 +926,7 @@ void DocumentTest::testGenerateSerializedFile() ByteBuffer bBuf(getSerializedSizeBody(doc)); doc.serializeBody(bBuf); - fd = open((vespalib::TestApp::GetSourceDirectory() + "/serializecppsplit_body.dat").c_str(), + fd = open(TEST_PATH("/serializecppsplit_body.dat").c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0644); if (write(fd, bBuf.getBuffer(), bBuf.getPos()) != (ssize_t)bBuf.getPos()) { throw vespalib::Exception("write failed"); @@ -942,7 +941,7 @@ void DocumentTest::testGenerateSerializedFile() doc.serialize(lz4buf); lz4buf.flip(); - fd = open((vespalib::TestApp::GetSourceDirectory() + "/serializecpp-lz4-level9.dat").c_str(), + fd = open(TEST_PATH("/serializecpp-lz4-level9.dat").c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0644); if (write(fd, lz4buf.getBufferAtPos(), lz4buf.getRemaining()) != (ssize_t)lz4buf.getRemaining()) { throw vespalib::Exception("write failed"); @@ -1309,7 +1308,7 @@ DocumentTest::testUnknownEntries() // Copy paste of above test to read an old version document and // deserialize it with some fields lacking to see that it doesn't // report failure. (Had a bug on this earlier) - int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serializev6.dat").c_str(), O_RDONLY); + int fd = open(TEST_PATH("data/serializev6.dat").c_str(), O_RDONLY); int len = lseek(fd,0,SEEK_END); ByteBuffer buf(len); lseek(fd,0,SEEK_SET); @@ -1358,7 +1357,7 @@ void DocumentTest::testAnnotationDeserialization() .annotationType(1730712959, "apple", 0); DocumentTypeRepo repo(builder.config()); - int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serializejavawithannotations.dat").c_str(), O_RDONLY); + int fd = open(TEST_PATH("data/serializejavawithannotations.dat").c_str(), O_RDONLY); int len = lseek(fd,0,SEEK_END); ByteBuffer buf(len); lseek(fd,0,SEEK_SET); diff --git a/document/src/tests/documenttypetestcase.cpp b/document/src/tests/documenttypetestcase.cpp index da6d61b507d..978592931ec 100644 --- a/document/src/tests/documenttypetestcase.cpp +++ b/document/src/tests/documenttypetestcase.cpp @@ -7,7 +7,7 @@ #include <vespa/document/repo/configbuilder.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/vdstestlib/cppunit/macros.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <sstream> #include <string> @@ -94,8 +94,7 @@ void DocumentTypeTest::testInheritanceConfig() { DocumentTypeRepo - repo(readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() + - "data/inheritancetest.cfg")); + repo(readDocumenttypesConfig(TEST_PATH("data/inheritancetest.cfg"))); { const DocumentType* type(repo.getDocumentType("music")); CPPUNIT_ASSERT(type != NULL); @@ -111,8 +110,7 @@ void DocumentTypeTest::testHeaderContent() { DocumentTypeRepo - repo(readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() + - "data/doctypesconfigtest.cfg")); + repo(readDocumenttypesConfig(TEST_PATH("data/doctypesconfigtest.cfg"))); const DocumentType* type(repo.getDocumentType("derived")); diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp index 80e45f3a977..1af20de3f9b 100644 --- a/document/src/tests/documentupdatetestcase.cpp +++ b/document/src/tests/documentupdatetestcase.cpp @@ -572,10 +572,10 @@ DocumentUpdateTest::testIncrementWithZeroResultWeightIsRemoved() void DocumentUpdateTest::testReadSerializedFile() { // Reads a file serialized from java - const std::string file_name = vespalib::TestApp::GetSourceDirectory() + "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string file_name = TEST_PATH("data/crossplatform-java-cpp-doctypes.cfg"); DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); - int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serializeupdatejava.dat").c_str(), O_RDONLY); + int fd = open(TEST_PATH("data/serializeupdatejava.dat").c_str(), O_RDONLY); int len = lseek(fd,0,SEEK_END); ByteBuffer buf(len); @@ -649,7 +649,7 @@ void DocumentUpdateTest::testReadSerializedFile() void DocumentUpdateTest::testGenerateSerializedFile() { // Tests nothing, only generates a file for java test - const std::string file_name = vespalib::TestApp::GetSourceDirectory() + "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string file_name = TEST_PATH("data/crossplatform-java-cpp-doctypes.cfg"); DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); const DocumentType *type(repo.getDocumentType("serializetest")); @@ -671,7 +671,7 @@ void DocumentUpdateTest::testGenerateSerializedFile() ArithmeticValueUpdate(ArithmeticValueUpdate::Mul, 2)))); ByteBuffer::UP buf(serialize42(upd)); - int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serializeupdatecpp.dat").c_str(), + int fd = open(TEST_PATH("data/serializeupdatecpp.dat").c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0644); if (write(fd, buf->getBuffer(), buf->getPos()) != (ssize_t)buf->getPos()) { throw vespalib::Exception("read failed"); diff --git a/document/src/tests/fieldpathupdatetestcase.cpp b/document/src/tests/fieldpathupdatetestcase.cpp index ca1c8338f90..fc113c79de8 100644 --- a/document/src/tests/fieldpathupdatetestcase.cpp +++ b/document/src/tests/fieldpathupdatetestcase.cpp @@ -1271,10 +1271,10 @@ void FieldPathUpdateTestCase::testReadSerializedFile() { // Reads a file serialized from java - const std::string cfg_file_name = vespalib::TestApp::GetSourceDirectory() + "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string cfg_file_name = TEST_PATH("data/crossplatform-java-cpp-doctypes.cfg"); DocumentTypeRepo repo(readDocumenttypesConfig(cfg_file_name)); - int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serialize-fieldpathupdate-java.dat").c_str(), O_RDONLY); + int fd = open(TEST_PATH("data/serialize-fieldpathupdate-java.dat").c_str(), O_RDONLY); int len = lseek(fd,0,SEEK_END); ByteBuffer buf(len); @@ -1295,7 +1295,7 @@ FieldPathUpdateTestCase::testReadSerializedFile() void FieldPathUpdateTestCase::testGenerateSerializedFile() { - const std::string cfg_file_name = vespalib::TestApp::GetSourceDirectory()+ "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string cfg_file_name = TEST_PATH("data/crossplatform-java-cpp-doctypes.cfg"); DocumentTypeRepo repo(readDocumenttypesConfig(cfg_file_name)); // Tests nothing, only generates a file for java test DocumentUpdate::UP upd( @@ -1303,7 +1303,7 @@ FieldPathUpdateTestCase::testGenerateSerializedFile() ByteBuffer::UP buf(serializeHEAD(*upd)); - int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serialize-fieldpathupdate-cpp.dat").c_str(), + int fd = open(TEST_PATH("data/serialize-fieldpathupdate-cpp.dat").c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0644); if (write(fd, buf->getBuffer(), buf->getPos()) != (ssize_t)buf->getPos()) { throw vespalib::Exception("write failed"); diff --git a/document/src/tests/repo/documenttyperepo_test.cpp b/document/src/tests/repo/documenttyperepo_test.cpp index c53661cc170..93e08e2667f 100644 --- a/document/src/tests/repo/documenttyperepo_test.cpp +++ b/document/src/tests/repo/documenttyperepo_test.cpp @@ -441,7 +441,7 @@ TEST("requireThatDocumentLookupChecksName") { } TEST("requireThatBuildFromConfigWorks") { - DocumentTypeRepo repo(readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() + "documenttypes.cfg")); + DocumentTypeRepo repo(readDocumenttypesConfig(TEST_PATH("documenttypes.cfg"))); ASSERT_TRUE(repo.getDocumentType("document")); ASSERT_TRUE(repo.getDocumentType("types")); ASSERT_TRUE(repo.getDocumentType("types_search")); diff --git a/document/src/tests/serialization/annotationserializer_test.cpp b/document/src/tests/serialization/annotationserializer_test.cpp index e4321953620..260f48033c5 100644 --- a/document/src/tests/serialization/annotationserializer_test.cpp +++ b/document/src/tests/serialization/annotationserializer_test.cpp @@ -80,11 +80,9 @@ Test::readSpanTree(const string &file_name, const FixedTypeRepo &repo) { } void Test::requireThatSimpleSpanTreeIsDeserialized() { - DocumentTypeRepo type_repo(readDocumenttypesConfig( - vespalib::TestApp::GetSourceDirectory() + "annotation.serialize.test.repo.cfg")); + DocumentTypeRepo type_repo(readDocumenttypesConfig(TEST_PATH("annotation.serialize.test.repo.cfg"))); FixedTypeRepo repo(type_repo); - SpanTree::UP span_tree = std::move(readSpanTree( - vespalib::TestApp::GetSourceDirectory() + "test_data_serialized_simple", repo).front()); + SpanTree::UP span_tree = std::move(readSpanTree(TEST_PATH("test_data_serialized_simple"), repo).front()); EXPECT_EQUAL("html", span_tree->getName()); const SimpleSpanList *root = dynamic_cast<const SimpleSpanList *>(&span_tree->getRoot()); @@ -127,11 +125,10 @@ struct AnnotationComparator { }; void Test::requireThatAdvancedSpanTreeIsDeserialized() { - DocumentTypeRepo type_repo( - readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() + "annotation.serialize.test.repo.cfg")); + DocumentTypeRepo type_repo(readDocumenttypesConfig(TEST_PATH("annotation.serialize.test.repo.cfg"))); FixedTypeRepo repo(type_repo, "my_document"); - SpanTree::UP span_tree = std::move(readSpanTree( - vespalib::TestApp::GetSourceDirectory() + "test_data_serialized_advanced", repo).front()); + SpanTree::UP span_tree = std::move(readSpanTree(TEST_PATH("test_data_serialized_advanced"), + repo).front()); EXPECT_EQUAL("html", span_tree->getName()); const SpanList *root = dynamic_cast<const SpanList *>(&span_tree->getRoot()); @@ -223,9 +220,9 @@ void Test::requireThatAdvancedSpanTreeIsDeserialized() { void Test::requireThatSpanTreeCanBeSerialized() { DocumentTypeRepo type_repo( - readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() + "annotation.serialize.test.repo.cfg")); + readDocumenttypesConfig(TEST_PATH("annotation.serialize.test.repo.cfg"))); FixedTypeRepo repo(type_repo, "my_document"); - string file_name = vespalib::TestApp::GetSourceDirectory() + "test_data_serialized_advanced"; + string file_name = TEST_PATH("test_data_serialized_advanced"); FastOS_File file(file_name.c_str()); ASSERT_TRUE(file.OpenReadOnlyExisting()); diff --git a/document/src/tests/serialization/vespadocumentserializer_test.cpp b/document/src/tests/serialization/vespadocumentserializer_test.cpp index 7a238cd3b87..0f7e1d35a46 100644 --- a/document/src/tests/serialization/vespadocumentserializer_test.cpp +++ b/document/src/tests/serialization/vespadocumentserializer_test.cpp @@ -682,7 +682,7 @@ void deserializeAndCheck(const string &file_name, PredicateFieldValue &value) { } void checkDeserialization(const string &name, std::unique_ptr<Slime> slime) { - const string data_dir = vespalib::TestApp::GetSourceDirectory() + "../../test/resources/predicates/"; + const string data_dir = TEST_PATH("../../test/resources/predicates/"); PredicateFieldValue value(std::move(slime)); serializeToFile(value, data_dir + name + "__cpp"); @@ -801,7 +801,7 @@ void deserializeAndCheck(const string &file_name, TensorFieldValue &value) { } void checkDeserialization(const string &name, std::unique_ptr<Tensor> tensor) { - const string data_dir = vespalib::TestApp::GetSourceDirectory() + "../../test/resources/tensor/"; + const string data_dir = TEST_PATH("../../test/resources/tensor/"); TensorFieldValue value; if (tensor) { diff --git a/document/src/tests/struct_anno/struct_anno_test.cpp b/document/src/tests/struct_anno/struct_anno_test.cpp index 2c1b7fb9fe6..d87d513ab89 100644 --- a/document/src/tests/struct_anno/struct_anno_test.cpp +++ b/document/src/tests/struct_anno/struct_anno_test.cpp @@ -47,10 +47,9 @@ int Test::Main() { template <typename T, int N> int arraysize(const T (&)[N]) { return N; } void Test::requireThatStructFieldsCanContainAnnotations() { - DocumentTypeRepo repo(readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() - + "documenttypes.cfg")); + DocumentTypeRepo repo(readDocumenttypesConfig(TEST_PATH("documenttypes.cfg"))); - FastOS_File file((vespalib::TestApp::GetSourceDirectory() + "document.dat").c_str()); + FastOS_File file(TEST_PATH("document.dat").c_str()); ASSERT_TRUE(file.OpenReadOnlyExisting()); char buffer[1024]; ssize_t size = file.Read(buffer, arraysize(buffer)); diff --git a/document/src/tests/testxml.cpp b/document/src/tests/testxml.cpp index 90849060598..2c513d5188b 100644 --- a/document/src/tests/testxml.cpp +++ b/document/src/tests/testxml.cpp @@ -16,7 +16,7 @@ #include <vespa/document/update/removevalueupdate.h> #include <vespa/document/fieldvalue/fieldvalues.h> #include <vespa/vespalib/text/stringtokenizer.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> using vespalib::StringTokenizer; @@ -98,8 +98,7 @@ createTestDocumentUpdate(const DocumentTypeRepo& repo) void TestXml::testSimpleUsage() { - DocumentTypeRepo repo(readDocumenttypesConfig( - vespalib::TestApp::GetSourceDirectory() + "data/defaultdoctypes.cfg")); + DocumentTypeRepo repo(readDocumenttypesConfig(TEST_PATH("data/defaultdoctypes.cfg"))); Document::UP doc1(createTestDocument(repo)); doc1->setValue(doc1->getField("stringattr"), StringFieldValue("tjohei���")); @@ -128,8 +127,7 @@ void TestXml::testSimpleUsage() void TestXml::testDocumentUpdate() { - DocumentTypeRepo repo(readDocumenttypesConfig( - vespalib::TestApp::GetSourceDirectory() + "data/defaultdoctypes.cfg")); + DocumentTypeRepo repo(readDocumenttypesConfig(TEST_PATH("data/defaultdoctypes.cfg"))); DocumentUpdate::UP up1(createTestDocumentUpdate(repo)); std::string expected = diff --git a/documentapi/src/tests/messagebus/messagebus_test.cpp b/documentapi/src/tests/messagebus/messagebus_test.cpp index 924325d117a..caa2bb84d46 100644 --- a/documentapi/src/tests/messagebus/messagebus_test.cpp +++ b/documentapi/src/tests/messagebus/messagebus_test.cpp @@ -37,7 +37,7 @@ Test::Main() { TEST_INIT(_argv[0]); _repo.reset(new DocumentTypeRepo(readDocumenttypesConfig( - GetSourceDirectory() + "../../../test/cfg/testdoctypes.cfg"))); + TEST_PATH("../../../test/cfg/testdoctypes.cfg")))); testMessage(); TEST_FLUSH(); testProtocol(); TEST_FLUSH(); diff --git a/documentapi/src/tests/messages/error_codes_test.cpp b/documentapi/src/tests/messages/error_codes_test.cpp index e9ad68f441e..57c97956d0d 100644 --- a/documentapi/src/tests/messages/error_codes_test.cpp +++ b/documentapi/src/tests/messages/error_codes_test.cpp @@ -99,7 +99,7 @@ std::string to_sorted_key_value_string(const NamedErrorCodes& codes) { std::string ErrorCodesTest::path_prefixed(const std::string& file_name) const { - return GetSourceDirectory() + "../../../test/crosslanguagefiles/" + file_name; + return TEST_PATH("../../../test/crosslanguagefiles/" + file_name); } void diff --git a/documentapi/src/tests/messages/testbase.cpp b/documentapi/src/tests/messages/testbase.cpp index 7ccf681c825..75f569b306f 100644 --- a/documentapi/src/tests/messages/testbase.cpp +++ b/documentapi/src/tests/messages/testbase.cpp @@ -12,8 +12,8 @@ using document::readDocumenttypesConfig; TestBase::TestBase() : _repo(new DocumentTypeRepo(readDocumenttypesConfig( - GetSourceDirectory() + "../../../test/cfg/testdoctypes.cfg"))), - _dataPath(GetSourceDirectory() + "../../../test/crosslanguagefiles"), + TEST_PATH("../../../test/cfg/testdoctypes.cfg")))), + _dataPath(TEST_PATH("../../../test/crosslanguagefiles")), _loadTypes(), _protocol(_loadTypes, _repo), _tests() diff --git a/documentapi/src/tests/policies/policies_test.cpp b/documentapi/src/tests/policies/policies_test.cpp index 6ee1625954d..81f2057bfde 100644 --- a/documentapi/src/tests/policies/policies_test.cpp +++ b/documentapi/src/tests/policies/policies_test.cpp @@ -97,7 +97,7 @@ Test::Main() { TEST_INIT(_argv[0]); _repo.reset(new DocumentTypeRepo(readDocumenttypesConfig( - GetSourceDirectory() + "../../../test/cfg/testdoctypes.cfg"))); + TEST_PATH("../../../test/cfg/testdoctypes.cfg")))); _docType = _repo->getDocumentType("testdoc"); testProtocol(); TEST_FLUSH(); diff --git a/documentapi/src/tests/priority/priority.cpp b/documentapi/src/tests/priority/priority.cpp index a9fcd011a5e..d2d7a744380 100644 --- a/documentapi/src/tests/priority/priority.cpp +++ b/documentapi/src/tests/priority/priority.cpp @@ -35,7 +35,7 @@ Test::Main() expected.push_back(Priority::PRI_LOWEST); std::ifstream in; - in.open((GetSourceDirectory() + "../../../test/crosslanguagefiles/5.1-Priority.txt").c_str()); + in.open(TEST_PATH("../../../test/crosslanguagefiles/5.1-Priority.txt").c_str()); ASSERT_TRUE(in.good()); while (in) { std::string str; diff --git a/juniper/src/test/SrcTestSuite.cpp b/juniper/src/test/SrcTestSuite.cpp index 42dbe6e4a5e..1134192d085 100644 --- a/juniper/src/test/SrcTestSuite.cpp +++ b/juniper/src/test/SrcTestSuite.cpp @@ -59,7 +59,7 @@ public: }; int SrcTestSuiteApp::Main() { - juniper::TestEnv te(this, (GetSourceDirectory() + "../rpclient/testclient.rc").c_str()); + juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); SrcTestSuite suite; suite.Run(); long failures = suite.Report(); diff --git a/juniper/src/test/auxTestApp.cpp b/juniper/src/test/auxTestApp.cpp index 50b367f99ec..63e9a0e6c5b 100644 --- a/juniper/src/test/auxTestApp.cpp +++ b/juniper/src/test/auxTestApp.cpp @@ -21,7 +21,7 @@ void Usage(char* s) int AuxTestApp::Main() { - juniper::TestEnv te(this, (GetSourceDirectory() + "../rpclient/testclient.rc").c_str()); + juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); AuxTest pta; pta.SetStream(&std::cout); pta.Run(_argc, _argv); diff --git a/juniper/src/test/matchobjectTestApp.cpp b/juniper/src/test/matchobjectTestApp.cpp index 9c9786969be..620d461372d 100644 --- a/juniper/src/test/matchobjectTestApp.cpp +++ b/juniper/src/test/matchobjectTestApp.cpp @@ -32,7 +32,7 @@ LOG_SETUP("matchobjectTest"); class MatchObjectTestApp : public vespalib::TestApp { public: virtual int Main() { - juniper::TestEnv te(this, (GetSourceDirectory() + "../rpclient/testclient.rc").c_str()); + juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); MatchObjectTest test; test.SetStream(&std::cout); test.Run(_argc, _argv); diff --git a/juniper/src/test/mcandTestApp.cpp b/juniper/src/test/mcandTestApp.cpp index fb331ac2b2a..268224ed195 100644 --- a/juniper/src/test/mcandTestApp.cpp +++ b/juniper/src/test/mcandTestApp.cpp @@ -32,7 +32,7 @@ LOG_SETUP("mcandTest"); class MatchCandidateTestApp : public vespalib::TestApp { public: virtual int Main() { - juniper::TestEnv te(this, (GetSourceDirectory() + "../rpclient/testclient.rc").c_str()); + juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); MatchCandidateTest test; test.SetStream(&std::cout); test.Run(_argc, _argv); diff --git a/juniper/src/test/queryparserTestApp.cpp b/juniper/src/test/queryparserTestApp.cpp index 6391885599a..20537028fb9 100644 --- a/juniper/src/test/queryparserTestApp.cpp +++ b/juniper/src/test/queryparserTestApp.cpp @@ -32,7 +32,7 @@ LOG_SETUP("queryparserTest"); class QueryParserTestApp : public vespalib::TestApp { public: virtual int Main() { - juniper::TestEnv te(this, (GetSourceDirectory() + "../rpclient/testclient.rc").c_str()); + juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); QueryParserTest test; test.SetStream(&std::cout); test.Run(_argc, _argv); diff --git a/memfilepersistence/src/tests/device/partitionmonitortest.cpp b/memfilepersistence/src/tests/device/partitionmonitortest.cpp index 45eed305507..faa8451e4d1 100644 --- a/memfilepersistence/src/tests/device/partitionmonitortest.cpp +++ b/memfilepersistence/src/tests/device/partitionmonitortest.cpp @@ -63,7 +63,7 @@ struct FakeStatter : public PartitionMonitor::Statter { void PartitionMonitorTest::testNormalUsage() { - const std::string file_name = vespalib::TestApp::GetSourceDirectory() + "testrunner.cpp"; + const std::string file_name = TEST_PATH("testrunner.cpp"); PartitionMonitor monitor(file_name); FakeStatter* statter = new FakeStatter(); monitor.setStatter(std::unique_ptr<PartitionMonitor::Statter>(statter)); @@ -90,7 +90,7 @@ void PartitionMonitorTest::testNormalUsage() void PartitionMonitorTest::testHighInodeFillrate() { - const std::string file_name = vespalib::TestApp::GetSourceDirectory() + "testrunner.cpp"; + const std::string file_name = TEST_PATH("testrunner.cpp"); PartitionMonitor monitor(file_name); FakeStatter* statter = new FakeStatter(); statter->_info.f_favail = 2; @@ -118,7 +118,7 @@ void PartitionMonitorTest::testHighInodeFillrate() void PartitionMonitorTest::testAlwaysStatPolicy() { - PartitionMonitor monitor(vespalib::TestApp::GetSourceDirectory() + "testrunner.cpp"); + PartitionMonitor monitor(TEST_PATH("testrunner.cpp")); FakeStatter* statter = new FakeStatter(); monitor.setStatter(std::unique_ptr<PartitionMonitor::Statter>(statter)); monitor.setAlwaysStatPolicy(); @@ -130,7 +130,7 @@ void PartitionMonitorTest::testAlwaysStatPolicy() void PartitionMonitorTest::testPeriodPolicy() { - PartitionMonitor monitor(vespalib::TestApp::GetSourceDirectory() + "testrunner.cpp"); + PartitionMonitor monitor(TEST_PATH("testrunner.cpp")); FakeStatter* statter = new FakeStatter(); monitor.setStatter(std::unique_ptr<PartitionMonitor::Statter>(statter)); monitor.setStatPeriodPolicy(4); @@ -142,7 +142,7 @@ void PartitionMonitorTest::testPeriodPolicy() void PartitionMonitorTest::testStatOncePolicy() { - PartitionMonitor monitor(vespalib::TestApp::GetSourceDirectory() + "testrunner.cpp"); + PartitionMonitor monitor(TEST_PATH("testrunner.cpp")); FakeStatter* statter = new FakeStatter(); monitor.setStatter(std::unique_ptr<PartitionMonitor::Statter>(statter)); monitor.setStatOncePolicy(); @@ -154,7 +154,7 @@ void PartitionMonitorTest::testStatOncePolicy() void PartitionMonitorTest::testDynamicPolicy() { - PartitionMonitor monitor(vespalib::TestApp::GetSourceDirectory() + "testrunner.cpp"); + PartitionMonitor monitor(TEST_PATH("testrunner.cpp")); FakeStatter* statter = new FakeStatter(); monitor.setStatter(std::unique_ptr<PartitionMonitor::Statter>(statter)); monitor.setStatDynamicPolicy(2); @@ -180,7 +180,7 @@ void PartitionMonitorTest::testDynamicPolicy() void PartitionMonitorTest::testIsFull() { - PartitionMonitor monitor(vespalib::TestApp::GetSourceDirectory() + "testrunner.cpp"); + PartitionMonitor monitor(TEST_PATH("testrunner.cpp")); monitor.setMaxFillness(0.85); FakeStatter* statter = new FakeStatter(); monitor.setStatOncePolicy(); diff --git a/memfilepersistence/src/tests/helper/testhelper.cpp b/memfilepersistence/src/tests/helper/testhelper.cpp index 13950026b22..94fc21c5140 100644 --- a/memfilepersistence/src/tests/helper/testhelper.cpp +++ b/memfilepersistence/src/tests/helper/testhelper.cpp @@ -86,8 +86,7 @@ vdstestlib::DirConfig getStandardConfig(bool storagenode) { config->set("maxconcurrentvisitors_fixed", "4"); config->set("maxconcurrentvisitors_variable", "0"); config = &dc.addConfig("stor-visitordispatcher"); - addFileConfig(dc, "documenttypes", - vespalib::TestApp::GetSourceDirectory() + "config-doctypes.cfg"); + addFileConfig(dc, "documenttypes", TEST_PATH("config-doctypes.cfg")); addStorageDistributionConfig(dc); return dc; } diff --git a/messagebus/src/tests/configagent/configagent.cpp b/messagebus/src/tests/configagent/configagent.cpp index c04cd48fff1..ab1f4cdbe11 100644 --- a/messagebus/src/tests/configagent/configagent.cpp +++ b/messagebus/src/tests/configagent/configagent.cpp @@ -109,13 +109,13 @@ Test::Main() ConfigAgent agent(*this); EXPECT_TRUE(!checkHalf()); EXPECT_TRUE(!checkFull()); - agent.configure(FileConfigReader<MessagebusConfig>(GetSourceDirectory() + "full.cfg").read()); + agent.configure(FileConfigReader<MessagebusConfig>(TEST_PATH("full.cfg")).read()); EXPECT_TRUE(!checkHalf()); EXPECT_TRUE(checkFull()); - agent.configure(FileConfigReader<MessagebusConfig>(GetSourceDirectory() + "half.cfg").read()); + agent.configure(FileConfigReader<MessagebusConfig>(TEST_PATH("half.cfg")).read()); EXPECT_TRUE(checkHalf()); EXPECT_TRUE(!checkFull()); - agent.configure(FileConfigReader<MessagebusConfig>(GetSourceDirectory() + "full.cfg").read()); + agent.configure(FileConfigReader<MessagebusConfig>(TEST_PATH("full.cfg")).read()); EXPECT_TRUE(checkFull()); EXPECT_TRUE(!checkHalf()); TEST_DONE(); diff --git a/searchcommon/src/tests/schema/schema_test.cpp b/searchcommon/src/tests/schema/schema_test.cpp index 0bac074b43a..224de58e95f 100644 --- a/searchcommon/src/tests/schema/schema_test.cpp +++ b/searchcommon/src/tests/schema/schema_test.cpp @@ -3,7 +3,7 @@ #include <vespa/log/log.h> #include <vespa/vespalib/stllike/string.h> #include <fstream> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/config/common/configparser.h> #include <vespa/searchcommon/common/schemaconfigurer.h> LOG_SETUP("schema_test"); @@ -161,7 +161,7 @@ TEST("testLoadAndSave") { { // load from config -> save to file -> load from file Schema s; - SchemaConfigurer configurer(s, "dir:" + vespalib::TestApp::GetSourceDirectory()); + SchemaConfigurer configurer(s, "dir:" + TEST_PATH("")); EXPECT_EQUAL(3u, s.getNumIndexFields()); assertIndexField(SIF("a", SDT::STRING), s.getIndexField(0)); assertIndexField(SIF("b", SDT::INT64), s.getIndexField(1)); diff --git a/searchcore/src/tests/applyattrupdates/applyattrupdates.cpp b/searchcore/src/tests/applyattrupdates/applyattrupdates.cpp index 8cb671f585e..959c8250e8d 100644 --- a/searchcore/src/tests/applyattrupdates/applyattrupdates.cpp +++ b/searchcore/src/tests/applyattrupdates/applyattrupdates.cpp @@ -317,7 +317,7 @@ Test::requireThatWeightedSetAttributesAreUpdated() } Test::Test() - : _repo(readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() + "doctypes.cfg")), + : _repo(readDocumenttypesConfig(TEST_PATH("doctypes.cfg"))), _docType(_repo.getDocumentType("testdoc")) { } diff --git a/searchcore/src/tests/proton/docsummary/docsummary.cpp b/searchcore/src/tests/proton/docsummary/docsummary.cpp index 5aa138121f9..dbd4839732d 100644 --- a/searchcore/src/tests/proton/docsummary/docsummary.cpp +++ b/searchcore/src/tests/proton/docsummary/docsummary.cpp @@ -156,7 +156,7 @@ public: _queryLimiter(), _clock(), _dummy(), - _spec(vespalib::TestApp::GetSourceDirectory()), + _spec(TEST_PATH("")), _configMgr(_spec, getDocTypeName()), _documenttypesConfig(new DocumenttypesConfig()), _repo(repo), @@ -1250,11 +1250,11 @@ Test::Test() { std::string cfgId("summary"); _summaryCfg = config::ConfigGetter<vespa::config::search::SummaryConfig>::getConfig( - cfgId, config::FileSpec(vespalib::TestApp::GetSourceDirectory() + "summary.cfg")); + cfgId, config::FileSpec(TEST_PATH("summary.cfg"))); _resultCfg.ReadConfig(*_summaryCfg, cfgId.c_str()); std::string mapCfgId("summarymap"); std::unique_ptr<vespa::config::search::SummarymapConfig> mapCfg = config::ConfigGetter<vespa::config::search::SummarymapConfig>::getConfig( - mapCfgId, config::FileSpec(vespalib::TestApp::GetSourceDirectory() + "summarymap.cfg")); + mapCfgId, config::FileSpec(TEST_PATH("summarymap.cfg"))); for (size_t i = 0; i < mapCfg->override.size(); ++i) { const vespa::config::search::SummarymapConfig::Override & o = mapCfg->override[i]; if (o.command == "dynamicteaser") { @@ -1271,6 +1271,7 @@ Test::Test() } + int Test::Main() { diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp index 384de9f207e..a5e7aec421b 100644 --- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp +++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp @@ -20,7 +20,7 @@ LOG_SETUP("document_subdbs_test"); #include <vespa/searchlib/index/docbuilder.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/test/insertion_operators.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <iostream> @@ -57,10 +57,11 @@ const std::string SUB_NAME = "subdb"; const std::string BASE_DIR = "basedir"; const SerialNum CFG_SERIAL = 5; -struct ConfigDir1 { static vespalib::string dir() { return vespalib::TestApp::GetSourceDirectory() + "cfg1"; } }; -struct ConfigDir2 { static vespalib::string dir() { return vespalib::TestApp::GetSourceDirectory() + "cfg2"; } }; -struct ConfigDir3 { static vespalib::string dir() { return vespalib::TestApp::GetSourceDirectory() + "cfg3"; } }; -struct ConfigDir4 { static vespalib::string dir() { return vespalib::TestApp::GetSourceDirectory() + "cfg4"; } }; +struct ConfigDir1 { static vespalib::string dir() { return TEST_PATH("cfg1"); } }; +struct ConfigDir2 { static vespalib::string dir() { return TEST_PATH("cfg2"); } }; +struct ConfigDir3 { static vespalib::string dir() { return TEST_PATH("cfg3"); } }; +struct ConfigDir4 { static vespalib::string dir() { return TEST_PATH("cfg4") + ; } }; struct MySubDBOwner : public IDocumentSubDB::IOwner { diff --git a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp index 699da256c8e..e95e8adc4c8 100644 --- a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp @@ -20,7 +20,7 @@ LOG_SETUP("documentdb_test"); #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/transactionlog/translogserver.h> #include <tests/proton/common/dummydbowner.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> using document::DocumentType; using document::DocumentTypeRepo; @@ -73,7 +73,7 @@ Fixture::Fixture() DocumentType docType("typea", 0); DocumentTypeRepo::SP repo(new DocumentTypeRepo(docType)); TuneFileDocumentDB::SP tuneFileDocumentDB(new TuneFileDocumentDB); - config::DirSpec spec(vespalib::TestApp::GetSourceDirectory() + "cfg"); + config::DirSpec spec(TEST_PATH("cfg")); DocumentDBConfigHelper mgr(spec, "typea"); BootstrapConfig::SP b(new BootstrapConfig(1, diff --git a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp index e61e3763094..16cad6e07bd 100644 --- a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp +++ b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp @@ -7,7 +7,7 @@ LOG_SETUP("fileconfigmanager_test"); #include <vespa/searchcore/proton/server/fileconfigmanager.h> #include <vespa/searchcore/proton/test/documentdb_config_builder.h> #include <vespa/vespalib/io/fileutil.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchcore/proton/common/schemautil.h> using namespace config; @@ -53,7 +53,7 @@ getSchema(int step) DocumentDBConfig::SP makeBaseConfigSnapshot() { - config::DirSpec spec(vespalib::TestApp::GetSourceDirectory() + "cfg"); + config::DirSpec spec(TEST_PATH("cfg")); ConfigKeySet extraKeySet; extraKeySet.add<MycfgConfig>(""); DBCM dbcm(spec, "test", extraKeySet); diff --git a/searchlib/src/tests/datastore/logdatastore_test.cpp b/searchlib/src/tests/datastore/logdatastore_test.cpp index 7c558c2119d..b5591bc2eb0 100644 --- a/searchlib/src/tests/datastore/logdatastore_test.cpp +++ b/searchlib/src/tests/datastore/logdatastore_test.cpp @@ -3,7 +3,7 @@ #include <vespa/log/log.h> LOG_SETUP("datastore_test"); -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchlib/docstore/logdocumentstore.h> #include <vespa/searchlib/docstore/chunkformats.h> #include <vespa/searchlib/docstore/storebybucket.h> @@ -303,7 +303,7 @@ TEST("testTruncatedIdxFile"){ { // Files comes from the 'growing test'. LogDataStore datastore(executor, - vespalib::TestApp::GetSourceDirectory() + "bug-7257706", config, + TEST_PATH("bug-7257706"), config, GrowStrategy(), TuneFileSummary(), fileHeaderContext, tlSyncer, NULL); EXPECT_EQUAL(354ul, datastore.lastSyncToken()); diff --git a/searchlib/src/tests/fef/featurenameparser/featurenameparser_test.cpp b/searchlib/src/tests/fef/featurenameparser/featurenameparser_test.cpp index 5b4e3c96da5..bc04d1533f7 100644 --- a/searchlib/src/tests/fef/featurenameparser/featurenameparser_test.cpp +++ b/searchlib/src/tests/fef/featurenameparser/featurenameparser_test.cpp @@ -2,6 +2,7 @@ #include <vespa/fastos/fastos.h> #include <vespa/log/log.h> LOG_SETUP("featurenameparser_test"); +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchlib/fef/featurenameparser.h> #include <vector> @@ -144,7 +145,7 @@ Test::Main() EXPECT_TRUE(testParse("foo( , , )", true, "foo", ParamList().add("").add("").add(""), "")); EXPECT_TRUE(testParse("foo( \t , \n , \r , \f )", true, "foo", ParamList().add("").add("").add("").add(""), "")); - testFile(vespalib::TestApp::GetSourceDirectory() + "parsetest.txt"); + testFile(TEST_PATH("parsetest.txt")); TEST_DONE(); } diff --git a/searchlib/src/tests/fef/table/table_test.cpp b/searchlib/src/tests/fef/table/table_test.cpp index 6835b6df5b0..7df91c6ee5d 100644 --- a/searchlib/src/tests/fef/table/table_test.cpp +++ b/searchlib/src/tests/fef/table/table_test.cpp @@ -34,8 +34,8 @@ public: TableTest::TableTest() : vespalib::TestApp(), - _tables1Dir(vespalib::TestApp::GetSourceDirectory() + "tables1"), - _tables2Dir(vespalib::TestApp::GetSourceDirectory() + "tables2") + _tables1Dir(TEST_PATH("tables1")), + _tables2Dir(TEST_PATH("tables2")) { } diff --git a/searchlib/src/tests/grouping/grouping_serialization_test.cpp b/searchlib/src/tests/grouping/grouping_serialization_test.cpp index a194ed7232b..1db13dca83d 100644 --- a/searchlib/src/tests/grouping/grouping_serialization_test.cpp +++ b/searchlib/src/tests/grouping/grouping_serialization_test.cpp @@ -19,7 +19,7 @@ #include <vespa/searchlib/expression/integerbucketresultnode.h> #include <vespa/vespalib/objects/nboserializer.h> #include <vespa/vespalib/objects/nbostream.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/stringfmt.h> #include <fstream> #include <vespa/log/log.h> @@ -43,7 +43,7 @@ document::GlobalId getGlobalId(uint32_t docId) { struct Fixture { // Set WRITE_FILES to true to generate new expected serialization files. const bool WRITE_FILES = false; - const std::string file_path = vespalib::TestApp::GetSourceDirectory() + "../../test/files/"; + const std::string file_path = TEST_PATH("../../test/files/"); std::string file_name; std::ifstream file_stream; diff --git a/searchlib/src/tests/indexmetainfo/indexmetainfo_test.cpp b/searchlib/src/tests/indexmetainfo/indexmetainfo_test.cpp index 522f748c423..3bab4acceee 100644 --- a/searchlib/src/tests/indexmetainfo/indexmetainfo_test.cpp +++ b/searchlib/src/tests/indexmetainfo/indexmetainfo_test.cpp @@ -2,9 +2,9 @@ #include <vespa/fastos/fastos.h> #include <vespa/log/log.h> LOG_SETUP("indexmetainfo_test"); +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchlib/common/indexmetainfo.h> -#include "../../../../vespalib/src/vespa/vespalib/testkit/testapp.h" using search::IndexMetaInfo; @@ -17,7 +17,7 @@ Test::Main() { TEST_INIT("indexmetainfo_test"); { // load pregenerated file - IndexMetaInfo info(vespalib::TestApp::GetSourceDirectory()); + IndexMetaInfo info(TEST_PATH("")); EXPECT_TRUE(info.load()); ASSERT_TRUE(info.snapshots().size() == 4); EXPECT_TRUE(info.snapshots()[0].valid); @@ -89,7 +89,7 @@ Test::Main() EXPECT_TRUE(!info.load("file-not-present.txt")); } { // load files with errors should fail - IndexMetaInfo info(vespalib::TestApp::GetSourceDirectory()); + IndexMetaInfo info(TEST_PATH("")); EXPECT_TRUE(!info.load("bogus1.txt")); EXPECT_TRUE(!info.load("bogus2.txt")); EXPECT_TRUE(!info.load("bogus3.txt")); diff --git a/staging_vespalib/src/tests/fileheader/fileheader_test.cpp b/staging_vespalib/src/tests/fileheader/fileheader_test.cpp index cd3dc5271ed..4e9c8959ca5 100644 --- a/staging_vespalib/src/tests/fileheader/fileheader_test.cpp +++ b/staging_vespalib/src/tests/fileheader/fileheader_test.cpp @@ -593,7 +593,7 @@ void Test::testLayout() { FastOS_File file; - const std::string fileName = vespalib::TestApp::GetSourceDirectory() + "fileheader.dat"; + const std::string fileName = TEST_PATH("fileheader.dat"); ASSERT_TRUE(file.OpenReadOnly(fileName.c_str())); FileHeader header; diff --git a/storage/src/tests/bucketdb/bucketmanagertest.cpp b/storage/src/tests/bucketdb/bucketmanagertest.cpp index 7e34c14a495..f6baffb304d 100644 --- a/storage/src/tests/bucketdb/bucketmanagertest.cpp +++ b/storage/src/tests/bucketdb/bucketmanagertest.cpp @@ -195,7 +195,7 @@ void BucketManagerTest::setupTestEnvironment(bool fakePersistenceLayer, DocumentTypeRepo::SP repo(new DocumentTypeRepo( *ConfigGetter<DocumenttypesConfig>::getConfig( - "config-doctypes", FileSpec(vespalib::TestApp::GetSourceDirectory() + "config-doctypes.cfg")))); + "config-doctypes", FileSpec(TEST_PATH("config-doctypes.cfg"))))); _top.reset(new DummyStorageLink); _node.reset(new TestServiceLayerApp( DiskCount(2), NodeIndex(0), config.getConfigId())); diff --git a/storage/src/tests/common/testhelper.cpp b/storage/src/tests/common/testhelper.cpp index a530b918b77..acab4ef1b28 100644 --- a/storage/src/tests/common/testhelper.cpp +++ b/storage/src/tests/common/testhelper.cpp @@ -4,7 +4,7 @@ #include <vespa/log/log.h> #include <vespa/vespalib/io/fileutil.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> LOG_SETUP(".testhelper"); @@ -160,7 +160,7 @@ vdstestlib::DirConfig getStandardConfig(bool storagenode) { config->set("maxconcurrentvisitors_fixed", "4"); config->set("maxconcurrentvisitors_variable", "0"); config = &dc.addConfig("stor-visitordispatcher"); - addFileConfig(dc, "documenttypes", vespalib::TestApp::GetSourceDirectory() + "config-doctypes.cfg"); + addFileConfig(dc, "documenttypes", TEST_PATH("config-doctypes.cfg")); addStorageDistributionConfig(dc); return dc; } diff --git a/storage/src/tests/distributor/distributor_host_info_reporter_test.cpp b/storage/src/tests/distributor/distributor_host_info_reporter_test.cpp index 8cbe2045fd2..3084cb1d389 100644 --- a/storage/src/tests/distributor/distributor_host_info_reporter_test.cpp +++ b/storage/src/tests/distributor/distributor_host_info_reporter_test.cpp @@ -7,7 +7,7 @@ #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/jsonstream.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <tests/common/hostreporter/util.h> namespace storage { @@ -187,7 +187,7 @@ DistributorHostInfoReporterTest::generateExampleJson() std::string jsonString = json.str(); - std::string path = vespalib::TestApp::GetSourceDirectory() + "../../../protocols/getnodestate/distributor.json"; + std::string path = TEST_PATH("../../../protocols/getnodestate/distributor.json"); std::string goldenString = File::readAll(path); vespalib::slime::Memory goldenMemory(goldenString); diff --git a/storage/src/tests/distributor/getoperationtest.cpp b/storage/src/tests/distributor/getoperationtest.cpp index 169fdc1c213..d9013ca2c22 100644 --- a/storage/src/tests/distributor/getoperationtest.cpp +++ b/storage/src/tests/distributor/getoperationtest.cpp @@ -56,7 +56,7 @@ public: _repo.reset( new document::DocumentTypeRepo(*ConfigGetter<DocumenttypesConfig>:: getConfig("config-doctypes", - FileSpec(vespalib::TestApp::GetSourceDirectory() + "config-doctypes.cfg")))); + FileSpec(TEST_PATH("config-doctypes.cfg"))))); createLinks(); docId = document::DocumentId(document::DocIdString("test", "uri")); diff --git a/storage/src/tests/distributor/operationtargetresolvertest.cpp b/storage/src/tests/distributor/operationtargetresolvertest.cpp index 27f1cb722b0..3b62bd20299 100644 --- a/storage/src/tests/distributor/operationtargetresolvertest.cpp +++ b/storage/src/tests/distributor/operationtargetresolvertest.cpp @@ -51,7 +51,7 @@ struct OperationTargetResolverTest : public CppUnit::TestFixture, _repo.reset(new document::DocumentTypeRepo( *config::ConfigGetter<document::DocumenttypesConfig>::getConfig( "config-doctypes", - config::FileSpec(vespalib::TestApp::GetSourceDirectory() + "config-doctypes.cfg")))); + config::FileSpec(TEST_PATH("config-doctypes.cfg"))))); _html_type = _repo->getDocumentType("text/html"); createLinks(); }; diff --git a/storage/src/tests/distributor/putoperationtest.cpp b/storage/src/tests/distributor/putoperationtest.cpp index d2dc7583229..da99ca9e019 100644 --- a/storage/src/tests/distributor/putoperationtest.cpp +++ b/storage/src/tests/distributor/putoperationtest.cpp @@ -12,7 +12,7 @@ #include <tests/common/dummystoragelink.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/text/stringtokenizer.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <iomanip> #include <iostream> #include <memory> @@ -95,7 +95,7 @@ public: _repo.reset( new DocumentTypeRepo(*ConfigGetter<DocumenttypesConfig> ::getConfig("config-doctypes", - FileSpec(vespalib::TestApp::GetSourceDirectory() + "config-doctypes.cfg")))); + FileSpec(TEST_PATH("config-doctypes.cfg"))))); _html_type = _repo->getDocumentType("text/html"); createLinks(); }; diff --git a/storage/src/tests/distributor/updateoperationtest.cpp b/storage/src/tests/distributor/updateoperationtest.cpp index 9a2b529eb77..d0b4bf39db6 100644 --- a/storage/src/tests/distributor/updateoperationtest.cpp +++ b/storage/src/tests/distributor/updateoperationtest.cpp @@ -13,7 +13,7 @@ #include <vespa/document/config/config-documenttypes.h> #include <tests/distributor/messagesenderstub.h> #include <vespa/storage/distributor/operations/external/updateoperation.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> using std::shared_ptr; using namespace document; @@ -50,7 +50,7 @@ public: _repo.reset( new DocumentTypeRepo(*ConfigGetter<DocumenttypesConfig>:: getConfig("config-doctypes", - FileSpec(vespalib::TestApp::GetSourceDirectory() + "config-doctypes.cfg")))); + FileSpec(TEST_PATH("config-doctypes.cfg"))))); _html_type = _repo->getDocumentType("text/html"); createLinks(); } diff --git a/storage/src/tests/storageserver/documentapiconvertertest.cpp b/storage/src/tests/storageserver/documentapiconvertertest.cpp index 604e849ebe8..15e8cda23b4 100644 --- a/storage/src/tests/storageserver/documentapiconvertertest.cpp +++ b/storage/src/tests/storageserver/documentapiconvertertest.cpp @@ -15,7 +15,7 @@ #include <vespa/storageapi/message/persistence.h> #include <vespa/storageapi/message/visitor.h> #include <vespa/vdslib/container/writabledocumentlist.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> using document::DataType; using document::DocIdString; @@ -34,7 +34,7 @@ struct DocumentApiConverterTest : public CppUnit::TestFixture DocumentApiConverterTest() : _repo(new DocumentTypeRepo(readDocumenttypesConfig( - vespalib::TestApp::GetSourceDirectory() + "config-doctypes.cfg"))), + TEST_PATH("config-doctypes.cfg")))), _html_type(*_repo->getDocumentType("text/html")) { } diff --git a/streamingvisitors/src/tests/searchvisitor/searchvisitor.cpp b/streamingvisitors/src/tests/searchvisitor/searchvisitor.cpp index 7442e695227..5d8e1e15ef9 100644 --- a/streamingvisitors/src/tests/searchvisitor/searchvisitor.cpp +++ b/streamingvisitors/src/tests/searchvisitor/searchvisitor.cpp @@ -35,11 +35,11 @@ public: SearchVisitorTest::SearchVisitorTest() : vespalib::TestApp(), _componentRegister(), - _env("dir:" + GetSourceDirectory() + "cfg") + _env("dir:" + TEST_PATH("cfg")) { _componentRegister.setNodeInfo("mycluster", lib::NodeType::STORAGE, 1); _componentRegister.setClock(_clock); - StorageComponent::DocumentTypeRepoSP repo(new DocumentTypeRepo(readDocumenttypesConfig(GetSourceDirectory() + "cfg/documenttypes.cfg"))); + StorageComponent::DocumentTypeRepoSP repo(new DocumentTypeRepo(readDocumenttypesConfig(TEST_PATH("cfg/documenttypes.cfg")))); _componentRegister.setDocumentTypeRepo(repo); _component.reset(new StorageComponent(_componentRegister, "storage")); }; @@ -92,13 +92,13 @@ SearchVisitorTest::testSearchVisitor() vespalib::string stackDump = StackDumpCreator::create(*node); params.set("query", stackDump); - testCreateSearchVisitor("dir:" + GetSourceDirectory() + "cfg", params); + testCreateSearchVisitor("dir:" + TEST_PATH("cfg"), params); } void SearchVisitorTest::testOnlyRequireWeakReadConsistency() { - SearchVisitorFactory factory("dir:" + GetSourceDirectory() + "cfg"); + SearchVisitorFactory factory("dir:" + TEST_PATH("cfg")); VisitorFactory& factoryBase(factory); vdslib::Parameters params; std::unique_ptr<Visitor> sv( diff --git a/vbench/src/tests/input_file_reader/input_file_reader_test.cpp b/vbench/src/tests/input_file_reader/input_file_reader_test.cpp index bb39dcceafd..2b8a2741e10 100644 --- a/vbench/src/tests/input_file_reader/input_file_reader_test.cpp +++ b/vbench/src/tests/input_file_reader/input_file_reader_test.cpp @@ -1,5 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <vbench/test/all.h> using namespace vbench; @@ -10,7 +10,7 @@ TEST("input file reader") { EXPECT_TRUE(reader.tainted()); } { - InputFileReader reader(vespalib::TestApp::GetSourceDirectory() + "simple_test_input.txt"); + InputFileReader reader(TEST_PATH("simple_test_input.txt")); EXPECT_TRUE(!reader.tainted()); string line; EXPECT_TRUE(reader.readLine(line)); @@ -23,7 +23,7 @@ TEST("input file reader") { TEST_FLUSH(); } { - InputFileReader reader(vespalib::TestApp::GetSourceDirectory() + "hard_test_input.txt"); + InputFileReader reader(TEST_PATH("hard_test_input.txt")); EXPECT_TRUE(!reader.tainted()); string line; EXPECT_TRUE(reader.readLine(line)); diff --git a/vbench/src/tests/mapped_file_input/mapped_file_input_test.cpp b/vbench/src/tests/mapped_file_input/mapped_file_input_test.cpp index facd70b20ce..639b91bf66b 100644 --- a/vbench/src/tests/mapped_file_input/mapped_file_input_test.cpp +++ b/vbench/src/tests/mapped_file_input/mapped_file_input_test.cpp @@ -1,5 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <vbench/test/all.h> using namespace vbench; @@ -10,7 +10,7 @@ TEST("mapped file input") { EXPECT_TRUE(file.tainted()); } { - MappedFileInput file(vespalib::TestApp::GetSourceDirectory() + "file.txt"); + MappedFileInput file(TEST_PATH("file.txt")); EXPECT_TRUE(!file.tainted()); LineReader reader(file, 3); string line; diff --git a/vbench/src/tests/request_generator/request_generator_test.cpp b/vbench/src/tests/request_generator/request_generator_test.cpp index bdaf3fee75e..de5b8a61164 100644 --- a/vbench/src/tests/request_generator/request_generator_test.cpp +++ b/vbench/src/tests/request_generator/request_generator_test.cpp @@ -1,10 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <vbench/test/all.h> using namespace vbench; -TEST_FF("generate request", RequestReceptor(), RequestGenerator(vespalib::TestApp::GetSourceDirectory() + "input.txt", f1)) { +TEST_FF("generate request", RequestReceptor(), RequestGenerator(TEST_PATH("input.txt"), f1)) { f2.run(); ASSERT_TRUE(f1.request.get() != 0); EXPECT_EQUAL("/this/is/url", f1.request->url()); @@ -17,7 +17,7 @@ TEST_FF("input not found", RequestReceptor(), RequestGenerator("no_such_input.tx EXPECT_TRUE(f2.tainted()); } -TEST_FF("abort request generation", RequestReceptor(), RequestGenerator(vespalib::TestApp::GetSourceDirectory() + "input.txt", f1)) { +TEST_FF("abort request generation", RequestReceptor(), RequestGenerator(TEST_PATH("input.txt"), f1)) { f2.abort(); f2.run(); EXPECT_TRUE(f1.request.get() == 0); diff --git a/vdslib/src/tests/container/documentlisttest.cpp b/vdslib/src/tests/container/documentlisttest.cpp index 5804c2c1646..2c72e29787e 100644 --- a/vdslib/src/tests/container/documentlisttest.cpp +++ b/vdslib/src/tests/container/documentlisttest.cpp @@ -307,11 +307,10 @@ void WritableDocumentListTest::testSizeOf() void WritableDocumentListTest::testReadJavaFile() { - DocumentTypeRepo::SP repo(new DocumentTypeRepo(readDocumenttypesConfig( - vespalib::TestApp::GetSourceDirectory() + "../test/files/documenttypes.cfg"))); + DocumentTypeRepo::SP repo(new DocumentTypeRepo(readDocumenttypesConfig(TEST_PATH("../test/files/documenttypes.cfg")))); //read file - int file = open((vespalib::TestApp::GetSourceDirectory() + "../test/files/documentlist-java.dat").c_str(), O_RDONLY); + int file = open(TEST_PATH("../test/files/documentlist-java.dat").c_str(), O_RDONLY); if (file == -1) { CPPUNIT_ASSERT(0); } @@ -408,10 +407,10 @@ void WritableDocumentListTest::testGetSerializedSize() { void WritableDocumentListTest::testCopyEntry() { DocumentTypeRepo::SP repo(new DocumentTypeRepo(readDocumenttypesConfig( - vespalib::TestApp::GetSourceDirectory() + "../test/files/documenttypes.cfg"))); + TEST_PATH("../test/files/documenttypes.cfg")))); //read file - int file = open((vespalib::TestApp::GetSourceDirectory() + "../test/files/documentlist-java.dat").c_str(), O_RDONLY); + int file = open(TEST_PATH("../test/files/documentlist-java.dat").c_str(), O_RDONLY); if (file == -1) { CPPUNIT_ASSERT(0); } diff --git a/vdslib/src/tests/distribution/distributiontest.cpp b/vdslib/src/tests/distribution/distributiontest.cpp index be93ec614cf..dadba03247b 100644 --- a/vdslib/src/tests/distribution/distributiontest.cpp +++ b/vdslib/src/tests/distribution/distributiontest.cpp @@ -11,7 +11,7 @@ #include <stdlib.h> #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/io/fileutil.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/text/stringtokenizer.h> #include <vespa/vespalib/util/regexp.h> #include <vespa/vespalib/stllike/lexical_cast.h> @@ -116,18 +116,15 @@ DistributionTest::testVerifyJavaDistributions() std::string test = tests[i]; ClusterState state; { - std::ifstream in( - (vespalib::TestApp::GetSourceDirectory() + - "distribution/testdata/java_" + test + ".state").c_str()); + std::ifstream in(TEST_PATH("distribution/testdata/java_" + test + ".state").c_str()); std::string mystate; in >> mystate; in.close(); state = ClusterState(mystate); } Distribution distr(readConfig<vespa::config::content::StorDistributionConfig>( - "file:" + vespalib::TestApp::GetSourceDirectory() + "distribution/testdata/java_" + test + ".cfg")); - std::ofstream of((vespalib::TestApp::GetSourceDirectory() + - "distribution/testdata/cpp_" + test + ".distribution").c_str()); + "file:" + TEST_PATH("distribution/testdata/java_") + test + ".cfg")); + std::ofstream of((TEST_PATH("distribution/testdata/cpp_") + test + ".distribution").c_str()); long maxBucket = 1; long mask = 0; @@ -158,8 +155,8 @@ DistributionTest::testVerifyJavaDistributions() } of.close(); std::ostringstream cmd; - cmd << "diff -u " << vespalib::TestApp::GetSourceDirectory() << "distribution/testdata/cpp_" << test << ".distribution " - << vespalib::TestApp::GetSourceDirectory() << "distribution/testdata/java_" << test << ".distribution"; + cmd << "diff -u " << TEST_PATH("distribution/testdata/cpp_") << test << ".distribution " + << TEST_PATH("distribution/testdata/java_") << test << ".distribution"; int result = system(cmd.str().c_str()); CPPUNIT_ASSERT_EQUAL_MSG("Failed distribution sync test: " + test, 0, result); @@ -234,7 +231,7 @@ void DistributionTest::testVerifyJavaDistributions2() { vespalib::DirectoryList files( - vespalib::listDirectory(vespalib::TestApp::GetSourceDirectory() + "distribution/testdata")); + vespalib::listDirectory(TEST_PATH("distribution/testdata"))); for (uint32_t i=0, n=files.size(); i<n; ++i) { size_t pos = files[i].find(".java.results"); if (pos == vespalib::string::npos || pos + 13 != files[i].size()) { @@ -246,14 +243,14 @@ DistributionTest::testVerifyJavaDistributions2() using namespace vespalib::slime; vespalib::Slime slime; - auto buf = readFile(vespalib::TestApp::GetSourceDirectory() + "distribution/testdata/" + files[i]); + auto buf = readFile(TEST_PATH("distribution/testdata/") + files[i]); auto size = JsonFormat::decode({&buf[0], buf.size()}, slime); if (size == 0) { std::cerr << "\n\nSize of " << files[i] << " is 0. Maybe is not generated yet? Taking a 5 second nap!"; std::this_thread::sleep_for(std::chrono::seconds(5)); - buf = readFile(vespalib::TestApp::GetSourceDirectory() + "distribution/testdata/" + files[i]); + buf = readFile(TEST_PATH("distribution/testdata/") + files[i]); size = JsonFormat::decode({&buf[0], buf.size()}, slime); if (size == 0) { @@ -299,7 +296,7 @@ DistributionTest::testUnchangedDistribution() ClusterState state("distributor:10 storage:10"); Distribution distr(Distribution::getDefaultDistributionConfig(3, 10)); - std::ifstream in(vespalib::TestApp::GetSourceDirectory() + "distribution/testdata/41-distributordistribution"); + std::ifstream in(TEST_PATH("distribution/testdata/41-distributordistribution")); for (unsigned i = 0; i < 65536; i++) { uint16_t node = distr.getIdealDistributorNode( diff --git a/vespalib/src/tests/guard/guard_test.cpp b/vespalib/src/tests/guard/guard_test.cpp index 83de03e3f20..1e7ec21008f 100644 --- a/vespalib/src/tests/guard/guard_test.cpp +++ b/vespalib/src/tests/guard/guard_test.cpp @@ -3,6 +3,7 @@ #include <vespa/log/log.h> LOG_SETUP("guard_test"); #include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/guard.h> using namespace vespalib; @@ -132,7 +133,7 @@ Test::testDirPointer() EXPECT_TRUE(!dir.valid()); } { - DirPointer dir(opendir(vespalib::TestApp::GetSourceDirectory().c_str())); + DirPointer dir(opendir(TEST_PATH("").c_str())); EXPECT_TRUE(dir.valid()); dirent *de; diff --git a/vespalib/src/tests/make_fixture_macros/make_fixture_macros_test.cpp b/vespalib/src/tests/make_fixture_macros/make_fixture_macros_test.cpp index 5718592203a..61801c1d3b2 100644 --- a/vespalib/src/tests/make_fixture_macros/make_fixture_macros_test.cpp +++ b/vespalib/src/tests/make_fixture_macros/make_fixture_macros_test.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/fastos.h> #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/slaveproc.h> using namespace vespalib; @@ -18,8 +17,7 @@ TEST("make fixture macros") { EXPECT_TRUE(runPrint("../../apps/make_fixture_macros/vespalib_make_fixture_macros_app 9 > macros.tmp")); std::string diffCmd("diff -u "); - diffCmd += vespalib::TestApp::GetSourceDirectory(); - diffCmd += "../../vespa/vespalib/testkit/generated_fixture_macros.h macros.tmp"; + diffCmd += TEST_PATH("../../vespa/vespalib/testkit/generated_fixture_macros.h macros.tmp"); EXPECT_TRUE(runPrint(diffCmd.c_str())); } diff --git a/vespalib/src/tests/slime/json_slime_benchmark.cpp b/vespalib/src/tests/slime/json_slime_benchmark.cpp index 73c5dbceab6..ea6ea89375b 100644 --- a/vespalib/src/tests/slime/json_slime_benchmark.cpp +++ b/vespalib/src/tests/slime/json_slime_benchmark.cpp @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/fastos.h> #include <vespa/vespalib/data/slime/slime.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <iostream> #include <fstream> #include <sstream> @@ -37,7 +37,7 @@ int main(int argc, char *argv[]) if (argc > 1) { numRep = strtoul(argv[1], 0, 0); } - std::ifstream file((vespalib::TestApp::GetSourceDirectory() + "large_json.txt").c_str()); + std::ifstream file(TEST_PATH("large_json.txt").c_str()); assert(file.is_open()); std::stringstream buf; buf << file.rdbuf(); diff --git a/vespalib/src/tests/slime/slime_json_format_test.cpp b/vespalib/src/tests/slime/slime_json_format_test.cpp index 7995584f60b..c054cc5a428 100644 --- a/vespalib/src/tests/slime/slime_json_format_test.cpp +++ b/vespalib/src/tests/slime/slime_json_format_test.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/fastos.h> #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/data/slime/slime.h> #include <iostream> #include <fstream> @@ -352,7 +351,7 @@ TEST("decode simplified form") { } TEST_F("decode bytes not null-terminated", Slime) { - std::ifstream file(vespalib::TestApp::GetSourceDirectory() + "large_json.txt"); + std::ifstream file(TEST_PATH("large_json.txt")); ASSERT_TRUE(file.is_open()); std::stringstream buf; buf << file.rdbuf(); diff --git a/vespalib/src/tests/stllike/asciistream_test.cpp b/vespalib/src/tests/stllike/asciistream_test.cpp index 1dcfda2b53f..b3a55f4d134 100644 --- a/vespalib/src/tests/stllike/asciistream_test.cpp +++ b/vespalib/src/tests/stllike/asciistream_test.cpp @@ -3,6 +3,7 @@ #include <limits> #include <vespa/log/log.h> LOG_SETUP("identifiable_test"); +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/exceptions.h> @@ -342,7 +343,7 @@ AsciistreamTest::testCreateFromFile() asciistream is(asciistream::createFromFile("non-existing.txt")); EXPECT_TRUE(is.eof()); - is = asciistream::createFromFile(vespalib::TestApp::GetSourceDirectory() + "test.txt"); + is = asciistream::createFromFile(TEST_PATH("test.txt")); EXPECT_FALSE(is.eof()); EXPECT_EQUAL(12u, is.size()); string s; diff --git a/vespalib/src/tests/testapp-debug/testapp-debug.cpp b/vespalib/src/tests/testapp-debug/testapp-debug.cpp index cbe032f19f8..3081048ea7a 100644 --- a/vespalib/src/tests/testapp-debug/testapp-debug.cpp +++ b/vespalib/src/tests/testapp-debug/testapp-debug.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/fastos.h> #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/vespalib/testkit/testapp.h> using namespace vespalib; @@ -11,6 +10,6 @@ TEST_MAIN() { std::string diff_cmd("diff diff.out "); - diff_cmd += vespalib::TestApp::GetSourceDirectory() + "diff.ref"; + diff_cmd += TEST_PATH("diff.ref"); EXPECT_EQUAL(system(diff_cmd.c_str()), 0); } diff --git a/vespalib/src/tests/testapp-state/testapp-state.cpp b/vespalib/src/tests/testapp-state/testapp-state.cpp index df126f8dcfc..cf6ced914d4 100644 --- a/vespalib/src/tests/testapp-state/testapp-state.cpp +++ b/vespalib/src/tests/testapp-state/testapp-state.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/fastos.h> #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/vespalib/testkit/testapp.h> using namespace vespalib; @@ -10,6 +9,6 @@ TEST_MAIN() { system("cat out.txt | grep STATE | sed 's/([^)].*\\//(/' > actual.txt"); std::string diff_cmd("diff -u actual.txt "); - diff_cmd += vespalib::TestApp::GetSourceDirectory() + "expect.txt"; + diff_cmd += TEST_PATH("expect.txt"); EXPECT_EQUAL(system(diff_cmd.c_str()), 0); } diff --git a/vespalib/src/tests/text/lowercase/lowercase_test.cpp b/vespalib/src/tests/text/lowercase/lowercase_test.cpp index 39ae5c0aea0..0d2514a0a21 100644 --- a/vespalib/src/tests/text/lowercase/lowercase_test.cpp +++ b/vespalib/src/tests/text/lowercase/lowercase_test.cpp @@ -2,6 +2,7 @@ #include <vespa/fastos/fastos.h> #include <vespa/log/log.h> LOG_SETUP("lowercase_test"); +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/text/lowercase.h> #include <iostream> @@ -20,7 +21,7 @@ Test::Main() EXPECT_EQUAL((int8_t)'a', LowerCase::convert((int8_t)'A')); EXPECT_EQUAL((uint8_t)'a', LowerCase::convert((uint8_t)'A')); - std::ifstream yellData(vespalib::TestApp::GetSourceDirectory() + "yell-want.dat"); + std::ifstream yellData(TEST_PATH("yell-want.dat")); EXPECT_TRUE(yellData.good()); diff --git a/vespalib/src/tests/text/utf8/utf8_test.cpp b/vespalib/src/tests/text/utf8/utf8_test.cpp index e88fe756e40..fd58dbfa044 100644 --- a/vespalib/src/tests/text/utf8/utf8_test.cpp +++ b/vespalib/src/tests/text/utf8/utf8_test.cpp @@ -2,8 +2,10 @@ #include <vespa/fastos/fastos.h> #include <vespa/log/log.h> LOG_SETUP("utf8_test"); +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/text/utf8.h> + #if 0 #include <vespa/fastlib/text/unicodeutil.h> #endif @@ -54,7 +56,7 @@ Test::Main() { // read data produced from Java program - int fd = ::open((vespalib::TestApp::GetSourceDirectory() + "regular-utf8.dat").c_str(), O_RDONLY); + int fd = ::open(TEST_PATH("regular-utf8.dat").c_str(), O_RDONLY); ASSERT_TRUE(fd > 0); vespalib::string data; data.clear(); diff --git a/vespalib/src/tests/tutorial/make_tutorial.cpp b/vespalib/src/tests/tutorial/make_tutorial.cpp index a18c33afeeb..1d4c3596661 100644 --- a/vespalib/src/tests/tutorial/make_tutorial.cpp +++ b/vespalib/src/tests/tutorial/make_tutorial.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/slaveproc.h> #include <vespa/vespalib/util/stringfmt.h> #include <sys/mman.h> @@ -57,7 +56,7 @@ TEST_MAIN_WITH_PROCESS_PROXY() { size_t pos = 0; size_t end = 0; size_t cursor = 0; - std::string input = readFile(vespalib::TestApp::GetSourceDirectory() + "tutorial_source.html"); + std::string input = readFile(TEST_PATH("tutorial_source.html")); while ((pos = input.find(pre, cursor)) < input.size() && (end = input.find(post, pos)) < input.size()) { @@ -65,16 +64,13 @@ TEST_MAIN_WITH_PROCESS_PROXY() { pos += pre.size(); if (input.find(example, pos) == pos) { pos += example.size(); - insertExample(std::string((input.data() + pos), (end - pos)), - vespalib::TestApp::GetSourceDirectory()); + insertExample(std::string((input.data() + pos), (end - pos)), TEST_PATH("")); } else if (input.find(source, pos) == pos) { pos += source.size(); - insertSource(std::string((input.data() + pos), (end - pos)), - vespalib::TestApp::GetSourceDirectory()); + insertSource(std::string((input.data() + pos), (end - pos)), TEST_PATH("")); } else if (input.find(file, pos) == pos) { pos += file.size(); - insertFile(std::string((input.data() + pos), (end - pos)), - vespalib::TestApp::GetSourceDirectory()); + insertFile(std::string((input.data() + pos), (end - pos)), TEST_PATH("")); } else { std::string str((input.data() + pos), (end - pos)); TEST_FATAL(make_string("invalid directive >%s<", str.c_str()).c_str()); diff --git a/vespalib/src/vespa/vespalib/testkit/testapp.cpp b/vespalib/src/vespa/vespalib/testkit/testapp.cpp index ee5a76a0500..a4bb01e525c 100644 --- a/vespalib/src/vespa/vespalib/testkit/testapp.cpp +++ b/vespalib/src/vespa/vespalib/testkit/testapp.cpp @@ -17,23 +17,6 @@ TestApp::~TestApp() { } -const std::string& -TestApp::GetSourceDirectory() -{ - static const std::string srcDir = [] () { - std::string dir("."); - const char* env = getenv("SOURCE_DIRECTORY"); - if (env) { - dir = env; - } - if (*dir.rbegin() != '/') { - dir += "/"; - } - return dir; - } (); - return srcDir; -} - void TestApp::ReportInit(const char *name) { diff --git a/vespalib/src/vespa/vespalib/testkit/testapp.h b/vespalib/src/vespa/vespalib/testkit/testapp.h index 25e4c060822..644c85e4be7 100644 --- a/vespalib/src/vespa/vespalib/testkit/testapp.h +++ b/vespalib/src/vespa/vespalib/testkit/testapp.h @@ -179,13 +179,6 @@ public: const char *GetName() { return _name.c_str(); } /** - * @brief Obtain the source directory for the current test - * - * @return Path to source directory with trailing / - */ - static const std::string& GetSourceDirectory(); - - /** * @brief Report test initialization * * @param name the name of this test |