summaryrefslogtreecommitdiffstats
path: root/vespalib/src
diff options
context:
space:
mode:
Diffstat (limited to 'vespalib/src')
-rw-r--r--vespalib/src/tests/eval/value_cache/tensor_loader_test.cpp12
-rw-r--r--vespalib/src/vespa/vespalib/testkit/test_macros.h1
-rw-r--r--vespalib/src/vespa/vespalib/testkit/test_master.cpp12
-rw-r--r--vespalib/src/vespa/vespalib/testkit/test_master.h2
4 files changed, 21 insertions, 6 deletions
diff --git a/vespalib/src/tests/eval/value_cache/tensor_loader_test.cpp b/vespalib/src/tests/eval/value_cache/tensor_loader_test.cpp
index 33fd9718f65..b9c646049e0 100644
--- a/vespalib/src/tests/eval/value_cache/tensor_loader_test.cpp
+++ b/vespalib/src/tests/eval/value_cache/tensor_loader_test.cpp
@@ -42,27 +42,27 @@ void verify_tensor(std::unique_ptr<Tensor> expect, ConstantValue::UP actual) {
}
TEST_F("require that load fails for invalid types", ConstantTensorLoader(SimpleTensorEngine::ref())) {
- TEST_DO(verify_error(f1.create("dense.json", "invalid type spec")));
+ TEST_DO(verify_error(f1.create(TEST_PATH("dense.json"), "invalid type spec")));
}
TEST_F("require that load fails for invalid file name", ConstantTensorLoader(SimpleTensorEngine::ref())) {
- TEST_DO(verify_error(f1.create("missing_file.json", "tensor(x[2],y[2])")));
+ TEST_DO(verify_error(f1.create(TEST_PATH("missing_file.json"), "tensor(x[2],y[2])")));
}
TEST_F("require that load fails for invalid json", ConstantTensorLoader(SimpleTensorEngine::ref())) {
- TEST_DO(verify_error(f1.create("invalid.json", "tensor(x[2],y[2])")));
+ TEST_DO(verify_error(f1.create(TEST_PATH("invalid.json"), "tensor(x[2],y[2])")));
}
TEST_F("require that dense tensors can be loaded", ConstantTensorLoader(SimpleTensorEngine::ref())) {
- TEST_DO(verify_tensor(make_dense_tensor(), f1.create("dense.json", "tensor(x[2],y[2])")));
+ TEST_DO(verify_tensor(make_dense_tensor(), f1.create(TEST_PATH("dense.json"), "tensor(x[2],y[2])")));
}
TEST_F("require that sparse tensors can be loaded", ConstantTensorLoader(SimpleTensorEngine::ref())) {
- TEST_DO(verify_tensor(make_sparse_tensor(), f1.create("sparse.json", "tensor(x{},y{})")));
+ TEST_DO(verify_tensor(make_sparse_tensor(), f1.create(TEST_PATH("sparse.json"), "tensor(x{},y{})")));
}
TEST_F("require that mixed tensors can be loaded", ConstantTensorLoader(SimpleTensorEngine::ref())) {
- TEST_DO(verify_tensor(make_mixed_tensor(), f1.create("mixed.json", "tensor(x{},y[2])")));
+ TEST_DO(verify_tensor(make_mixed_tensor(), f1.create(TEST_PATH("mixed.json"), "tensor(x{},y[2])")));
}
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/vespa/vespalib/testkit/test_macros.h b/vespalib/src/vespa/vespalib/testkit/test_macros.h
index f9b762d8d98..fd0e8a981e0 100644
--- a/vespalib/src/vespa/vespalib/testkit/test_macros.h
+++ b/vespalib/src/vespa/vespalib/testkit/test_macros.h
@@ -6,6 +6,7 @@
#define TEST_CAT_IMPL(a, b) a ## b
#define TEST_CAT(a, b) TEST_CAT_IMPL(a, b)
#define TEST_MASTER vespalib::TestMaster::master
+#define TEST_PATH(local_file) TEST_MASTER.get_path(local_file)
#define TEST_DEBUG(lhsFile, rhsFile) TEST_MASTER.openDebugFiles(lhsFile, rhsFile)
#define TEST_STATE(msg) vespalib::TestStateGuard TEST_CAT(testStateGuard, __LINE__) (__FILE__, __LINE__, msg)
#define TEST_DO(doit) do { TEST_STATE(TEST_STR(doit)); doit; } while(false)
diff --git a/vespalib/src/vespa/vespalib/testkit/test_master.cpp b/vespalib/src/vespa/vespalib/testkit/test_master.cpp
index 60fde106a27..5c3326bbe9d 100644
--- a/vespalib/src/vespa/vespalib/testkit/test_master.cpp
+++ b/vespalib/src/vespa/vespalib/testkit/test_master.cpp
@@ -12,6 +12,11 @@ const char *skip_path(const char *file) {
return (last == nullptr) ? file : (last + 1);
}
+std::string get_source_dir() {
+ const char *dir = getenv("SOURCE_DIRECTORY");
+ return (dir ? dir : ".");
+}
+
} // namespace vespalib::<unnamed>
//-----------------------------------------------------------------------------
@@ -152,6 +157,7 @@ TestMaster::reportConclusion(const vespalib::LockGuard &)
TestMaster::TestMaster()
: _lock(),
_name("<unnamed>"),
+ _path_prefix(get_source_dir() + "/"),
_state(),
_threadStorage()
{
@@ -175,6 +181,12 @@ TestMaster::getName()
return _name;
}
+std::string
+TestMaster::get_path(const std::string &local_file)
+{
+ return (_path_prefix + local_file);
+}
+
void
TestMaster::setThreadName(const char *name)
{
diff --git a/vespalib/src/vespa/vespalib/testkit/test_master.h b/vespalib/src/vespa/vespalib/testkit/test_master.h
index 78035fa2f65..523c9bd8eec 100644
--- a/vespalib/src/vespa/vespalib/testkit/test_master.h
+++ b/vespalib/src/vespa/vespalib/testkit/test_master.h
@@ -69,6 +69,7 @@ private:
private:
vespalib::Lock _lock;
std::string _name;
+ std::string _path_prefix;
SharedState _state;
std::vector<vespalib::LinkedPtr<ThreadState> > _threadStorage;
@@ -91,6 +92,7 @@ private:
public:
void init(const char *name);
std::string getName();
+ std::string get_path(const std::string &local_file);
void setThreadName(const char *name);
const char *getThreadName();
void setThreadUnwind(bool unwind);