summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vespalib/CMakeLists.txt1
-rw-r--r--vespalib/src/tests/tensor/tensor_conformance/CMakeLists.txt8
-rw-r--r--vespalib/src/tests/tensor/tensor_conformance/tensor_conformance_test.cpp23
-rw-r--r--vespalib/src/vespa/vespalib/eval/test/CMakeLists.txt1
-rw-r--r--vespalib/src/vespa/vespalib/eval/test/tensor_conformance.cpp27
-rw-r--r--vespalib/src/vespa/vespalib/eval/test/tensor_conformance.h26
6 files changed, 86 insertions, 0 deletions
diff --git a/vespalib/CMakeLists.txt b/vespalib/CMakeLists.txt
index f4c944876e7..3bbd6804450 100644
--- a/vespalib/CMakeLists.txt
+++ b/vespalib/CMakeLists.txt
@@ -84,6 +84,7 @@ vespa_define_module(
src/tests/tensor/tensor
src/tests/tensor/tensor_address
src/tests/tensor/tensor_address_element_iterator
+ src/tests/tensor/tensor_conformance
src/tests/tensor/tensor_function
src/tests/tensor/tensor_mapper
src/tests/tensor/tensor_operations
diff --git a/vespalib/src/tests/tensor/tensor_conformance/CMakeLists.txt b/vespalib/src/tests/tensor/tensor_conformance/CMakeLists.txt
new file mode 100644
index 00000000000..21a0469de64
--- /dev/null
+++ b/vespalib/src/tests/tensor/tensor_conformance/CMakeLists.txt
@@ -0,0 +1,8 @@
+# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(vespalib_tensor_tensor_conformance_test_app TEST
+ SOURCES
+ tensor_conformance_test.cpp
+ DEPENDS
+ vespalib
+)
+vespa_add_test(NAME vespalib_tensor_tensor_conformance_test_app COMMAND vespalib_tensor_tensor_conformance_test_app)
diff --git a/vespalib/src/tests/tensor/tensor_conformance/tensor_conformance_test.cpp b/vespalib/src/tests/tensor/tensor_conformance/tensor_conformance_test.cpp
new file mode 100644
index 00000000000..95991d9dd79
--- /dev/null
+++ b/vespalib/src/tests/tensor/tensor_conformance/tensor_conformance_test.cpp
@@ -0,0 +1,23 @@
+// 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/eval/test/tensor_conformance.h>
+#include <vespa/vespalib/eval/simple_tensor_engine.h>
+#include <vespa/vespalib/tensor/default_tensor_engine.h>
+
+using vespalib::eval::SimpleTensorEngine;
+using vespalib::eval::test::TensorConformance;
+using vespalib::tensor::DefaultTensorEngine;
+
+TEST_F("require that reference tensor implementation passes conformance test",
+ TensorConformance(SimpleTensorEngine::ref()))
+{
+ TEST_DO(f1.run_all_tests());
+}
+
+IGNORE_TEST_F("require that production tensor implementation passes conformance test",
+ TensorConformance(DefaultTensorEngine::ref()))
+{
+ TEST_DO(f1.run_all_tests());
+}
+
+TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/vespa/vespalib/eval/test/CMakeLists.txt b/vespalib/src/vespa/vespalib/eval/test/CMakeLists.txt
index 540b053603c..3d132b4d113 100644
--- a/vespalib/src/vespa/vespalib/eval/test/CMakeLists.txt
+++ b/vespalib/src/vespa/vespalib/eval/test/CMakeLists.txt
@@ -2,5 +2,6 @@
vespa_add_library(vespalib_vespalib_eval_test OBJECT
SOURCES
eval_spec.cpp
+ tensor_conformance.cpp
DEPENDS
)
diff --git a/vespalib/src/vespa/vespalib/eval/test/tensor_conformance.cpp b/vespalib/src/vespa/vespalib/eval/test/tensor_conformance.cpp
new file mode 100644
index 00000000000..fa62fcc1f10
--- /dev/null
+++ b/vespalib/src/vespa/vespalib/eval/test/tensor_conformance.cpp
@@ -0,0 +1,27 @@
+// 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 "tensor_conformance.h"
+#include <vespa/vespalib/eval/simple_tensor_engine.h>
+
+namespace vespalib {
+namespace eval {
+namespace test {
+namespace {
+
+void dummy_test(const TensorEngine &engine) {
+ EXPECT_TRUE(&engine == &SimpleTensorEngine::ref());
+}
+
+} // namespace vespalib::eval::test::<unnamed>
+
+void
+TensorConformance::run_all_tests() const
+{
+ TEST_DO(dummy_test(_engine));
+}
+
+} // namespace vespalib::eval::test
+} // namespace vespalib::eval
+} // namespace vespalib
diff --git a/vespalib/src/vespa/vespalib/eval/test/tensor_conformance.h b/vespalib/src/vespa/vespalib/eval/test/tensor_conformance.h
new file mode 100644
index 00000000000..0fbde9475f3
--- /dev/null
+++ b/vespalib/src/vespa/vespalib/eval/test/tensor_conformance.h
@@ -0,0 +1,26 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/vespalib/eval/tensor_engine.h>
+
+namespace vespalib {
+namespace eval {
+namespace test {
+
+/**
+ * A collection of tensor-related tests that can be run for various
+ * implementations of the TensorEngine interface.
+ **/
+class TensorConformance
+{
+private:
+ const TensorEngine &_engine;
+public:
+ TensorConformance(const TensorEngine &engine) : _engine(engine) {}
+ void run_all_tests() const;
+};
+
+} // namespace vespalib::eval::test
+} // namespace vespalib::eval
+} // namespace vespalib