diff options
author | Arnstein Ressem <aressem@gmail.com> | 2016-08-23 15:10:36 +0200 |
---|---|---|
committer | Vegard Sjonfjell <vegardsjo@gmail.com> | 2016-08-23 15:10:36 +0200 |
commit | 55e5a91901109161186e05d3a6e959e06958bbba (patch) | |
tree | f312bab2c60207ee305dbcfa047fcc4fa8fd2dc1 /document | |
parent | d337a29392fb752dc725e4aea5efa0cc0df5f17a (diff) |
Aressem/cmake more out of source tests (#441)
* vespalib tests run out of source.
* staging_vespalib run tests out of source.
* fastos tests run out of source.
* Fixed storage tests out of source.
* Fixed some of the config tests.
* config* tests run out of source.
* document_* tests run out of source.
* documentapi_ tests run out of source.
* Fixed fsa out of source tests.
* Fix jrt_test out of source.
* More tests run out of source.
* Fix some slobrok and messagebus tests.
* More fixes for out of source tests.
* Done with first pass of regular tests out of source.
* Only use SOURCE_DIRECTORY in a limited set of places.
* Fix some remaining tests.
* Some cleanups.
* No need for extra slash.
Diffstat (limited to 'document')
-rw-r--r-- | document/src/tests/documentidtest.cpp | 3 | ||||
-rw-r--r-- | document/src/tests/documenttestcase.cpp | 39 | ||||
-rw-r--r-- | document/src/tests/documenttypetestcase.cpp | 10 | ||||
-rw-r--r-- | document/src/tests/documentupdatetestcase.cpp | 9 | ||||
-rw-r--r-- | document/src/tests/fieldpathupdatetestcase.cpp | 9 | ||||
-rw-r--r-- | document/src/tests/repo/documenttyperepo_test.cpp | 2 | ||||
-rw-r--r-- | document/src/tests/serialization/annotationserializer_test.cpp | 15 | ||||
-rw-r--r-- | document/src/tests/serialization/vespadocumentserializer_test.cpp | 4 | ||||
-rw-r--r-- | document/src/tests/struct_anno/struct_anno_test.cpp | 5 | ||||
-rw-r--r-- | document/src/tests/testxml.cpp | 7 | ||||
-rw-r--r-- | document/src/vespa/document/repo/documenttyperepo.cpp | 4 | ||||
-rw-r--r-- | document/src/vespa/document/repo/documenttyperepo.h | 1 |
12 files changed, 63 insertions, 45 deletions
diff --git a/document/src/tests/documentidtest.cpp b/document/src/tests/documentidtest.cpp index fd60c6c436b..b3da80ba958 100644 --- a/document/src/tests/documentidtest.cpp +++ b/document/src/tests/documentidtest.cpp @@ -5,6 +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 <sstream> #include <string> #include <vespa/document/bucket/bucketidfactory.h> @@ -81,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("cpp-globalidbucketids.txt")); + CPPUNIT_ASSERT(file.OpenWriteOnlyTruncate((vespalib::TestApp::GetSourceDirectory() + "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 9f8ab454bd2..fbef378e745 100644 --- a/document/src/tests/documenttestcase.cpp +++ b/document/src/tests/documenttestcase.cpp @@ -16,6 +16,7 @@ #include <vespa/document/serialization/vespadocumentserializer.h> #include <vespa/vespalib/objects/nbostream.h> #include <fstream> +#include <vespa/vespalib/testkit/testapp.h> using vespalib::nbostream; @@ -589,10 +590,10 @@ void verifyJavaDocument(Document& doc) void DocumentTest::testReadSerializedFile() { // Reads a file serialized from java - const char file_name[] = "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string file_name = vespalib::TestApp::GetSourceDirectory() + "data/crossplatform-java-cpp-doctypes.cfg"; DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); - int fd = open("data/serializejava.dat", O_RDONLY); + int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serializejava.dat").c_str(), O_RDONLY); size_t len = lseek(fd,0,SEEK_END); ByteBuffer buf(len); @@ -623,10 +624,11 @@ void DocumentTest::testReadSerializedFile() void DocumentTest::testReadSerializedFileCompressed() { // Reads a file serialized from java - const char file_name[] = "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string file_name = vespalib::TestApp::GetSourceDirectory() + + "data/crossplatform-java-cpp-doctypes.cfg"; DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); - int fd = open("data/serializejava-compressed.dat", O_RDONLY); + int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serializejava-compressed.dat").c_str(), O_RDONLY); int len = lseek(fd,0,SEEK_END); ByteBuffer buf(len); @@ -743,7 +745,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("data/document-cpp-currentversion-uncompressed.dat", + int fd = open((vespalib::TestApp::GetSourceDirectory() + "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()); @@ -756,7 +758,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("data/document-cpp-currentversion-lz4-9.dat", + int fd = open((vespalib::TestApp::GetSourceDirectory() + "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()); @@ -766,12 +768,12 @@ void DocumentTest::testReadSerializedAllVersions() } } - std::string jpath = "../test/serializeddocuments/"; + std::string jpath = vespalib::TestApp::GetSourceDirectory() + "../test/serializeddocuments/"; std::vector<TestDoc> tests; - tests.push_back(TestDoc("data/document-cpp-v8-uncompressed.dat", 8)); - tests.push_back(TestDoc("data/document-cpp-v7-uncompressed.dat", 7)); - tests.push_back(TestDoc("data/serializev6.dat", 6)); + 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(jpath + "document-java-v8-uncompressed.dat", 8)); for (uint32_t i=0; i<tests.size(); ++i) { int version = tests[i]._createdVersion; @@ -867,7 +869,7 @@ size_t getSerializedSizeBody(const Document &doc) { void DocumentTest::testGenerateSerializedFile() { - const char file_name[] = "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string file_name = vespalib::TestApp::GetSourceDirectory() + "data/crossplatform-java-cpp-doctypes.cfg"; DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); Document doc(*repo.getDocumentType("serializetest"), DocumentId(DocIdString("serializetest", @@ -906,8 +908,8 @@ void DocumentTest::testGenerateSerializedFile() std::unique_ptr<ByteBuffer> buf = doc.serialize(); -#define SERIALIZED_DIR "../test/document/" - int fd = open(SERIALIZED_DIR "/serializecpp.dat", + const std::string serializedDir = vespalib::TestApp::GetSourceDirectory() + "../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()) { throw vespalib::Exception("write failed"); @@ -916,7 +918,7 @@ void DocumentTest::testGenerateSerializedFile() ByteBuffer hBuf(getSerializedSizeHeader(doc)); doc.serializeHeader(hBuf); - fd = open(SERIALIZED_DIR "/serializecppsplit_header.dat", + fd = open((serializedDir + "/serializecppsplit_header.dat").c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0644); if (write(fd, hBuf.getBuffer(), hBuf.getPos()) != (ssize_t)hBuf.getPos()) { throw vespalib::Exception("write failed"); @@ -925,14 +927,13 @@ void DocumentTest::testGenerateSerializedFile() ByteBuffer bBuf(getSerializedSizeBody(doc)); doc.serializeBody(bBuf); - fd = open(SERIALIZED_DIR "/serializecppsplit_body.dat", + fd = open((vespalib::TestApp::GetSourceDirectory() + "/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"); } close(fd); - CompressionConfig newCfg(CompressionConfig::LZ4, 9, 95); const_cast<StructDataType &>(doc.getType().getFieldsType()).setCompressionConfig(newCfg); @@ -941,7 +942,7 @@ void DocumentTest::testGenerateSerializedFile() doc.serialize(lz4buf); lz4buf.flip(); - fd = open(SERIALIZED_DIR "/serializecpp-lz4-level9.dat", + fd = open((vespalib::TestApp::GetSourceDirectory() + "/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"); @@ -1308,7 +1309,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("data/serializev6.dat", O_RDONLY); + int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serializev6.dat").c_str(), O_RDONLY); int len = lseek(fd,0,SEEK_END); ByteBuffer buf(len); lseek(fd,0,SEEK_SET); @@ -1357,7 +1358,7 @@ void DocumentTest::testAnnotationDeserialization() .annotationType(1730712959, "apple", 0); DocumentTypeRepo repo(builder.config()); - int fd = open("data/serializejavawithannotations.dat", O_RDONLY); + int fd = open((vespalib::TestApp::GetSourceDirectory() + "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 e946844e867..da6d61b507d 100644 --- a/document/src/tests/documenttypetestcase.cpp +++ b/document/src/tests/documenttypetestcase.cpp @@ -7,6 +7,8 @@ #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 <sstream> #include <string> @@ -39,7 +41,6 @@ struct DocumentTypeTest : public CppUnit::TestFixture { CPPUNIT_TEST(testOutputOperator); CPPUNIT_TEST(testHeaderContent); CPPUNIT_TEST_SUITE_END(); - }; CPPUNIT_TEST_SUITE_REGISTRATION(DocumentTypeTest); @@ -93,8 +94,8 @@ void DocumentTypeTest::testInheritanceConfig() { DocumentTypeRepo - repo(readDocumenttypesConfig("data/inheritancetest.cfg")); - + repo(readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() + + "data/inheritancetest.cfg")); { const DocumentType* type(repo.getDocumentType("music")); CPPUNIT_ASSERT(type != NULL); @@ -110,7 +111,8 @@ void DocumentTypeTest::testHeaderContent() { DocumentTypeRepo - repo(readDocumenttypesConfig("data/doctypesconfigtest.cfg")); + repo(readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() + + "data/doctypesconfigtest.cfg")); const DocumentType* type(repo.getDocumentType("derived")); diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp index 971b8c4e88e..f3604493f01 100644 --- a/document/src/tests/documentupdatetestcase.cpp +++ b/document/src/tests/documentupdatetestcase.cpp @@ -23,6 +23,7 @@ #include <vespa/vespalib/tensor/types.h> #include <vespa/vespalib/tensor/default_tensor.h> #include <vespa/vespalib/tensor/tensor_factory.h> +#include <vespa/vespalib/testkit/testapp.h> using namespace document::config_builder; using vespalib::tensor::Tensor; @@ -572,10 +573,10 @@ DocumentUpdateTest::testIncrementWithZeroResultWeightIsRemoved() void DocumentUpdateTest::testReadSerializedFile() { // Reads a file serialized from java - const char file_name[] = "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string file_name = vespalib::TestApp::GetSourceDirectory() + "data/crossplatform-java-cpp-doctypes.cfg"; DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); - int fd = open("data/serializeupdatejava.dat", O_RDONLY); + int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serializeupdatejava.dat").c_str(), O_RDONLY); int len = lseek(fd,0,SEEK_END); ByteBuffer buf(len); @@ -649,7 +650,7 @@ void DocumentUpdateTest::testReadSerializedFile() void DocumentUpdateTest::testGenerateSerializedFile() { // Tests nothing, only generates a file for java test - const char file_name[] = "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string file_name = vespalib::TestApp::GetSourceDirectory() + "data/crossplatform-java-cpp-doctypes.cfg"; DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); const DocumentType *type(repo.getDocumentType("serializetest")); @@ -671,7 +672,7 @@ void DocumentUpdateTest::testGenerateSerializedFile() ArithmeticValueUpdate(ArithmeticValueUpdate::Mul, 2)))); ByteBuffer::UP buf(serialize42(upd)); - int fd = open("data/serializeupdatecpp.dat", + int fd = open((vespalib::TestApp::GetSourceDirectory() + "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 b79ff8873e5..ca1c8338f90 100644 --- a/document/src/tests/fieldpathupdatetestcase.cpp +++ b/document/src/tests/fieldpathupdatetestcase.cpp @@ -10,6 +10,7 @@ #include <vespa/document/repo/configbuilder.h> #include <vespa/vespalib/objects/identifiable.h> +#include <vespa/vespalib/testkit/testapp.h> #include <vespa/document/serialization/vespadocumentserializer.h> #include <fstream> #include <sstream> @@ -1270,10 +1271,10 @@ void FieldPathUpdateTestCase::testReadSerializedFile() { // Reads a file serialized from java - const char cfg_file_name[] = "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string cfg_file_name = vespalib::TestApp::GetSourceDirectory() + "data/crossplatform-java-cpp-doctypes.cfg"; DocumentTypeRepo repo(readDocumenttypesConfig(cfg_file_name)); - int fd = open("data/serialize-fieldpathupdate-java.dat", O_RDONLY); + int fd = open((vespalib::TestApp::GetSourceDirectory() + "data/serialize-fieldpathupdate-java.dat").c_str(), O_RDONLY); int len = lseek(fd,0,SEEK_END); ByteBuffer buf(len); @@ -1294,7 +1295,7 @@ FieldPathUpdateTestCase::testReadSerializedFile() void FieldPathUpdateTestCase::testGenerateSerializedFile() { - const char cfg_file_name[] = "data/crossplatform-java-cpp-doctypes.cfg"; + const std::string cfg_file_name = vespalib::TestApp::GetSourceDirectory()+ "data/crossplatform-java-cpp-doctypes.cfg"; DocumentTypeRepo repo(readDocumenttypesConfig(cfg_file_name)); // Tests nothing, only generates a file for java test DocumentUpdate::UP upd( @@ -1302,7 +1303,7 @@ FieldPathUpdateTestCase::testGenerateSerializedFile() ByteBuffer::UP buf(serializeHEAD(*upd)); - int fd = open("data/serialize-fieldpathupdate-cpp.dat", + int fd = open((vespalib::TestApp::GetSourceDirectory() + "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 003bd1698af..c53661cc170 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("documenttypes.cfg")); + DocumentTypeRepo repo(readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() + "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 1cc3fc19373..e4321953620 100644 --- a/document/src/tests/serialization/annotationserializer_test.cpp +++ b/document/src/tests/serialization/annotationserializer_test.cpp @@ -80,9 +80,11 @@ Test::readSpanTree(const string &file_name, const FixedTypeRepo &repo) { } void Test::requireThatSimpleSpanTreeIsDeserialized() { - DocumentTypeRepo type_repo(readDocumenttypesConfig("annotation.serialize.test.repo.cfg")); + DocumentTypeRepo type_repo(readDocumenttypesConfig( + vespalib::TestApp::GetSourceDirectory() + "annotation.serialize.test.repo.cfg")); FixedTypeRepo repo(type_repo); - SpanTree::UP span_tree = std::move(readSpanTree("test_data_serialized_simple", repo).front()); + SpanTree::UP span_tree = std::move(readSpanTree( + vespalib::TestApp::GetSourceDirectory() + "test_data_serialized_simple", repo).front()); EXPECT_EQUAL("html", span_tree->getName()); const SimpleSpanList *root = dynamic_cast<const SimpleSpanList *>(&span_tree->getRoot()); @@ -126,9 +128,10 @@ struct AnnotationComparator { void Test::requireThatAdvancedSpanTreeIsDeserialized() { DocumentTypeRepo type_repo( - readDocumenttypesConfig("annotation.serialize.test.repo.cfg")); + readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() + "annotation.serialize.test.repo.cfg")); FixedTypeRepo repo(type_repo, "my_document"); - SpanTree::UP span_tree = std::move(readSpanTree("test_data_serialized_advanced", repo).front()); + SpanTree::UP span_tree = std::move(readSpanTree( + vespalib::TestApp::GetSourceDirectory() + "test_data_serialized_advanced", repo).front()); EXPECT_EQUAL("html", span_tree->getName()); const SpanList *root = dynamic_cast<const SpanList *>(&span_tree->getRoot()); @@ -220,9 +223,9 @@ void Test::requireThatAdvancedSpanTreeIsDeserialized() { void Test::requireThatSpanTreeCanBeSerialized() { DocumentTypeRepo type_repo( - readDocumenttypesConfig("annotation.serialize.test.repo.cfg")); + readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() + "annotation.serialize.test.repo.cfg")); FixedTypeRepo repo(type_repo, "my_document"); - string file_name = "test_data_serialized_advanced"; + string file_name = vespalib::TestApp::GetSourceDirectory() + "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 0043548a906..7a238cd3b87 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 = "../../test/resources/predicates/"; + const string data_dir = vespalib::TestApp::GetSourceDirectory() + "../../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 = "../../test/resources/tensor/"; + const string data_dir = vespalib::TestApp::GetSourceDirectory() + "../../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 85b3b8f2d0b..2c1b7fb9fe6 100644 --- a/document/src/tests/struct_anno/struct_anno_test.cpp +++ b/document/src/tests/struct_anno/struct_anno_test.cpp @@ -47,9 +47,10 @@ int Test::Main() { template <typename T, int N> int arraysize(const T (&)[N]) { return N; } void Test::requireThatStructFieldsCanContainAnnotations() { - DocumentTypeRepo repo(readDocumenttypesConfig("documenttypes.cfg")); + DocumentTypeRepo repo(readDocumenttypesConfig(vespalib::TestApp::GetSourceDirectory() + + "documenttypes.cfg")); - FastOS_File file("document.dat"); + FastOS_File file((vespalib::TestApp::GetSourceDirectory() + "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 7729c748b3f..90849060598 100644 --- a/document/src/tests/testxml.cpp +++ b/document/src/tests/testxml.cpp @@ -16,6 +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> using vespalib::StringTokenizer; @@ -97,7 +98,8 @@ createTestDocumentUpdate(const DocumentTypeRepo& repo) void TestXml::testSimpleUsage() { - DocumentTypeRepo repo(readDocumenttypesConfig("data/defaultdoctypes.cfg")); + DocumentTypeRepo repo(readDocumenttypesConfig( + vespalib::TestApp::GetSourceDirectory() + "data/defaultdoctypes.cfg")); Document::UP doc1(createTestDocument(repo)); doc1->setValue(doc1->getField("stringattr"), StringFieldValue("tjohei���")); @@ -126,7 +128,8 @@ void TestXml::testSimpleUsage() void TestXml::testDocumentUpdate() { - DocumentTypeRepo repo(readDocumenttypesConfig("data/defaultdoctypes.cfg")); + DocumentTypeRepo repo(readDocumenttypesConfig( + vespalib::TestApp::GetSourceDirectory() + "data/defaultdoctypes.cfg")); DocumentUpdate::UP up1(createTestDocumentUpdate(repo)); std::string expected = diff --git a/document/src/vespa/document/repo/documenttyperepo.cpp b/document/src/vespa/document/repo/documenttyperepo.cpp index fd0feb35064..4b05261ab4b 100644 --- a/document/src/vespa/document/repo/documenttyperepo.cpp +++ b/document/src/vespa/document/repo/documenttyperepo.cpp @@ -586,4 +586,8 @@ DocumenttypesConfig readDocumenttypesConfig(const char *file_name) { return DocumenttypesConfig(*reader.read()); } +DocumenttypesConfig readDocumenttypesConfig(const std::string &file_name ) { + return readDocumenttypesConfig(file_name.c_str()); +} + } // namespace document diff --git a/document/src/vespa/document/repo/documenttyperepo.h b/document/src/vespa/document/repo/documenttyperepo.h index f3542d3cae2..199d35c0351 100644 --- a/document/src/vespa/document/repo/documenttyperepo.h +++ b/document/src/vespa/document/repo/documenttyperepo.h @@ -46,6 +46,7 @@ private: }; DocumenttypesConfig readDocumenttypesConfig(const char *file_name); +DocumenttypesConfig readDocumenttypesConfig(const std::string& file_name); } // namespace document |