aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vespalib/src/tests')
-rw-r--r--vespalib/src/tests/alloc/alloc_test.cpp2
-rw-r--r--vespalib/src/tests/array/array_test.cpp9
-rw-r--r--vespalib/src/tests/arrayqueue/arrayqueue.cpp1
-rw-r--r--vespalib/src/tests/barrier/barrier_test.cpp1
-rw-r--r--vespalib/src/tests/benchmark/benchmark.cpp24
-rw-r--r--vespalib/src/tests/component/component.cpp2
-rw-r--r--vespalib/src/tests/compression/compression_test.cpp2
-rw-r--r--vespalib/src/tests/data/memory_input/memory_input_test.cpp2
-rw-r--r--vespalib/src/tests/data/output_writer/output_writer_test.cpp2
-rw-r--r--vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp2
-rw-r--r--vespalib/src/tests/datastore/buffer_type/buffer_type_test.cpp3
-rw-r--r--vespalib/src/tests/directio/directio.cpp6
-rw-r--r--vespalib/src/tests/dotproduct/CMakeLists.txt1
-rw-r--r--vespalib/src/tests/dotproduct/dotproductbenchmark.cpp8
-rw-r--r--vespalib/src/tests/encoding/base64/base64_test.cpp13
-rw-r--r--vespalib/src/tests/executor/executor_test.cpp2
-rw-r--r--vespalib/src/tests/false/false.cpp12
-rw-r--r--vespalib/src/tests/fastlib/text/unicodeutiltest.cpp14
-rw-r--r--vespalib/src/tests/gencnt/gencnt_test.cpp13
-rw-r--r--vespalib/src/tests/guard/guard_test.cpp2
-rw-r--r--vespalib/src/tests/hwaccelerated/.gitignore1
-rw-r--r--vespalib/src/tests/hwaccelerated/CMakeLists.txt17
-rw-r--r--vespalib/src/tests/hwaccelerated/hwaccelerated_bench.cpp (renamed from vespalib/src/tests/hwaccelrated/hwaccelrated_bench.cpp)12
-rw-r--r--vespalib/src/tests/hwaccelerated/hwaccelerated_test.cpp (renamed from vespalib/src/tests/hwaccelrated/hwaccelrated_test.cpp)16
-rw-r--r--vespalib/src/tests/hwaccelrated/.gitignore1
-rw-r--r--vespalib/src/tests/hwaccelrated/CMakeLists.txt15
-rw-r--r--vespalib/src/tests/io/fileutil/fileutiltest.cpp1
-rw-r--r--vespalib/src/tests/memory/memory_test.cpp3
-rw-r--r--vespalib/src/tests/memorydatastore/memorydatastore.cpp2
-rw-r--r--vespalib/src/tests/metrics/simple_metrics_test.cpp2
-rw-r--r--vespalib/src/tests/metrics/stable_store_test.cpp2
-rw-r--r--vespalib/src/tests/net/send_fd/CMakeLists.txt1
-rw-r--r--vespalib/src/tests/net/send_fd/send_fd_test.cpp92
-rw-r--r--vespalib/src/tests/net/socket/CMakeLists.txt1
-rw-r--r--vespalib/src/tests/net/socket/socket_test.cpp382
-rw-r--r--vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/CMakeLists.txt1
-rw-r--r--vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp68
-rw-r--r--vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/test_config.json7
-rw-r--r--vespalib/src/tests/net/tls/capabilities/capabilities_test.cpp1
-rw-r--r--vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp4
-rw-r--r--vespalib/src/tests/net/tls/policy_checking_certificate_verifier/policy_checking_certificate_verifier_test.cpp1
-rw-r--r--vespalib/src/tests/net/tls/protocol_snooping/protocol_snooping_test.cpp1
-rw-r--r--vespalib/src/tests/net/tls/transport_options/CMakeLists.txt1
-rw-r--r--vespalib/src/tests/net/tls/transport_options/ok_config.json7
-rw-r--r--vespalib/src/tests/net/tls/transport_options/transport_options_reading_test.cpp364
-rw-r--r--vespalib/src/tests/objects/nbostream/nbostream_test.cpp1
-rw-r--r--vespalib/src/tests/objects/objectdump/objectdump.cpp12
-rw-r--r--vespalib/src/tests/objects/objectselection/objectselection.cpp12
-rw-r--r--vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp2
-rw-r--r--vespalib/src/tests/priority_queue/priority_queue_test.cpp2
-rw-r--r--vespalib/src/tests/rendezvous/rendezvous_test.cpp1
-rw-r--r--vespalib/src/tests/rusage/rusage_test.cpp2
-rw-r--r--vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp3
-rw-r--r--vespalib/src/tests/sequencedtaskexecutor/foregroundtaskexecutor_test.cpp2
-rw-r--r--vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp3
-rw-r--r--vespalib/src/tests/sha1/sha1_test.cpp3
-rw-r--r--vespalib/src/tests/shared_operation_throttler/shared_operation_throttler_test.cpp1
-rw-r--r--vespalib/src/tests/shutdownguard/shutdownguard_test.cpp2
-rw-r--r--vespalib/src/tests/singleexecutor/singleexecutor_test.cpp6
-rw-r--r--vespalib/src/tests/slime/json_slime_benchmark.cpp1
-rw-r--r--vespalib/src/tests/slime/slime_binary_format_test.cpp5
-rw-r--r--vespalib/src/tests/slime/slime_inject_test.cpp3
-rw-r--r--vespalib/src/tests/slime/slime_test.cpp3
-rw-r--r--vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp1
-rw-r--r--vespalib/src/tests/state_server/state_server_test.cpp3
-rw-r--r--vespalib/src/tests/stllike/cache_test.cpp2
-rw-r--r--vespalib/src/tests/stllike/hash_test.cpp3
-rw-r--r--vespalib/src/tests/stllike/hashtable_test.cpp2
-rw-r--r--vespalib/src/tests/stllike/lrucache.cpp2
-rw-r--r--vespalib/src/tests/stllike/vector_map_test.cpp2
-rw-r--r--vespalib/src/tests/sync/sync_test.cpp2
-rw-r--r--vespalib/src/tests/testapp-generic/testapp-generic.cpp3
-rw-r--r--vespalib/src/tests/text/lowercase/lowercase_test.cpp1
-rw-r--r--vespalib/src/tests/text/stringtokenizer/stringtokenizer_test.cpp12
-rw-r--r--vespalib/src/tests/text/utf8/utf8_test.cpp11
-rw-r--r--vespalib/src/tests/trace/trace.cpp2
-rw-r--r--vespalib/src/tests/true/true.cpp12
-rw-r--r--vespalib/src/tests/util/cgroup_resource_limits/cgroup_resource_limits_test.cpp4
-rw-r--r--vespalib/src/tests/valgrind/valgrind_test.cpp37
-rw-r--r--vespalib/src/tests/zcurve/zcurve_test.cpp66
80 files changed, 807 insertions, 546 deletions
diff --git a/vespalib/src/tests/alloc/alloc_test.cpp b/vespalib/src/tests/alloc/alloc_test.cpp
index 1436724267d..566ef8d9716 100644
--- a/vespalib/src/tests/alloc/alloc_test.cpp
+++ b/vespalib/src/tests/alloc/alloc_test.cpp
@@ -1,7 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/config.h>
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/alloc.h>
#include <vespa/vespalib/util/memory_allocator.h>
#include <vespa/vespalib/util/exceptions.h>
diff --git a/vespalib/src/tests/array/array_test.cpp b/vespalib/src/tests/array/array_test.cpp
index 48e82b56e7d..75050612357 100644
--- a/vespalib/src/tests/array/array_test.cpp
+++ b/vespalib/src/tests/array/array_test.cpp
@@ -1,8 +1,9 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/stllike/string.h>
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/test/memory_allocator_observer.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
#include <vespa/vespalib/util/array.hpp>
#include <vespa/vespalib/util/round_up_to_page_size.h>
#include <vespa/vespalib/util/size_literals.h>
@@ -37,7 +38,7 @@ using AllocStats = MyMemoryAllocator::Stats;
class Clever {
public:
Clever() : _counter(&_global) { (*_counter)++; }
- Clever(std::atomic<size_t> * counter) :
+ explicit Clever(std::atomic<size_t> * counter) :
_counter(counter)
{
(*_counter)++;
@@ -224,7 +225,7 @@ testBeginEnd(T & v)
EXPECT_EQUAL(1u, *(v.begin()));
EXPECT_EQUAL(3u, *(v.end() - 1));
- typename T::iterator i(v.begin());
+ auto i(v.begin());
EXPECT_EQUAL(1u, *i);
EXPECT_EQUAL(2u, *(i+1));
EXPECT_EQUAL(1u, *i++);
@@ -249,7 +250,7 @@ testBeginEnd(T & v)
EXPECT_EQUAL(3u, *(v.rbegin()));
EXPECT_EQUAL(1u, *(v.rend() - 1));
- typename T::reverse_iterator r(v.rbegin());
+ auto r(v.rbegin());
EXPECT_EQUAL(3u, *r);
EXPECT_EQUAL(2u, *(r+1));
EXPECT_EQUAL(3u, *r++);
diff --git a/vespalib/src/tests/arrayqueue/arrayqueue.cpp b/vespalib/src/tests/arrayqueue/arrayqueue.cpp
index c00cca17c78..657d379167f 100644
--- a/vespalib/src/tests/arrayqueue/arrayqueue.cpp
+++ b/vespalib/src/tests/arrayqueue/arrayqueue.cpp
@@ -1,5 +1,6 @@
// Copyright Vespa.ai. 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/test_master.hpp>
#include <vespa/vespalib/util/arrayqueue.hpp>
using namespace vespalib;
diff --git a/vespalib/src/tests/barrier/barrier_test.cpp b/vespalib/src/tests/barrier/barrier_test.cpp
index eba57f5381f..18032d92ce0 100644
--- a/vespalib/src/tests/barrier/barrier_test.cpp
+++ b/vespalib/src/tests/barrier/barrier_test.cpp
@@ -1,6 +1,7 @@
// Copyright Vespa.ai. 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/util/barrier.h>
+#include <vespa/vespalib/util/count_down_latch.h>
using namespace vespalib;
diff --git a/vespalib/src/tests/benchmark/benchmark.cpp b/vespalib/src/tests/benchmark/benchmark.cpp
index d5805a04cbc..771ea8be129 100644
--- a/vespalib/src/tests/benchmark/benchmark.cpp
+++ b/vespalib/src/tests/benchmark/benchmark.cpp
@@ -1,5 +1,5 @@
// Copyright Vespa.ai. 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 "testbase.h"
#include <vespa/log/log.h>
@@ -7,24 +7,16 @@ LOG_SETUP("benchmark_test");
using namespace vespalib;
-TEST_SETUP(Test)
-
-int
-Test::Main()
-{
- TEST_INIT("benchmark_test");
-
- if (_argc > 1) {
+TEST_MAIN() {
+ if (argc > 1) {
size_t concurrency(1);
size_t numRuns(1000);
- if (_argc > 2) {
- numRuns = strtoul(_argv[2], NULL, 0);
- if (_argc > 3) {
- concurrency = strtoul(_argv[3], NULL, 0);
+ if (argc > 2) {
+ numRuns = strtoul(argv[2], NULL, 0);
+ if (argc > 3) {
+ concurrency = strtoul(argv[3], NULL, 0);
}
}
- Benchmark::run(_argv[1], numRuns, concurrency);
+ Benchmark::run(argv[1], numRuns, concurrency);
}
-
- TEST_DONE();
}
diff --git a/vespalib/src/tests/component/component.cpp b/vespalib/src/tests/component/component.cpp
index 01d006d8aa8..15b381f6ba2 100644
--- a/vespalib/src/tests/component/component.cpp
+++ b/vespalib/src/tests/component/component.cpp
@@ -1,7 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/log/log.h>
LOG_SETUP("component_test");
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/component/version.h>
diff --git a/vespalib/src/tests/compression/compression_test.cpp b/vespalib/src/tests/compression/compression_test.cpp
index 264f21aeefe..3d8aeb02a81 100644
--- a/vespalib/src/tests/compression/compression_test.cpp
+++ b/vespalib/src/tests/compression/compression_test.cpp
@@ -1,9 +1,11 @@
// Copyright Vespa.ai. 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/test_master.hpp>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/util/compressor.h>
#include <vespa/vespalib/data/databuffer.h>
+#include <atomic>
#include <vespa/log/log.h>
LOG_SETUP("compression_test");
diff --git a/vespalib/src/tests/data/memory_input/memory_input_test.cpp b/vespalib/src/tests/data/memory_input/memory_input_test.cpp
index b3ed505b6e5..418a595eadb 100644
--- a/vespalib/src/tests/data/memory_input/memory_input_test.cpp
+++ b/vespalib/src/tests/data/memory_input/memory_input_test.cpp
@@ -1,5 +1,5 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/data/memory_input.h>
using namespace vespalib;
diff --git a/vespalib/src/tests/data/output_writer/output_writer_test.cpp b/vespalib/src/tests/data/output_writer/output_writer_test.cpp
index b3090624336..2fcc77c929f 100644
--- a/vespalib/src/tests/data/output_writer/output_writer_test.cpp
+++ b/vespalib/src/tests/data/output_writer/output_writer_test.cpp
@@ -1,5 +1,5 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/data/simple_buffer.h>
#include <vespa/vespalib/data/output_writer.h>
diff --git a/vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp b/vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp
index 01233a20fb5..f64287d334f 100644
--- a/vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp
+++ b/vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp
@@ -1,6 +1,6 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/datastore/entryref.h>
#include <vespa/vespalib/datastore/array_store_config.h>
#include <vespa/vespalib/util/size_literals.h>
diff --git a/vespalib/src/tests/datastore/buffer_type/buffer_type_test.cpp b/vespalib/src/tests/datastore/buffer_type/buffer_type_test.cpp
index b3af0c84b2d..d2dcf99081b 100644
--- a/vespalib/src/tests/datastore/buffer_type/buffer_type_test.cpp
+++ b/vespalib/src/tests/datastore/buffer_type/buffer_type_test.cpp
@@ -1,7 +1,8 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/datastore/buffer_type.h>
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
+#include <cassert>
using namespace vespalib::datastore;
diff --git a/vespalib/src/tests/directio/directio.cpp b/vespalib/src/tests/directio/directio.cpp
index 01d6be84516..7362c33c7b6 100644
--- a/vespalib/src/tests/directio/directio.cpp
+++ b/vespalib/src/tests/directio/directio.cpp
@@ -15,7 +15,7 @@ TEST("that DirectIOException propagates the correct information.") {
EXPECT_EQUAL(3u, e.getOffset());
EXPECT_EQUAL(msg, e.getBuffer());
EXPECT_EQUAL(0u, string(e.what()).find("DirectIO failed for file 'file.a' buffer="));
- EXPECT_EQUAL(string("file.a"), e.getFileName());
+ EXPECT_EQUAL("file.a", e.getFileName());
}
TEST("that DirectIOException is thrown on unaligned buf.") {
@@ -30,7 +30,7 @@ TEST("that DirectIOException is thrown on unaligned buf.") {
EXPECT_EQUAL(4_Ki, e.getLength());
EXPECT_EQUAL(0u, e.getOffset());
EXPECT_EQUAL(buf.getFree()+1, e.getBuffer());
- EXPECT_EQUAL(string(f.GetFileName()), e.getFileName());
+ EXPECT_EQUAL(f.GetFileName(), e.getFileName());
caught = true;
}
EXPECT_TRUE(caught);
@@ -48,7 +48,7 @@ TEST("that DirectIOException is thrown on unaligned offset.") {
EXPECT_EQUAL(4_Ki, e.getLength());
EXPECT_EQUAL(1u, e.getOffset());
EXPECT_EQUAL(buf.getFree(), e.getBuffer());
- EXPECT_EQUAL(string(f.GetFileName()), e.getFileName());
+ EXPECT_EQUAL(f.GetFileName(), e.getFileName());
caught = true;
}
EXPECT_TRUE(caught);
diff --git a/vespalib/src/tests/dotproduct/CMakeLists.txt b/vespalib/src/tests/dotproduct/CMakeLists.txt
index ff25f14e02c..41f8ba5c1cf 100644
--- a/vespalib/src/tests/dotproduct/CMakeLists.txt
+++ b/vespalib/src/tests/dotproduct/CMakeLists.txt
@@ -4,6 +4,7 @@ vespa_add_executable(vespalib_dotproductbenchmark_app
dotproductbenchmark.cpp
DEPENDS
vespalib
+ vespa_hwaccelerated
)
vespa_add_test(NAME vespalib_dotproductbenchmark_app_sparse-ordered COMMAND vespalib_dotproductbenchmark_app 10 10 1000 1000 BENCHMARK)
vespa_add_test(NAME vespalib_dotproductbenchmark_app_sparse-unordered COMMAND vespalib_dotproductbenchmark_app 10 10 1000 1000 BENCHMARK)
diff --git a/vespalib/src/tests/dotproduct/dotproductbenchmark.cpp b/vespalib/src/tests/dotproduct/dotproductbenchmark.cpp
index ce97683d1fc..ef88c8e94c3 100644
--- a/vespalib/src/tests/dotproduct/dotproductbenchmark.cpp
+++ b/vespalib/src/tests/dotproduct/dotproductbenchmark.cpp
@@ -1,5 +1,5 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/vespalib/hwaccelrated/iaccelrated.h>
+#include <vespa/vespalib/hwaccelerated/iaccelerated.h>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/stllike/hash_map.h>
#include <iostream>
@@ -8,7 +8,7 @@
#include <functional>
using namespace vespalib;
-using vespalib::hwaccelrated::IAccelrated;
+using vespalib::hwaccelerated::IAccelerated;
class Benchmark {
public:
@@ -54,14 +54,14 @@ public:
private:
std::vector<T> _values;
std::vector<T> _query;
- const IAccelrated & _dp;
+ const IAccelerated & _dp;
};
template <typename T>
FullBenchmark<T>::FullBenchmark(size_t numDocs, size_t numValues)
: _values(numDocs*numValues),
_query(numValues),
- _dp(IAccelrated::getAccelerator())
+ _dp(IAccelerated::getAccelerator())
{
for (size_t i(0); i < numDocs; i++) {
for (size_t j(0); j < numValues; j++) {
diff --git a/vespalib/src/tests/encoding/base64/base64_test.cpp b/vespalib/src/tests/encoding/base64/base64_test.cpp
index 2b058b33b49..21ff9af9162 100644
--- a/vespalib/src/tests/encoding/base64/base64_test.cpp
+++ b/vespalib/src/tests/encoding/base64/base64_test.cpp
@@ -1,17 +1,12 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/encoding/base64.h>
#include <vector>
using namespace vespalib;
-TEST_SETUP(Test);
-
-int
-Test::Main()
-{
- TEST_INIT("base64_test");
+TEST("base64_test") {
// Basic test without padding
std::string source = "No need to pad this string.";
@@ -78,6 +73,6 @@ Test::Main()
EXPECT_EQUAL(60, Base64::decode(encoded.c_str(), encoded.size(),
&buffer[0], minSizeNeeded));
EXPECT_EQUAL(source, std::string(&buffer[0], 60));
-
- TEST_DONE();
}
+
+TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/tests/executor/executor_test.cpp b/vespalib/src/tests/executor/executor_test.cpp
index afe37710088..5fcc23fe618 100644
--- a/vespalib/src/tests/executor/executor_test.cpp
+++ b/vespalib/src/tests/executor/executor_test.cpp
@@ -1,6 +1,6 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/util/lambdatask.h>
#include <vespa/vespalib/util/executor_stats.h>
diff --git a/vespalib/src/tests/false/false.cpp b/vespalib/src/tests/false/false.cpp
index e602bc9570e..1c86308a6ee 100644
--- a/vespalib/src/tests/false/false.cpp
+++ b/vespalib/src/tests/false/false.cpp
@@ -1,14 +1,10 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/log/log.h>
LOG_SETUP("false_test");
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
-TEST_SETUP(Test)
-
-int
-Test::Main()
-{
- TEST_INIT("false_test");
+TEST("false_test") {
EXPECT_TRUE(false);
- TEST_DONE();
}
+
+TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/tests/fastlib/text/unicodeutiltest.cpp b/vespalib/src/tests/fastlib/text/unicodeutiltest.cpp
index 7e8b52e6b30..6e86197bd3a 100644
--- a/vespalib/src/tests/fastlib/text/unicodeutiltest.cpp
+++ b/vespalib/src/tests/fastlib/text/unicodeutiltest.cpp
@@ -2,6 +2,7 @@
#include <vespa/fastlib/text/unicodeutil.h>
#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
TEST("GetUTF8Char_WrongInput") {
const char *testdata = "ab\xF8";
@@ -15,17 +16,4 @@ TEST("GetUTF8Char_WrongInput") {
EXPECT_EQUAL(Fast_UnicodeUtil::_BadUTF8Char, the_char);
}
-TEST("IsTerminalPunctuationChar") {
- // test a small selection
-
- EXPECT_TRUE(Fast_UnicodeUtil::IsTerminalPunctuationChar('!'));
- EXPECT_TRUE(Fast_UnicodeUtil::IsTerminalPunctuationChar(','));
- EXPECT_TRUE(Fast_UnicodeUtil::IsTerminalPunctuationChar('.'));
- EXPECT_TRUE(Fast_UnicodeUtil::IsTerminalPunctuationChar(':'));
- EXPECT_TRUE(Fast_UnicodeUtil::IsTerminalPunctuationChar(';'));
- EXPECT_FALSE(Fast_UnicodeUtil::IsTerminalPunctuationChar(' '));
- EXPECT_FALSE(Fast_UnicodeUtil::IsTerminalPunctuationChar('a'));
- EXPECT_FALSE(Fast_UnicodeUtil::IsTerminalPunctuationChar('A'));
-}
-
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/tests/gencnt/gencnt_test.cpp b/vespalib/src/tests/gencnt/gencnt_test.cpp
index d689abb3b9c..1932c8ea1e6 100644
--- a/vespalib/src/tests/gencnt/gencnt_test.cpp
+++ b/vespalib/src/tests/gencnt/gencnt_test.cpp
@@ -1,17 +1,12 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/log/log.h>
LOG_SETUP("gencnt_test");
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/gencnt.h>
using vespalib::GenCnt;
-TEST_SETUP(Test);
-
-int
-Test::Main()
-{
- TEST_INIT("gencnt_test");
+TEST("gencnt_test") {
GenCnt first;
@@ -80,6 +75,6 @@ Test::Main()
EXPECT_TRUE(b.distance(c) == 10);
EXPECT_TRUE(!first.inRangeInclusive(a, c));
EXPECT_TRUE(!first.inRangeInclusive(c, a));
-
- TEST_DONE();
}
+
+TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/tests/guard/guard_test.cpp b/vespalib/src/tests/guard/guard_test.cpp
index 2efe66201f9..c310f99ba3f 100644
--- a/vespalib/src/tests/guard/guard_test.cpp
+++ b/vespalib/src/tests/guard/guard_test.cpp
@@ -1,6 +1,6 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/util/guard.h>
#include <fcntl.h>
#include <unistd.h>
diff --git a/vespalib/src/tests/hwaccelerated/.gitignore b/vespalib/src/tests/hwaccelerated/.gitignore
new file mode 100644
index 00000000000..659184bbac3
--- /dev/null
+++ b/vespalib/src/tests/hwaccelerated/.gitignore
@@ -0,0 +1 @@
+vespalib_hwaccelerated_bench_app
diff --git a/vespalib/src/tests/hwaccelerated/CMakeLists.txt b/vespalib/src/tests/hwaccelerated/CMakeLists.txt
new file mode 100644
index 00000000000..044cfa2e9a3
--- /dev/null
+++ b/vespalib/src/tests/hwaccelerated/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(vespalib_hwaccelerated_test_app TEST
+ SOURCES
+ hwaccelerated_test.cpp
+ DEPENDS
+ vespalib
+ vespa_hwaccelerated
+)
+vespa_add_test(NAME vespalib_hwaccelerated_test_app COMMAND vespalib_hwaccelerated_test_app)
+
+vespa_add_executable(vespalib_hwaccelerated_bench_app
+ SOURCES
+ hwaccelerated_bench.cpp
+ DEPENDS
+ vespalib
+ vespa_hwaccelerated
+)
diff --git a/vespalib/src/tests/hwaccelrated/hwaccelrated_bench.cpp b/vespalib/src/tests/hwaccelerated/hwaccelerated_bench.cpp
index 61c53a20cf5..cebdeeab28b 100644
--- a/vespalib/src/tests/hwaccelrated/hwaccelrated_bench.cpp
+++ b/vespalib/src/tests/hwaccelerated/hwaccelerated_bench.cpp
@@ -1,7 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/vespalib/hwaccelrated/iaccelrated.h>
-#include <vespa/vespalib/hwaccelrated/generic.h>
+#include <vespa/vespalib/hwaccelerated/iaccelerated.h>
+#include <vespa/vespalib/hwaccelerated/generic.h>
#include <vespa/vespalib/util/time.h>
#include <cinttypes>
@@ -18,7 +18,7 @@ std::vector<T> createAndFill(size_t sz) {
template<typename T>
void
-benchmarkEuclideanDistance(const hwaccelrated::IAccelrated & accel, size_t sz, size_t count) {
+benchmarkEuclideanDistance(const hwaccelerated::IAccelerated & accel, size_t sz, size_t count) {
srand(1);
std::vector<T> a = createAndFill<T>(sz);
std::vector<T> b = createAndFill<T>(sz);
@@ -33,7 +33,7 @@ benchmarkEuclideanDistance(const hwaccelrated::IAccelrated & accel, size_t sz, s
}
void
-benchMarkEuclidianDistance(const hwaccelrated::IAccelrated & accelrator, size_t sz, size_t count) {
+benchMarkEuclidianDistance(const hwaccelerated::IAccelerated & accelrator, size_t sz, size_t count) {
printf("double : ");
benchmarkEuclideanDistance<double>(accelrator, sz, count);
printf("float : ");
@@ -53,8 +53,8 @@ int main(int argc, char *argv[]) {
}
printf("%s %d %d\n", argv[0], length, count);
printf("Squared Euclidian Distance - Generic\n");
- benchMarkEuclidianDistance(hwaccelrated::GenericAccelrator(), length, count);
+ benchMarkEuclidianDistance(hwaccelerated::GenericAccelrator(), length, count);
printf("Squared Euclidian Distance - Optimized for this cpu\n");
- benchMarkEuclidianDistance(hwaccelrated::IAccelrated::getAccelerator(), length, count);
+ benchMarkEuclidianDistance(hwaccelerated::IAccelerated::getAccelerator(), length, count);
return 0;
}
diff --git a/vespalib/src/tests/hwaccelrated/hwaccelrated_test.cpp b/vespalib/src/tests/hwaccelerated/hwaccelerated_test.cpp
index e35efb20c1a..3305b911de3 100644
--- a/vespalib/src/tests/hwaccelrated/hwaccelrated_test.cpp
+++ b/vespalib/src/tests/hwaccelerated/hwaccelerated_test.cpp
@@ -1,10 +1,10 @@
// Copyright Vespa.ai. 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/hwaccelrated/iaccelrated.h>
-#include <vespa/vespalib/hwaccelrated/generic.h>
+#include <vespa/vespalib/hwaccelerated/iaccelerated.h>
+#include <vespa/vespalib/hwaccelerated/generic.h>
#include <vespa/log/log.h>
-LOG_SETUP("hwaccelrated_test");
+LOG_SETUP("hwaccelerated_test");
using namespace vespalib;
@@ -18,7 +18,7 @@ std::vector<T> createAndFill(size_t sz) {
}
template<typename T, typename P>
-void verifyEuclideanDistance(const hwaccelrated::IAccelrated & accel, size_t testLength, double approxFactor) {
+void verifyEuclideanDistance(const hwaccelerated::IAccelerated & accel, size_t testLength, double approxFactor) {
srand(1);
std::vector<T> a = createAndFill<T>(testLength);
std::vector<T> b = createAndFill<T>(testLength);
@@ -34,17 +34,17 @@ void verifyEuclideanDistance(const hwaccelrated::IAccelrated & accel, size_t tes
}
void
-verifyEuclideanDistance(const hwaccelrated::IAccelrated & accelrator, size_t testLength) {
+verifyEuclideanDistance(const hwaccelerated::IAccelerated & accelrator, size_t testLength) {
verifyEuclideanDistance<int8_t, double>(accelrator, testLength, 0.0);
verifyEuclideanDistance<float, double>(accelrator, testLength, 0.0001); // Small deviation requiring EXPECT_APPROX
verifyEuclideanDistance<double, double>(accelrator, testLength, 0.0);
}
TEST("test euclidean distance") {
- hwaccelrated::GenericAccelrator genericAccelrator;
+ hwaccelerated::GenericAccelrator genericAccelrator;
constexpr size_t TEST_LENGTH = 140000; // must be longer than 64k
- TEST_DO(verifyEuclideanDistance(hwaccelrated::GenericAccelrator(), TEST_LENGTH));
- TEST_DO(verifyEuclideanDistance(hwaccelrated::IAccelrated::getAccelerator(), TEST_LENGTH));
+ TEST_DO(verifyEuclideanDistance(hwaccelerated::GenericAccelrator(), TEST_LENGTH));
+ TEST_DO(verifyEuclideanDistance(hwaccelerated::IAccelerated::getAccelerator(), TEST_LENGTH));
}
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/tests/hwaccelrated/.gitignore b/vespalib/src/tests/hwaccelrated/.gitignore
deleted file mode 100644
index 42f73a39d78..00000000000
--- a/vespalib/src/tests/hwaccelrated/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-vespalib_hwaccelrated_bench_app
diff --git a/vespalib/src/tests/hwaccelrated/CMakeLists.txt b/vespalib/src/tests/hwaccelrated/CMakeLists.txt
deleted file mode 100644
index b5e8f7daa2c..00000000000
--- a/vespalib/src/tests/hwaccelrated/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(vespalib_hwaccelrated_test_app TEST
- SOURCES
- hwaccelrated_test.cpp
- DEPENDS
- vespalib
-)
-vespa_add_test(NAME vespalib_hwaccelrated_test_app COMMAND vespalib_hwaccelrated_test_app)
-
-vespa_add_executable(vespalib_hwaccelrated_bench_app
- SOURCES
- hwaccelrated_bench.cpp
- DEPENDS
- vespalib
-)
diff --git a/vespalib/src/tests/io/fileutil/fileutiltest.cpp b/vespalib/src/tests/io/fileutil/fileutiltest.cpp
index 8e08c8c88bb..51b755e1668 100644
--- a/vespalib/src/tests/io/fileutil/fileutiltest.cpp
+++ b/vespalib/src/tests/io/fileutil/fileutiltest.cpp
@@ -1,6 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
#include <filesystem>
#include <iostream>
#include <vector>
diff --git a/vespalib/src/tests/memory/memory_test.cpp b/vespalib/src/tests/memory/memory_test.cpp
index 4b6815196c2..59d1cbe059d 100644
--- a/vespalib/src/tests/memory/memory_test.cpp
+++ b/vespalib/src/tests/memory/memory_test.cpp
@@ -1,6 +1,7 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/testkit/test_master.hpp>
#include <vespa/vespalib/util/memory.h>
using namespace vespalib;
diff --git a/vespalib/src/tests/memorydatastore/memorydatastore.cpp b/vespalib/src/tests/memorydatastore/memorydatastore.cpp
index fbbc1e76dff..3efab9e0178 100644
--- a/vespalib/src/tests/memorydatastore/memorydatastore.cpp
+++ b/vespalib/src/tests/memorydatastore/memorydatastore.cpp
@@ -1,6 +1,6 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/data/memorydatastore.h>
#include <vespa/vespalib/stllike/asciistream.h>
diff --git a/vespalib/src/tests/metrics/simple_metrics_test.cpp b/vespalib/src/tests/metrics/simple_metrics_test.cpp
index 8d751bf3528..a5b22b6726d 100644
--- a/vespalib/src/tests/metrics/simple_metrics_test.cpp
+++ b/vespalib/src/tests/metrics/simple_metrics_test.cpp
@@ -1,5 +1,5 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/data/slime/json_format.h>
#include <vespa/vespalib/metrics/simple_metrics.h>
diff --git a/vespalib/src/tests/metrics/stable_store_test.cpp b/vespalib/src/tests/metrics/stable_store_test.cpp
index 026e6f5dfef..33bff5eec4a 100644
--- a/vespalib/src/tests/metrics/stable_store_test.cpp
+++ b/vespalib/src/tests/metrics/stable_store_test.cpp
@@ -1,5 +1,5 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/metrics/simple_metrics.h>
#include <vespa/vespalib/metrics/simple_metrics_manager.h>
#include <vespa/vespalib/metrics/stable_store.h>
diff --git a/vespalib/src/tests/net/send_fd/CMakeLists.txt b/vespalib/src/tests/net/send_fd/CMakeLists.txt
index 4c46a773f5c..b4baaeb5855 100644
--- a/vespalib/src/tests/net/send_fd/CMakeLists.txt
+++ b/vespalib/src/tests/net/send_fd/CMakeLists.txt
@@ -4,5 +4,6 @@ vespa_add_executable(vespalib_send_fd_test_app TEST
send_fd_test.cpp
DEPENDS
vespalib
+ GTest::gtest
)
vespa_add_test(NAME vespalib_send_fd_test_app COMMAND vespalib_send_fd_test_app)
diff --git a/vespalib/src/tests/net/send_fd/send_fd_test.cpp b/vespalib/src/tests/net/send_fd/send_fd_test.cpp
index 59b9aacea07..8dc1235ff76 100644
--- a/vespalib/src/tests/net/send_fd/send_fd_test.cpp
+++ b/vespalib/src/tests/net/send_fd/send_fd_test.cpp
@@ -1,5 +1,5 @@
// Copyright Vespa.ai. 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/gtest/gtest.h>
#include <vespa/vespalib/testkit/time_bomb.h>
#include <vespa/vespalib/net/selector.h>
@@ -7,15 +7,19 @@
#include <vespa/vespalib/net/server_socket.h>
#include <vespa/vespalib/net/socket_options.h>
#include <vespa/vespalib/net/socket.h>
+#include <vespa/vespalib/test/nexus.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/test/socket_options_verifier.h>
-#include <thread>
-#include <functional>
#include <chrono>
+#include <functional>
+#include <latch>
+#include <optional>
+#include <thread>
#include <unistd.h>
#include <sys/stat.h>
using namespace vespalib;
+using vespalib::test::Nexus;
vespalib::string read_bytes(SocketHandle &socket, size_t wanted_bytes) {
char tmp[64];
@@ -23,7 +27,9 @@ vespalib::string read_bytes(SocketHandle &socket, size_t wanted_bytes) {
while (result.size() < wanted_bytes) {
size_t read_size = std::min(sizeof(tmp), wanted_bytes - result.size());
ssize_t read_result = socket.read(tmp, read_size);
- ASSERT_GREATER(read_result, 0);
+ if (read_result <= 0) {
+ return result;
+ }
result.append(tmp, read_result);
}
return result;
@@ -34,14 +40,14 @@ void verify_socket_io(bool is_server, SocketHandle &socket) {
vespalib::string client_message = "please pick up, I need to talk to you";
if(is_server) {
ssize_t written = socket.write(server_message.data(), server_message.size());
- EXPECT_EQUAL(written, ssize_t(server_message.size()));
+ EXPECT_EQ(written, ssize_t(server_message.size()));
vespalib::string read = read_bytes(socket, client_message.size());
- EXPECT_EQUAL(client_message, read);
+ EXPECT_EQ(client_message, read);
} else {
ssize_t written = socket.write(client_message.data(), client_message.size());
- EXPECT_EQUAL(written, ssize_t(client_message.size()));
+ EXPECT_EQ(written, ssize_t(client_message.size()));
vespalib::string read = read_bytes(socket, server_message.size());
- EXPECT_EQUAL(server_message, read);
+ EXPECT_EQ(server_message, read);
}
}
@@ -79,10 +85,10 @@ void send_fd(SocketHandle &socket, SocketHandle fd) {
int *fd_dst = (int *) (void *) CMSG_DATA(hdr);
fd_dst[0] = fd.get();
ssize_t res = sendmsg(socket.get(), &msg, 0);
- ASSERT_EQUAL(res, 1);
+ ASSERT_EQ(res, 1);
}
-SocketHandle recv_fd(SocketHandle &socket) {
+void recv_fd(SocketHandle &socket, std::optional<SocketHandle>& result) {
struct msghdr msg = {};
char tag = '*';
struct iovec data;
@@ -94,36 +100,62 @@ SocketHandle recv_fd(SocketHandle &socket) {
msg.msg_control = buf;
msg.msg_controllen = sizeof(buf);
ssize_t res = recvmsg(socket.get(), &msg, 0);
- ASSERT_EQUAL(res, 1);
+ ASSERT_EQ(res, 1);
struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg);
bool type_ok = ((hdr->cmsg_level == SOL_SOCKET) &&
(hdr->cmsg_type == SCM_RIGHTS));
ASSERT_TRUE(type_ok);
int *fd_src = (int *) (void *) CMSG_DATA(hdr);
fprintf(stderr, "got fd: %d\n", fd_src[0]);
- return SocketHandle(fd_src[0]);
+ result = SocketHandle(fd_src[0]);
}
//-----------------------------------------------------------------------------
-TEST_MT_FFF("require that an open socket (handle) can be passed over a unix domain socket", 3,
- ServerSocket("tcp/0"), ServerSocket("ipc/file:my_socket"), TimeBomb(60))
-{
- if (thread_id == 0) { // server
- SocketHandle socket = accept(f1);
- TEST_DO(verify_socket_io(true, socket)); // server side
- TEST_BARRIER();
- } else if (thread_id == 1) { // proxy
- SocketHandle server_socket = connect(f1);
- SocketHandle client_socket = accept(f2);
- send_fd(client_socket, std::move(server_socket));
- TEST_BARRIER();
- } else { // client
- SocketHandle proxy_socket = connect(f2);
- SocketHandle socket = recv_fd(proxy_socket);
- TEST_DO(verify_socket_io(false, socket)); // client side
- TEST_BARRIER();
+namespace {
+
+class WaitLatch {
+ std::latch& _latch;
+public:
+ explicit WaitLatch(std::latch& latch) noexcept
+ : _latch(latch)
+ {
}
+ ~WaitLatch() { _latch.arrive_and_wait(); }
+};
+
+}
+
+TEST(SendFdTest, require_that_an_open_socket_handle_can_be_passed_over_a_unix_domain_socket)
+{
+ constexpr size_t num_threads = 3;
+ ServerSocket f1("tcp/0");
+ ServerSocket f2("ipc/file:my_socket");
+ std::latch latch(num_threads);
+ TimeBomb f3(60);
+ auto task = [&f1,&f2,&latch](Nexus& ctx) {
+ auto thread_id = ctx.thread_id();
+ if (thread_id == 0) { // server
+ SocketHandle socket = accept(f1);
+ WaitLatch wait(latch);
+ SCOPED_TRACE("verify socket io server side");
+ verify_socket_io(true, socket); // server side
+ } else if (thread_id == 1) { // proxy
+ SocketHandle server_socket = connect(f1);
+ SocketHandle client_socket = accept(f2);
+ WaitLatch wait(latch);
+ ASSERT_NO_FATAL_FAILURE(send_fd(client_socket, std::move(server_socket)));
+ } else { // client
+ SocketHandle proxy_socket = connect(f2);
+ std::optional<SocketHandle> socket;
+ WaitLatch wait(latch);
+ ASSERT_NO_FATAL_FAILURE(recv_fd(proxy_socket, socket));
+ ASSERT_TRUE(socket.has_value());
+ SCOPED_TRACE("verify socket io client side");
+ verify_socket_io(false, socket.value()); // client side
+ }
+ };
+ Nexus::run(num_threads, task);
}
-TEST_MAIN() { TEST_RUN_ALL(); }
+GTEST_MAIN_RUN_ALL_TESTS()
diff --git a/vespalib/src/tests/net/socket/CMakeLists.txt b/vespalib/src/tests/net/socket/CMakeLists.txt
index d20720971d2..49c4ca20ba3 100644
--- a/vespalib/src/tests/net/socket/CMakeLists.txt
+++ b/vespalib/src/tests/net/socket/CMakeLists.txt
@@ -4,6 +4,7 @@ vespa_add_executable(vespalib_socket_test_app TEST
socket_test.cpp
DEPENDS
vespalib
+ GTest::gtest
)
vespa_add_test(NAME vespalib_socket_test_app COMMAND vespalib_socket_test_app)
vespa_add_executable(vespalib_socket_server_app
diff --git a/vespalib/src/tests/net/socket/socket_test.cpp b/vespalib/src/tests/net/socket/socket_test.cpp
index b0708388cd6..64f337c03f6 100644
--- a/vespalib/src/tests/net/socket/socket_test.cpp
+++ b/vespalib/src/tests/net/socket/socket_test.cpp
@@ -1,11 +1,12 @@
// Copyright Vespa.ai. 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/gtest/gtest.h>
#include <vespa/vespalib/testkit/time_bomb.h>
#include <vespa/vespalib/net/selector.h>
#include <vespa/vespalib/net/socket_spec.h>
#include <vespa/vespalib/net/server_socket.h>
#include <vespa/vespalib/net/socket_options.h>
#include <vespa/vespalib/net/socket.h>
+#include <vespa/vespalib/test/nexus.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/test/socket_options_verifier.h>
#include <thread>
@@ -14,19 +15,55 @@
#include <sys/stat.h>
using namespace vespalib;
+using vespalib::test::Nexus;
-bool ipv4_enabled = false;
-bool ipv6_enabled = false;
+class SocketTest : public ::testing::Test {
+protected:
+ static bool ipv4_enabled;
+ static bool ipv6_enabled;
-int my_inet() {
+ SocketTest();
+ ~SocketTest() override;
+ static void SetUpTestSuite();
+ static void TearDownTestSuite();
+ static int my_inet();
+};
+
+bool SocketTest::ipv4_enabled = false;
+bool SocketTest::ipv6_enabled = false;
+
+SocketTest::SocketTest()
+ : testing::Test()
+{
+}
+
+SocketTest::~SocketTest() = default;
+
+void
+SocketTest::SetUpTestSuite()
+{
+ auto list = SocketAddress::resolve(4080);
+ for (const auto &addr : list) {
+ (void) addr;
+ ipv4_enabled |= addr.is_ipv4();
+ ipv6_enabled |= addr.is_ipv6();
+ }
+ ASSERT_TRUE(ipv4_enabled || ipv6_enabled) << "tcp/ip support not detected";
+}
+
+void
+SocketTest::TearDownTestSuite()
+{
+}
+
+int
+SocketTest::my_inet()
+{
if (ipv6_enabled) {
return AF_INET6;
- }
- if (ipv4_enabled) {
+ } else {
return AF_INET;
}
- TEST_ERROR("tcp/ip support not detected");
- return AF_UNIX;
}
bool is_socket(const vespalib::string &path) {
@@ -52,8 +89,8 @@ void remove_file(const vespalib::string &path) {
void replace_file(const vespalib::string &path, const vespalib::string &data) {
remove_file(path);
int fd = creat(path.c_str(), 0600);
- ASSERT_NOT_EQUAL(fd, -1);
- ASSERT_EQUAL(write(fd, data.data(), data.size()), ssize_t(data.size()));
+ ASSERT_NE(fd, -1);
+ ASSERT_EQ(write(fd, data.data(), data.size()), ssize_t(data.size()));
close(fd);
}
@@ -96,14 +133,14 @@ void verify_socket_io(bool is_server, SocketHandle &socket) {
vespalib::string client_message = "please pick up, I need to talk to you";
if(is_server) {
ssize_t written = socket.write(server_message.data(), server_message.size());
- EXPECT_EQUAL(written, ssize_t(server_message.size()));
+ EXPECT_EQ(written, ssize_t(server_message.size()));
vespalib::string read = read_bytes(socket, client_message.size());
- EXPECT_EQUAL(client_message, read);
+ EXPECT_EQ(client_message, read);
} else {
ssize_t written = socket.write(client_message.data(), client_message.size());
- EXPECT_EQUAL(written, ssize_t(client_message.size()));
+ EXPECT_EQ(written, ssize_t(client_message.size()));
vespalib::string read = read_bytes(socket, server_message.size());
- EXPECT_EQUAL(server_message, read);
+ EXPECT_EQ(server_message, read);
}
}
@@ -122,22 +159,22 @@ SocketHandle connect_sockets(bool is_server, ServerSocket &server_socket) {
//-----------------------------------------------------------------------------
-TEST("my local address") {
+TEST_F(SocketTest, my_local_address)
+{
auto list = SocketAddress::resolve(4080);
fprintf(stderr, "resolve(4080):\n");
for (const auto &addr: list) {
EXPECT_TRUE(addr.is_wildcard());
EXPECT_TRUE(addr.is_ipv4() || addr.is_ipv6());
- ipv4_enabled |= addr.is_ipv4();
- ipv6_enabled |= addr.is_ipv6();
EXPECT_TRUE(!addr.is_ipc());
EXPECT_TRUE(!addr.is_abstract());
- EXPECT_EQUAL(addr.port(), 4080);
+ EXPECT_EQ(addr.port(), 4080);
fprintf(stderr, " %s (%s)\n", addr.spec().c_str(), get_meta(addr).c_str());
}
}
-TEST("yahoo.com address") {
+TEST_F(SocketTest, yahoo_com_address)
+{
auto list = SocketAddress::resolve(80, "yahoo.com");
fprintf(stderr, "resolve(80, 'yahoo.com'):\n");
for (const auto &addr: list) {
@@ -145,80 +182,102 @@ TEST("yahoo.com address") {
EXPECT_TRUE(addr.is_ipv4() || addr.is_ipv6());
EXPECT_TRUE(!addr.is_ipc());
EXPECT_TRUE(!addr.is_abstract());
- EXPECT_EQUAL(addr.port(), 80);
+ EXPECT_EQ(addr.port(), 80);
fprintf(stderr, " %s (%s)\n", addr.spec().c_str(), get_meta(addr).c_str());
}
}
-TEST("ipc address (path)") {
+TEST_F(SocketTest, ipc_address_with_path)
+{
auto addr = SocketAddress::from_path("my_socket");
EXPECT_TRUE(!addr.is_ipv4());
EXPECT_TRUE(!addr.is_ipv6());
EXPECT_TRUE(addr.is_ipc());
EXPECT_TRUE(!addr.is_abstract());
EXPECT_TRUE(!addr.is_wildcard());
- EXPECT_EQUAL(addr.port(), -1);
- EXPECT_EQUAL(vespalib::string("my_socket"), addr.path());
+ EXPECT_EQ(addr.port(), -1);
+ EXPECT_EQ(vespalib::string("my_socket"), addr.path());
EXPECT_TRUE(addr.name().empty());
fprintf(stderr, "from_path(my_socket)\n");
fprintf(stderr, " %s (%s)\n", addr.spec().c_str(), get_meta(addr).c_str());
}
-TEST("ipc address (name)") {
+TEST_F(SocketTest, ipc_address_with_name)
+{
auto addr = SocketAddress::from_name("my_socket");
EXPECT_TRUE(!addr.is_ipv4());
EXPECT_TRUE(!addr.is_ipv6());
EXPECT_TRUE(addr.is_ipc());
EXPECT_TRUE(addr.is_abstract());
EXPECT_TRUE(!addr.is_wildcard());
- EXPECT_EQUAL(addr.port(), -1);
+ EXPECT_EQ(addr.port(), -1);
EXPECT_TRUE(addr.path().empty());
- EXPECT_EQUAL(vespalib::string("my_socket"), addr.name());
+ EXPECT_EQ(vespalib::string("my_socket"), addr.name());
fprintf(stderr, "from_path(my_socket)\n");
fprintf(stderr, " %s (%s)\n", addr.spec().c_str(), get_meta(addr).c_str());
}
-TEST("local client/server addresses") {
+TEST_F(SocketTest, local_client_and_server_addresses) {
auto spec = SocketSpec("tcp/123");
auto client = spec.client_address();
auto server = spec.server_address();
EXPECT_TRUE(!client.is_wildcard());
- EXPECT_EQUAL(client.port(), 123);
+ EXPECT_EQ(client.port(), 123);
EXPECT_TRUE(server.is_wildcard());
- EXPECT_EQUAL(server.port(), 123);
+ EXPECT_EQ(server.port(), 123);
fprintf(stderr, "client(tcp/123): %s (%s)\n", client.spec().c_str(), get_meta(client).c_str());
fprintf(stderr, "server(tcp/123): %s (%s)\n", server.spec().c_str(), get_meta(server).c_str());
}
-TEST_MT_FF("require that basic socket io works", 2, ServerSocket("tcp/0"), TimeBomb(60)) {
- bool is_server = (thread_id == 0);
- SocketHandle socket = connect_sockets(is_server, f1);
- TEST_DO(verify_socket_io(is_server, socket));
-}
-
-TEST_MT_FF("require that basic unix domain socket io works (path)", 2,
- ServerSocket("ipc/file:my_socket"), TimeBomb(60))
+TEST_F(SocketTest, require_that_basic_socket_io_works)
+{
+ constexpr size_t num_threads = 2;
+ ServerSocket f1("tcp/0");
+ TimeBomb f2(60);
+ auto task = [&f1](Nexus& ctx) {
+ bool is_server = (ctx.thread_id() == 0);
+ SocketHandle socket = connect_sockets(is_server, f1);
+ verify_socket_io(is_server, socket);
+ };
+ Nexus::run(num_threads, task);
+}
+
+TEST_F(SocketTest, require_that_basic_unix_domain_socket_io_works_with_path)
+{
+ constexpr size_t num_threads = 2;
+ ServerSocket f1("ipc/file:my_socket");
+ TimeBomb f2(60);
+ auto task = [&f1](Nexus& ctx) {
+ bool is_server = (ctx.thread_id() == 0);
+ SocketHandle socket = connect_sockets(is_server, f1);
+ verify_socket_io(is_server, socket);
+ };
+ Nexus::run(num_threads, task);
+}
+
+TEST_F(SocketTest, require_that_server_accept_can_be_interrupted)
+{
+ constexpr size_t num_threads = 2;
+ ServerSocket f1("tcp/0");
+ TimeBomb f2(60);
+ auto task = [&f1](Nexus& ctx) {
+ bool is_server = (ctx.thread_id() == 0);
+ if (is_server) {
+ fprintf(stderr, "--> calling accept\n");
+ SocketHandle socket = f1.accept();
+ fprintf(stderr, "<-- accept returned\n");
+ EXPECT_TRUE(!socket.valid());
+ } else {
+ std::this_thread::sleep_for(std::chrono::milliseconds(20));
+ fprintf(stderr, "--- closing server socket\n");
+ f1.shutdown();
+ }
+ };
+ Nexus::run(num_threads, task);
+}
+
+TEST_F(SocketTest, require_that_socket_file_is_removed_by_server_socket_when_destructed)
{
- bool is_server = (thread_id == 0);
- SocketHandle socket = connect_sockets(is_server, f1);
- TEST_DO(verify_socket_io(is_server, socket));
-}
-
-TEST_MT_FF("require that server accept can be interrupted", 2, ServerSocket("tcp/0"), TimeBomb(60)) {
- bool is_server = (thread_id == 0);
- if (is_server) {
- fprintf(stderr, "--> calling accept\n");
- SocketHandle socket = f1.accept();
- fprintf(stderr, "<-- accept returned\n");
- EXPECT_TRUE(!socket.valid());
- } else {
- std::this_thread::sleep_for(std::chrono::milliseconds(20));
- fprintf(stderr, "--- closing server socket\n");
- f1.shutdown();
- }
-}
-
-TEST("require that socket file is removed by server socket when destructed") {
remove_file("my_socket");
ServerSocket server("ipc/file:my_socket");
EXPECT_TRUE(server.valid());
@@ -227,7 +286,8 @@ TEST("require that socket file is removed by server socket when destructed") {
EXPECT_TRUE(!is_socket("my_socket"));
}
-TEST("require that socket file is only removed on destruction if it is a socket") {
+TEST_F(SocketTest, require_that_socket_file_is_only_removed_on_destruction_if_it_is_a_socket)
+{
remove_file("my_socket");
ServerSocket server("ipc/file:my_socket");
EXPECT_TRUE(server.valid());
@@ -238,7 +298,8 @@ TEST("require that socket file is only removed on destruction if it is a socket"
remove_file("my_socket");
}
-TEST("require that a server socket will fail to listen to a path that is already a regular file") {
+TEST_F(SocketTest, require_that_a_server_socket_will_fail_to_listen_to_a_path_that_is_already_a_regular_file)
+{
replace_file("my_socket", "hello\n");
ServerSocket server("ipc/file:my_socket");
EXPECT_TRUE(!server.valid());
@@ -247,7 +308,8 @@ TEST("require that a server socket will fail to listen to a path that is already
remove_file("my_socket");
}
-TEST("require that a server socket will fail to listen to a path that is already taken by another server") {
+TEST_F(SocketTest, require_that_a_server_socket_will_fail_to_listen_to_a_path_that_is_already_taken_by_another_server)
+{
remove_file("my_socket");
ServerSocket server1("ipc/file:my_socket");
ServerSocket server2("ipc/file:my_socket");
@@ -258,7 +320,8 @@ TEST("require that a server socket will fail to listen to a path that is already
EXPECT_TRUE(!is_socket("my_socket"));
}
-TEST("require that a server socket will remove an old socket file if it cannot be connected to") {
+TEST_F(SocketTest, require_that_a_server_socket_will_remove_an_old_socket_file_if_it_cannot_be_connected_to)
+{
remove_file("my_socket");
{
SocketHandle server_handle = SocketAddress::from_path("my_socket").listen();
@@ -272,15 +335,21 @@ TEST("require that a server socket will remove an old socket file if it cannot b
}
#ifdef __linux__
-TEST_MT_FF("require that basic unix domain socket io works (name)", 2,
- ServerSocket(make_string("ipc/name:my_socket-%d", int(getpid()))), TimeBomb(60))
+TEST_F(SocketTest, require_that_basic_unix_domain_socket_io_works_with_name)
+{
+ constexpr size_t num_threads = 2;
+ ServerSocket f1(make_string("ipc/name:my_socket-%d", int(getpid())));
+ TimeBomb f2(60);
+ auto task = [&f1](Nexus& ctx) {
+ bool is_server = (ctx.thread_id() == 0);
+ SocketHandle socket = connect_sockets(is_server, f1);
+ verify_socket_io(is_server, socket);
+ };
+ Nexus::run(num_threads, task);
+}
+
+TEST_F(SocketTest, require_that_two_server_sockets_cannot_have_the_same_abstract_unix_domain_socket_name)
{
- bool is_server = (thread_id == 0);
- SocketHandle socket = connect_sockets(is_server, f1);
- TEST_DO(verify_socket_io(is_server, socket));
-}
-
-TEST("require that two server sockets cannot have the same abstract unix domain socket name") {
vespalib::string spec = make_string("ipc/name:my_socket-%d", int(getpid()));
ServerSocket server1(spec);
ServerSocket server2(spec);
@@ -288,7 +357,8 @@ TEST("require that two server sockets cannot have the same abstract unix domain
EXPECT_TRUE(!server2.valid());
}
-TEST("require that abstract socket names are freed when the server socket is destructed") {
+TEST_F(SocketTest, require_that_abstract_socket_names_are_freed_when_the_server_socket_is_destructed)
+{
vespalib::string spec = make_string("ipc/name:my_socket-%d", int(getpid()));
ServerSocket server1(spec);
EXPECT_TRUE(server1.valid());
@@ -297,100 +367,162 @@ TEST("require that abstract socket names are freed when the server socket is des
EXPECT_TRUE(server2.valid());
}
-TEST("require that abstract sockets do not have socket files") {
+TEST_F(SocketTest, require_that_abstract_sockets_do_not_have_socket_files)
+{
vespalib::string name = make_string("my_socket-%d", int(getpid()));
ServerSocket server(SocketSpec::from_name(name));
EXPECT_TRUE(server.valid());
EXPECT_TRUE(!is_socket(name));
- EXPECT_TRUE(!is_file(name));
+ EXPECT_TRUE(!is_file(name));
}
-TEST_MT_FFF("require that abstract and file-based unix domain sockets are not in conflict", 4,
- ServerSocket(make_string("ipc/file:my_socket-%d", int(getpid()))),
- ServerSocket(make_string("ipc/name:my_socket-%d", int(getpid()))), TimeBomb(60))
+TEST_F(SocketTest, require_that_abstract_and_file_based_unix_domain_sockets_are_not_in_conflict)
{
- bool is_server = ((thread_id % 2) == 0);
- ServerSocket &server_socket = ((thread_id / 2) == 0) ? f1 : f2;
- SocketHandle socket = connect_sockets(is_server, server_socket);
- TEST_DO(verify_socket_io(is_server, socket));
+ constexpr size_t num_threads = 4;
+ ServerSocket f1(make_string("ipc/file:my_socket-%d", int(getpid())));
+ ServerSocket f2(make_string("ipc/name:my_socket-%d", int(getpid())));
+ TimeBomb f3(60);
+ auto task = [&f1,&f2](Nexus& ctx) {
+ auto thread_id = ctx.thread_id();
+ bool is_server = ((thread_id % 2) == 0);
+ ServerSocket &server_socket = ((thread_id / 2) == 0) ? f1 : f2;
+ SocketHandle socket = connect_sockets(is_server, server_socket);
+ verify_socket_io(is_server, socket);
+ };
+ Nexus::run(num_threads, task);
}
#endif
-TEST("require that sockets can be set blocking and non-blocking") {
+TEST_F(SocketTest, require_that_sockets_can_be_set_blocking_and_non_blocking)
+{
SocketHandle handle(socket(my_inet(), SOCK_STREAM, 0));
test::SocketOptionsVerifier verifier(handle.get());
EXPECT_TRUE(!SocketOptions::set_blocking(-1, true));
EXPECT_TRUE(handle.set_blocking(true));
- TEST_DO(verifier.verify_blocking(true));
+ {
+ SCOPED_TRACE("verify blocking true");
+ verifier.verify_blocking(true);
+ }
EXPECT_TRUE(handle.set_blocking(false));
- TEST_DO(verifier.verify_blocking(false));
+ {
+ SCOPED_TRACE("verify blocking false");
+ verifier.verify_blocking(false);
+ }
}
-TEST("require that server sockets use non-blocking underlying socket") {
+TEST_F(SocketTest, require_that_server_sockets_use_non_blocking_underlying_socket)
+{
ServerSocket tcp_server("tcp/0");
ServerSocket ipc_server("ipc/file:my_socket");
test::SocketOptionsVerifier tcp_verifier(tcp_server.get_fd());
test::SocketOptionsVerifier ipc_verifier(ipc_server.get_fd());
- TEST_DO(tcp_verifier.verify_blocking(false));
- TEST_DO(ipc_verifier.verify_blocking(false));
+ {
+ SCOPED_TRACE("verify tcp nonblocking");
+ tcp_verifier.verify_blocking(false);
+ }
+ {
+ SCOPED_TRACE("verify ipc nonblocking");
+ ipc_verifier.verify_blocking(false);
+ }
}
-TEST("require that tcp nodelay can be enabled and disabled") {
+TEST_F(SocketTest, require_that_tcp_nodelay_can_be_enabled_and_disabled)
+{
SocketHandle handle(socket(my_inet(), SOCK_STREAM, 0));
test::SocketOptionsVerifier verifier(handle.get());
EXPECT_TRUE(!SocketOptions::set_nodelay(-1, true));
EXPECT_TRUE(handle.set_nodelay(true));
- TEST_DO(verifier.verify_nodelay(true));
+ {
+ SCOPED_TRACE("verify nodelay true");
+ verifier.verify_nodelay(true);
+ }
EXPECT_TRUE(handle.set_nodelay(false));
- TEST_DO(verifier.verify_nodelay(false));
+ {
+ SCOPED_TRACE("verify nodelay false");
+ verifier.verify_nodelay(false);
+ }
}
-TEST("require that reuse addr can be set and cleared") {
+TEST_F(SocketTest, require_that_reuse_addr_can_be_set_and_cleared)
+{
SocketHandle handle(socket(my_inet(), SOCK_STREAM, 0));
test::SocketOptionsVerifier verifier(handle.get());
EXPECT_TRUE(!SocketOptions::set_reuse_addr(-1, true));
EXPECT_TRUE(handle.set_reuse_addr(true));
- TEST_DO(verifier.verify_reuse_addr(true));
+ {
+ SCOPED_TRACE("verify reuse addr true");
+ verifier.verify_reuse_addr(true);
+ }
EXPECT_TRUE(handle.set_reuse_addr(false));
- TEST_DO(verifier.verify_reuse_addr(false));
+ {
+ SCOPED_TRACE("verify reuse addr false");
+ verifier.verify_reuse_addr(false);
+ }
}
-TEST("require that ipv6_only can be set and cleared") {
+TEST_F(SocketTest, require_that_ipv6_only_can_be_set_and_cleared)
+{
if (ipv6_enabled) {
SocketHandle handle(socket(my_inet(), SOCK_STREAM, 0));
test::SocketOptionsVerifier verifier(handle.get());
EXPECT_TRUE(!SocketOptions::set_ipv6_only(-1, true));
EXPECT_TRUE(handle.set_ipv6_only(true));
- TEST_DO(verifier.verify_ipv6_only(true));
+ {
+ SCOPED_TRACE("verify ipv6 only true");
+ verifier.verify_ipv6_only(true);
+ }
EXPECT_TRUE(handle.set_ipv6_only(false));
- TEST_DO(verifier.verify_ipv6_only(false));
+ {
+ SCOPED_TRACE("verify ipv6 only false");
+ verifier.verify_ipv6_only(false);
+ }
} else {
fprintf(stderr, "WARNING: skipping ipv6_only test since ipv6 is disabled");
}
}
-TEST("require that tcp keepalive can be set and cleared") {
+TEST_F(SocketTest, require_that_tcp_keepalive_can_be_set_and_cleared)
+{
SocketHandle handle(socket(my_inet(), SOCK_STREAM, 0));
test::SocketOptionsVerifier verifier(handle.get());
EXPECT_TRUE(!SocketOptions::set_keepalive(-1, true));
EXPECT_TRUE(handle.set_keepalive(true));
- TEST_DO(verifier.verify_keepalive(true));
+ {
+ SCOPED_TRACE("verify keepalive true");
+ verifier.verify_keepalive(true);
+ }
EXPECT_TRUE(handle.set_keepalive(false));
- TEST_DO(verifier.verify_keepalive(false));
+ {
+ SCOPED_TRACE("verify keepalive false");
+ verifier.verify_keepalive(false);
+ }
}
-TEST("require that tcp lingering can be adjusted") {
+TEST_F(SocketTest, require_that_tcp_lingering_can_be_adjusted)
+{
SocketHandle handle(socket(my_inet(), SOCK_STREAM, 0));
test::SocketOptionsVerifier verifier(handle.get());
EXPECT_TRUE(!SocketOptions::set_linger(-1, true, 0));
EXPECT_TRUE(handle.set_linger(true, 0));
- TEST_DO(verifier.verify_linger(true, 0));
+ {
+ SCOPED_TRACE("verify linger true 0");
+ verifier.verify_linger(true, 0);
+ }
EXPECT_TRUE(handle.set_linger(true, 10));
- TEST_DO(verifier.verify_linger(true, 10));
+ {
+ SCOPED_TRACE("verify linger true 10");
+ verifier.verify_linger(true, 10);
+ }
EXPECT_TRUE(handle.set_linger(false, 0));
- TEST_DO(verifier.verify_linger(false, 0));
+ {
+ SCOPED_TRACE("verify linger false 0");
+ verifier.verify_linger(false, 0);
+ }
EXPECT_TRUE(handle.set_linger(false, 10));
- TEST_DO(verifier.verify_linger(false, 0));
+ {
+ SCOPED_TRACE("verify linger false 0 (overridden)");
+ verifier.verify_linger(false, 0);
+ }
}
SocketHandle connect_async(const SocketAddress &addr) {
@@ -411,7 +543,10 @@ SocketHandle connect_async(const SocketAddress &addr) {
ctx.handle = addr.connect_async();
EXPECT_TRUE(ctx.handle.valid());
test::SocketOptionsVerifier verifier(ctx.handle.get());
- TEST_DO(verifier.verify_blocking(false));
+ {
+ SCOPED_TRACE("verify blocking false");
+ verifier.verify_blocking(false);
+ }
if (ctx.handle.valid()) {
selector.add(ctx.handle.get(), ctx, true, true);
while (!ctx.connect_done) {
@@ -420,23 +555,30 @@ SocketHandle connect_async(const SocketAddress &addr) {
}
selector.remove(ctx.handle.get());
}
- EXPECT_EQUAL(ctx.error, 0);
+ EXPECT_EQ(ctx.error, 0);
return std::move(ctx.handle);
}
-TEST_MT_FF("require that async connect pattern works", 2, ServerSocket("tcp/0"), TimeBomb(60)) {
- if (thread_id == 0) {
- SocketHandle socket = f1.accept();
- EXPECT_TRUE(socket.valid());
- TEST_DO(verify_socket_io(true, socket));
- } else {
- SocketAddress addr = SocketSpec::from_port(f1.address().port()).client_address();
- SocketHandle socket = connect_async(addr);
- socket.set_blocking(true);
- TEST_DO(verify_socket_io(false, socket));
- // TEST_DO(connect_async(SocketAddress::select_remote(80, "www.yahoo.com")));
- // TEST_DO(connect_async(SocketAddress::select_remote(85, "myinternalhost")));
- }
-}
-
-TEST_MAIN() { TEST_RUN_ALL(); }
+TEST_F(SocketTest, require_that_async_connect_pattern_works)
+{
+ constexpr size_t num_threads = 2;
+ ServerSocket f1("tcp/0");
+ TimeBomb f2(60);
+ auto task = [&f1](Nexus& ctx) {
+ if (ctx.thread_id() == 0) {
+ SocketHandle socket = f1.accept();
+ EXPECT_TRUE(socket.valid());
+ SCOPED_TRACE("verify socket io true");
+ verify_socket_io(true, socket);
+ } else {
+ SocketAddress addr = SocketSpec::from_port(f1.address().port()).client_address();
+ SocketHandle socket = connect_async(addr);
+ socket.set_blocking(true);
+ SCOPED_TRACE("verify socket io false");
+ verify_socket_io(false, socket);
+ }
+ };
+ Nexus::run(num_threads, task);
+}
+
+GTEST_MAIN_RUN_ALL_TESTS()
diff --git a/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/CMakeLists.txt b/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/CMakeLists.txt
index 6bbf0189862..87e13f14875 100644
--- a/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/CMakeLists.txt
+++ b/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/CMakeLists.txt
@@ -4,6 +4,7 @@ vespa_add_executable(vespalib_net_tls_auto_reloading_tls_crypto_engine_test_app
auto_reloading_tls_crypto_engine_test.cpp
DEPENDS
vespalib
+ GTest::gtest
)
vespa_add_test(NAME vespalib_net_tls_auto_reloading_tls_crypto_engine_test_app
COMMAND vespalib_net_tls_auto_reloading_tls_crypto_engine_test_app)
diff --git a/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp b/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp
index b6efb66c8bb..ed20dd6bcf4 100644
--- a/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp
+++ b/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp
@@ -1,15 +1,17 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/net/tls/auto_reloading_tls_crypto_engine.h>
#include <vespa/vespalib/net/tls/statistics.h>
#include <vespa/vespalib/net/tls/transport_security_options.h>
#include <vespa/vespalib/net/tls/transport_security_options_reading.h>
#include <vespa/vespalib/net/tls/impl/openssl_tls_context_impl.h>
-#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_path.h>
#include <vespa/vespalib/testkit/time_bomb.h>
#include <openssl/ssl.h>
#include <filesystem>
+#include <fstream>
using namespace vespalib;
using namespace vespalib::net::tls;
@@ -89,6 +91,42 @@ void write_file(vespalib::stringref path, vespalib::stringref data) {
f.write(data.data(), data.size(), 0);
}
+class AutoReloadingTlsCryptoEngineTest : public ::testing::Test
+{
+protected:
+ AutoReloadingTlsCryptoEngineTest();
+ ~AutoReloadingTlsCryptoEngineTest() override;
+ static void SetUpTestSuite();
+ static void TearDownTestSuite();
+};
+
+AutoReloadingTlsCryptoEngineTest::AutoReloadingTlsCryptoEngineTest()
+ : testing::Test()
+{
+}
+
+AutoReloadingTlsCryptoEngineTest::~AutoReloadingTlsCryptoEngineTest() = default;
+
+void
+AutoReloadingTlsCryptoEngineTest::SetUpTestSuite()
+{
+ std::ofstream test_config("test_config.json");
+ test_config << "{\n" <<
+ " \"files\":{\n" <<
+ " \"private-key\": \"" + TEST_PATH("test_key.pem") << "\",\n" <<
+ " \"ca-certificates\": \"" + TEST_PATH("test_ca.pem") << "\",\n" <<
+ " \"certificates\": \"test_cert.pem\"\n" <<
+ " }\n" <<
+ "}" << std::endl;
+ test_config.close();
+}
+
+void
+AutoReloadingTlsCryptoEngineTest::TearDownTestSuite()
+{
+ std::filesystem::remove("test_config.json");
+}
+
struct Fixture {
std::unique_ptr<AutoReloadingTlsCryptoEngine> engine;
explicit Fixture(AutoReloadingTlsCryptoEngine::TimeInterval reload_interval,
@@ -114,9 +152,13 @@ struct Fixture {
}
};
-TEST_FF("Config reloading transitively loads updated files", Fixture(50ms), TimeBomb(60)) {
+TEST_F(AutoReloadingTlsCryptoEngineTest, config_reloading_transitively_loads_updated_files)
+{
+ Fixture f1(50ms);
+ TimeBomb f2(60);
+
auto current_certs = f1.current_cert_chain();
- ASSERT_EQUAL(cert1_pem, current_certs);
+ ASSERT_EQ(cert1_pem, current_certs);
write_file("test_cert.pem.tmp", cert2_pem);
std::filesystem::rename(std::filesystem::path("test_cert.pem.tmp"), std::filesystem::path("test_cert.pem")); // We expect this to be an atomic rename under the hood
@@ -129,15 +171,25 @@ TEST_FF("Config reloading transitively loads updated files", Fixture(50ms), Time
// If the config is never reloaded, test will go boom.
}
-TEST_FF("Shutting down auto-reloading engine immediately stops background thread", Fixture(600s), TimeBomb(60)) {
+TEST_F(AutoReloadingTlsCryptoEngineTest, shutting_down_auto_reloading_engine_immediately_stops_background_thread)
+{
+ Fixture f1(600s);
+ TimeBomb f2(60);
// This passes just from not having the TimeBomb blow up.
}
-TEST_FF("Authorization mode is propagated to engine", Fixture(50ms, AuthorizationMode::LogOnly), TimeBomb(60)) {
- EXPECT_EQUAL(AuthorizationMode::LogOnly, f1.current_authorization_mode());
+TEST_F(AutoReloadingTlsCryptoEngineTest, authorization_mode_is_propagated_to_engine)
+{
+ Fixture f1(50ms, AuthorizationMode::LogOnly);
+ TimeBomb f2(60);
+ EXPECT_EQ(AuthorizationMode::LogOnly, f1.current_authorization_mode());
}
-TEST_FF("Config reload failure increments failure statistic", Fixture(50ms), TimeBomb(60)) {
+TEST_F(AutoReloadingTlsCryptoEngineTest, config_reload_failure_increments_failure_statistic)
+{
+ Fixture f1(50ms);
+ TimeBomb f2(60);
+
auto before = ConfigStatistics::get().snapshot();
write_file("test_cert.pem.tmp", "Broken file oh no :(");
@@ -148,4 +200,4 @@ TEST_FF("Config reload failure increments failure statistic", Fixture(50ms), Tim
}
}
-TEST_MAIN() { TEST_RUN_ALL(); }
+GTEST_MAIN_RUN_ALL_TESTS()
diff --git a/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/test_config.json b/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/test_config.json
deleted file mode 100644
index 2b2322d928f..00000000000
--- a/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/test_config.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "files":{
- "private-key": "test_key.pem",
- "ca-certificates": "test_ca.pem",
- "certificates": "test_cert.pem"
- }
-}
diff --git a/vespalib/src/tests/net/tls/capabilities/capabilities_test.cpp b/vespalib/src/tests/net/tls/capabilities/capabilities_test.cpp
index 4a20f907fe6..aeaff93ffe9 100644
--- a/vespalib/src/tests/net/tls/capabilities/capabilities_test.cpp
+++ b/vespalib/src/tests/net/tls/capabilities/capabilities_test.cpp
@@ -2,6 +2,7 @@
#include <vespa/vespalib/net/tls/capability_set.h>
#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
using namespace vespalib;
using namespace vespalib::net::tls;
diff --git a/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp b/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp
index 6d5c5fa6308..0912afde250 100644
--- a/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp
+++ b/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp
@@ -1,7 +1,6 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/crypto/private_key.h>
#include <vespa/vespalib/crypto/x509_certificate.h>
-#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/data/smart_buffer.h>
#include <vespa/vespalib/net/tls/authorization_mode.h>
#include <vespa/vespalib/net/tls/crypto_codec.h>
@@ -14,7 +13,8 @@
#include <vespa/vespalib/test/peer_policy_utils.h>
#include <vespa/vespalib/util/size_literals.h>
#include <stdexcept>
-#include <stdlib.h>
+#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
using namespace vespalib;
using namespace vespalib::crypto;
diff --git a/vespalib/src/tests/net/tls/policy_checking_certificate_verifier/policy_checking_certificate_verifier_test.cpp b/vespalib/src/tests/net/tls/policy_checking_certificate_verifier/policy_checking_certificate_verifier_test.cpp
index 26db06e35f1..b80151e9ccf 100644
--- a/vespalib/src/tests/net/tls/policy_checking_certificate_verifier/policy_checking_certificate_verifier_test.cpp
+++ b/vespalib/src/tests/net/tls/policy_checking_certificate_verifier/policy_checking_certificate_verifier_test.cpp
@@ -3,6 +3,7 @@
#include <vespa/vespalib/net/tls/policy_checking_certificate_verifier.h>
#include <vespa/vespalib/test/peer_policy_utils.h>
#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
using namespace vespalib;
using namespace vespalib::net::tls;
diff --git a/vespalib/src/tests/net/tls/protocol_snooping/protocol_snooping_test.cpp b/vespalib/src/tests/net/tls/protocol_snooping/protocol_snooping_test.cpp
index 01e6113064a..a5fe850d85d 100644
--- a/vespalib/src/tests/net/tls/protocol_snooping/protocol_snooping_test.cpp
+++ b/vespalib/src/tests/net/tls/protocol_snooping/protocol_snooping_test.cpp
@@ -1,5 +1,6 @@
// Copyright Vespa.ai. 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/test_master.hpp>
#include <vespa/vespalib/net/tls/protocol_snooping.h>
using namespace vespalib;
diff --git a/vespalib/src/tests/net/tls/transport_options/CMakeLists.txt b/vespalib/src/tests/net/tls/transport_options/CMakeLists.txt
index 3623912bb42..2013879569f 100644
--- a/vespalib/src/tests/net/tls/transport_options/CMakeLists.txt
+++ b/vespalib/src/tests/net/tls/transport_options/CMakeLists.txt
@@ -4,6 +4,7 @@ vespa_add_executable(vespalib_net_tls_transport_options_test_app TEST
transport_options_reading_test.cpp
DEPENDS
vespalib
+ GTest::gtest
)
vespa_add_test(NAME vespalib_net_tls_transport_options_test_app
COMMAND vespalib_net_tls_transport_options_test_app)
diff --git a/vespalib/src/tests/net/tls/transport_options/ok_config.json b/vespalib/src/tests/net/tls/transport_options/ok_config.json
deleted file mode 100644
index dd2591661dc..00000000000
--- a/vespalib/src/tests/net/tls/transport_options/ok_config.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "files":{
- "private-key": "dummy_privkey.txt",
- "ca-certificates": "dummy_ca_certs.txt",
- "certificates": "dummy_certs.txt"
- }
-}
diff --git a/vespalib/src/tests/net/tls/transport_options/transport_options_reading_test.cpp b/vespalib/src/tests/net/tls/transport_options/transport_options_reading_test.cpp
index ef0fdac0495..ea499607685 100644
--- a/vespalib/src/tests/net/tls/transport_options/transport_options_reading_test.cpp
+++ b/vespalib/src/tests/net/tls/transport_options/transport_options_reading_test.cpp
@@ -1,113 +1,245 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/net/tls/transport_security_options.h>
#include <vespa/vespalib/net/tls/transport_security_options_reading.h>
#include <vespa/vespalib/test/peer_policy_utils.h>
-#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_path.h>
#include <vespa/vespalib/util/exceptions.h>
+#include <gmock/gmock.h>
+#include <filesystem>
+#include <fstream>
+#include <optional>
+#include <sstream>
using namespace vespalib;
using namespace vespalib::net::tls;
-TEST("can load TLS credentials via config file") {
+namespace {
+
+class ConfigWriter {
+ std::optional<std::string> _private_key;
+ std::optional<std::string> _ca_certificates;
+ std::optional<std::string> _certificates;
+ std::optional<std::string> _accepted_ciphers;
+ std::optional<std::string> _authorized_peers;
+ std::optional<std::string> _disable_hostname_validation;
+ std::optional<std::string> _flipper_the_dolphin;
+public:
+ ConfigWriter();
+ ConfigWriter(ConfigWriter&&);
+ ~ConfigWriter();
+ ConfigWriter private_key(std::optional<std::string> value) && { _private_key = value; return std::move(*this); }
+ ConfigWriter ca_certificates(std::optional<std::string> value) && { _ca_certificates = value; return std::move(*this); }
+ ConfigWriter certificates(std::optional<std::string> value) && { _certificates = value; return std::move(*this); }
+ ConfigWriter accepted_ciphers(std::optional<std::string> value) && { _accepted_ciphers = value; return std::move(*this); }
+ ConfigWriter authorized_peers(std::optional<std::string> value) && { _authorized_peers = value; return std::move(*this); }
+ ConfigWriter disable_hostname_validation(std::optional<std::string> value) && { _disable_hostname_validation = value; return std::move(*this); }
+ ConfigWriter flipper_the_dolphin(std::optional<std::string> value) && { _flipper_the_dolphin = value; return std::move(*this); }
+ void write(std::ostream& os);
+ std::string write();
+};
+
+ConfigWriter::ConfigWriter()
+ : _private_key(TEST_PATH("dummy_privkey.txt")),
+ _ca_certificates(TEST_PATH("dummy_ca_certs.txt")),
+ _certificates(TEST_PATH("dummy_certs.txt")),
+ _accepted_ciphers(),
+ _authorized_peers(),
+ _disable_hostname_validation(),
+ _flipper_the_dolphin()
+{
+}
+
+ConfigWriter::ConfigWriter(ConfigWriter&&) = default;
+
+ConfigWriter::~ConfigWriter() = default;
+
+void
+ConfigWriter::write(std::ostream& os)
+{
+ os << "{\n" <<
+ R"( "files": {)";
+ bool had_files_entry = false;
+ if (_private_key.has_value()) {
+ os << "\n" << R"( "private-key": ")" << _private_key.value() << R"(")";
+ had_files_entry = true;
+ }
+ if (_ca_certificates.has_value()) {
+ if (had_files_entry) {
+ os << ",";
+ }
+ os << "\n" << R"( "ca-certificates": ")" << _ca_certificates.value() << R"(")";
+ had_files_entry = true;
+ }
+ if (_certificates.has_value()) {
+ if (had_files_entry) {
+ os << ",";
+ }
+ os << "\n" << R"( "certificates": ")" << _certificates.value() << R"(")";
+ had_files_entry = true;
+ }
+ os << "\n }";
+ if (_accepted_ciphers.has_value()) {
+ os << ",\n" << R"( "accepted-ciphers" : )" << _accepted_ciphers.value();
+ }
+ if (_authorized_peers.has_value()) {
+ os << ",\n" << R"( "authorized-peers": )" << _authorized_peers.value();
+ }
+ if (_disable_hostname_validation.has_value()) {
+ os << ",\n" << R"( "disable-hostname-validation": )" << _disable_hostname_validation.value();
+ }
+ if (_flipper_the_dolphin.has_value()) {
+ os << ",\n" << R"( "flipper-the-dolphin": )" << _flipper_the_dolphin.value();
+ }
+ os << "\n}" << std::endl;
+}
+
+std::string
+ConfigWriter::write()
+{
+ std::ostringstream os;
+ write(os);
+ return os.str();
+}
+
+}
+
+class TransportSecurityOptionsTest : public ::testing::Test {
+protected:
+ TransportSecurityOptionsTest();
+ ~TransportSecurityOptionsTest() override;
+ static void SetUpTestSuite();
+ static void TearDownTestSuite();
+};
+
+TransportSecurityOptionsTest::TransportSecurityOptionsTest()
+ : ::testing::Test()
+{
+}
+
+TransportSecurityOptionsTest::~TransportSecurityOptionsTest() = default;
+
+void
+TransportSecurityOptionsTest::SetUpTestSuite()
+{
+ std::ofstream ok_config("ok_config.json");
+ ConfigWriter().write(ok_config);
+ ok_config.close();
+}
+
+void
+TransportSecurityOptionsTest::TearDownTestSuite()
+{
+ std::filesystem::remove("ok_config.json");
+}
+
+TEST_F(TransportSecurityOptionsTest, can_load_tls_credentials_via_config_file)
+{
auto opts = read_options_from_json_file("ok_config.json");
ASSERT_TRUE(opts.get() != nullptr);
// Obviously we'd need to change this to actual PEM data if config reading started
// actually verifying the _content_ of files, not just reading them.
- EXPECT_EQUAL("My private key\n", opts->private_key_pem());
- EXPECT_EQUAL("My CA certificates\n", opts->ca_certs_pem());
- EXPECT_EQUAL("My certificate chain\n", opts->cert_chain_pem());
+ EXPECT_EQ("My private key\n", opts->private_key_pem());
+ EXPECT_EQ("My CA certificates\n", opts->ca_certs_pem());
+ EXPECT_EQ("My certificate chain\n", opts->cert_chain_pem());
}
-TEST("copying options without private key does, in fact, not include private key") {
+TEST_F(TransportSecurityOptionsTest, copying_options_without_private_key_does_in_fact_not_include_private_key)
+{
auto opts = read_options_from_json_file("ok_config.json");
auto cloned = opts->copy_without_private_key();
- EXPECT_EQUAL("", cloned.private_key_pem());
- EXPECT_EQUAL("My CA certificates\n", cloned.ca_certs_pem());
- EXPECT_EQUAL("My certificate chain\n", cloned.cert_chain_pem());
+ EXPECT_EQ("", cloned.private_key_pem());
+ EXPECT_EQ("My CA certificates\n", cloned.ca_certs_pem());
+ EXPECT_EQ("My certificate chain\n", cloned.cert_chain_pem());
}
-TEST("missing JSON file throws exception") {
- EXPECT_EXCEPTION(read_options_from_json_file("missing_config.json"), IllegalArgumentException,
- "TLS config file 'missing_config.json' could not be read");
+TEST_F(TransportSecurityOptionsTest, missing_json_file_throws_exception)
+{
+ EXPECT_THAT([]() { read_options_from_json_file("missing_config.json"); },
+ testing::ThrowsMessage<IllegalArgumentException>(testing::HasSubstr("TLS config file 'missing_config.json' could not be read")));
}
-TEST("bad JSON content throws exception") {
+TEST_F(TransportSecurityOptionsTest, bad_json_content_throws_exception)
+{
const char* bad_json = "hello world :D";
- EXPECT_EXCEPTION(read_options_from_json_string(bad_json), IllegalArgumentException,
- "Provided TLS config file is not valid JSON");
+ EXPECT_THAT([bad_json]() { read_options_from_json_string(bad_json); },
+ testing::ThrowsMessage<IllegalArgumentException>(testing::HasSubstr("Provided TLS config file is not valid JSON")));
}
-TEST("missing 'files' field throws exception") {
+TEST_F(TransportSecurityOptionsTest, missing_files_field_throws_exception)
+{
const char* incomplete_json = R"({})";
- EXPECT_EXCEPTION(read_options_from_json_string(incomplete_json), IllegalArgumentException,
- "TLS config root field 'files' is missing or empty");
+ EXPECT_THAT([incomplete_json]() { read_options_from_json_string(incomplete_json); },
+ testing::ThrowsMessage<IllegalArgumentException>(testing::HasSubstr("TLS config root field 'files' is missing or empty")));
}
-TEST("missing 'private-key' field throws exception") {
- const char* incomplete_json = R"({"files":{"certificates":"dummy_certs.txt","ca-certificates":"dummy_ca_certs.txt"}})";
- EXPECT_EXCEPTION(read_options_from_json_string(incomplete_json), IllegalArgumentException,
- "TLS config field 'private-key' has not been set");
+TEST_F(TransportSecurityOptionsTest, missing_private_key_field_throws_exception)
+{
+ auto incomplete_json = ConfigWriter().private_key(std::nullopt).write();
+ EXPECT_THAT([incomplete_json]() { read_options_from_json_string(incomplete_json); },
+ testing::ThrowsMessage<IllegalArgumentException>(testing::HasSubstr("TLS config field 'private-key' has not been set")));
}
-TEST("missing 'certificates' field throws exception") {
- const char* incomplete_json = R"({"files":{"private-key":"dummy_privkey.txt","ca-certificates":"dummy_ca_certs.txt"}})";
- EXPECT_EXCEPTION(read_options_from_json_string(incomplete_json), IllegalArgumentException,
- "TLS config field 'certificates' has not been set");
+TEST_F(TransportSecurityOptionsTest, missing_certificates_field_throws_exception)
+{
+ auto incomplete_json = ConfigWriter().certificates(std::nullopt).write();
+ EXPECT_THAT([incomplete_json]() { read_options_from_json_string(incomplete_json); },
+ testing::ThrowsMessage<IllegalArgumentException>(testing::HasSubstr("TLS config field 'certificates' has not been set")));
}
-TEST("missing 'ca-certificates' field throws exception") {
- const char* incomplete_json = R"({"files":{"private-key":"dummy_privkey.txt","certificates":"dummy_certs.txt"}})";
- EXPECT_EXCEPTION(read_options_from_json_string(incomplete_json), IllegalArgumentException,
- "TLS config field 'ca-certificates' has not been set");
+TEST_F(TransportSecurityOptionsTest, missing_ca_certificates_field_throws_exception)
+{
+ auto incomplete_json = ConfigWriter().ca_certificates(std::nullopt).write();
+ EXPECT_THAT([incomplete_json]() { read_options_from_json_string(incomplete_json); },
+ testing::ThrowsMessage<IllegalArgumentException>(testing::HasSubstr("TLS config field 'ca-certificates' has not been set")));
}
-TEST("missing file referenced by field throws exception") {
- const char* incomplete_json = R"({"files":{"private-key":"missing_privkey.txt",
- "certificates":"dummy_certs.txt",
- "ca-certificates":"dummy_ca_certs.txt"}})";
- EXPECT_EXCEPTION(read_options_from_json_string(incomplete_json), IllegalArgumentException,
- "File 'missing_privkey.txt' referenced by TLS config does not exist");
+TEST_F(TransportSecurityOptionsTest, missing_file_referenced_by_field_throws_exception)
+{
+ auto incomplete_json = ConfigWriter().private_key("missing_privkey.txt").write();
+ EXPECT_THAT([incomplete_json]() { read_options_from_json_string(incomplete_json); },
+ testing::ThrowsMessage<IllegalArgumentException>(testing::HasSubstr("File 'missing_privkey.txt' referenced by TLS config does not exist")));
}
vespalib::string json_with_policies(const vespalib::string& policies) {
- const char* fmt = R"({"files":{"private-key":"dummy_privkey.txt",
- "certificates":"dummy_certs.txt",
- "ca-certificates":"dummy_ca_certs.txt"},
- "authorized-peers":[%s]})";
- return vespalib::make_string(fmt, policies.c_str());
+ return ConfigWriter().authorized_peers(std::string("[") + policies + "]").write();
}
-TransportSecurityOptions parse_policies(const vespalib::string& policies) {
+TransportSecurityOptions parse_policies(const vespalib::string& policies)
+{
return *read_options_from_json_string(json_with_policies(policies));
}
-TEST("config file without authorized-peers accepts all pre-verified certificates") {
- const char* json = R"({"files":{"private-key":"dummy_privkey.txt",
- "certificates":"dummy_certs.txt",
- "ca-certificates":"dummy_ca_certs.txt"}})";
+TEST_F(TransportSecurityOptionsTest, config_file_without_authorized_peers_accepts_all_pre_verified_certificates)
+{
+ auto json = ConfigWriter().write();
EXPECT_TRUE(read_options_from_json_string(json)->authorized_peers().allows_all_authenticated());
}
// Instead of contemplating what the semantics of an empty allow list should be,
// we do the easy way out and just say it's not allowed in the first place.
-TEST("empty policy array throws exception") {
- EXPECT_EXCEPTION(parse_policies(""), vespalib::IllegalArgumentException,
- "\"authorized-peers\" must either be not present (allows "
- "all peers with valid certificates) or a non-empty array");
+TEST_F(TransportSecurityOptionsTest, empty_policy_array_throws_exception)
+{
+ EXPECT_THAT([]() { parse_policies(""); },
+ testing::ThrowsMessage<IllegalArgumentException>(testing::HasSubstr("\"authorized-peers\" must either be not present (allows "
+ "all peers with valid certificates) or a non-empty array")));
}
-TEST("can parse single peer policy with single requirement") {
+TEST_F(TransportSecurityOptionsTest, can_parse_single_peer_policy_with_single_requirement)
+{
const char* json = R"({
"required-credentials":[
{"field": "SAN_DNS", "must-match": "hello.world"}
]
})";
- EXPECT_EQUAL(authorized_peers({policy_with({required_san_dns("hello.world")})}),
- parse_policies(json).authorized_peers());
+ EXPECT_EQ(authorized_peers({policy_with({required_san_dns("hello.world")})}),
+ parse_policies(json).authorized_peers());
}
-TEST("can parse single peer policy with multiple requirements") {
+TEST_F(TransportSecurityOptionsTest, can_parse_single_peer_policy_with_multiple_requirements)
+{
const char* json = R"({
"required-credentials":[
{"field": "SAN_DNS", "must-match": "hello.world"},
@@ -115,57 +247,56 @@ TEST("can parse single peer policy with multiple requirements") {
{"field": "CN", "must-match": "goodbye.moon"}
]
})";
- EXPECT_EQUAL(authorized_peers({policy_with({required_san_dns("hello.world"),
- required_san_uri("foo://bar/baz"),
- required_cn("goodbye.moon")})}),
- parse_policies(json).authorized_peers());
+ EXPECT_EQ(authorized_peers({policy_with({required_san_dns("hello.world"),
+ required_san_uri("foo://bar/baz"),
+ required_cn("goodbye.moon")})}),
+ parse_policies(json).authorized_peers());
}
-TEST("unknown field type throws exception") {
+TEST_F(TransportSecurityOptionsTest, unknown_field_type_throws_exception)
+{
const char* json = R"({
"required-credentials":[
{"field": "winnie the pooh", "must-match": "piglet"}
]
})";
- EXPECT_EXCEPTION(parse_policies(json), vespalib::IllegalArgumentException,
- "Unsupported credential field type: 'winnie the pooh'. Supported are: CN, SAN_DNS");
+ EXPECT_THAT([json]() { parse_policies(json); },
+ testing::ThrowsMessage<IllegalArgumentException>(testing::HasSubstr("Unsupported credential field type: 'winnie the pooh'. Supported are: CN, SAN_DNS")));
}
-TEST("empty required-credentials array throws exception") {
+TEST_F(TransportSecurityOptionsTest, empty_required_credentials_array_throws_exception)
+{
const char* json = R"({
"required-credentials":[]
})";
- EXPECT_EXCEPTION(parse_policies(json), vespalib::IllegalArgumentException,
- "\"required-credentials\" array can't be empty (would allow all peers)");
+ EXPECT_THAT([json]() { parse_policies(json); },
+ testing::ThrowsMessage<IllegalArgumentException>(testing::HasSubstr("\"required-credentials\" array can't be empty (would allow all peers)")));
}
-TEST("accepted cipher list is empty if not specified") {
- const char* json = R"({"files":{"private-key":"dummy_privkey.txt",
- "certificates":"dummy_certs.txt",
- "ca-certificates":"dummy_ca_certs.txt"}})";
+TEST_F(TransportSecurityOptionsTest, accepted_cipher_list_is_empty_if_not_specified)
+{
+ auto json = ConfigWriter().write();
EXPECT_TRUE(read_options_from_json_string(json)->accepted_ciphers().empty());
}
-TEST("accepted cipher list is populated if specified") {
- const char* json = R"({"files":{"private-key":"dummy_privkey.txt",
- "certificates":"dummy_certs.txt",
- "ca-certificates":"dummy_ca_certs.txt"},
- "accepted-ciphers":["foo", "bar"]})";
+TEST_F(TransportSecurityOptionsTest, accepted_cipher_list_is_populated_if_specified)
+{
+ auto json = ConfigWriter().accepted_ciphers(R"(["foo", "bar"])").write();
auto ciphers = read_options_from_json_string(json)->accepted_ciphers();
- ASSERT_EQUAL(2u, ciphers.size());
- EXPECT_EQUAL("foo", ciphers[0]);
- EXPECT_EQUAL("bar", ciphers[1]);
+ ASSERT_EQ(2u, ciphers.size());
+ EXPECT_EQ("foo", ciphers[0]);
+ EXPECT_EQ("bar", ciphers[1]);
}
// FIXME this is temporary until we know enabling it by default won't break the world!
-TEST("hostname validation is DISABLED by default when creating options from config file") {
- const char* json = R"({"files":{"private-key":"dummy_privkey.txt",
- "certificates":"dummy_certs.txt",
- "ca-certificates":"dummy_ca_certs.txt"}})";
+TEST_F(TransportSecurityOptionsTest, hostname_validation_is_DISABLED_by_default_when_creating_options_from_config_file)
+{
+ auto json = ConfigWriter().write();
EXPECT_TRUE(read_options_from_json_string(json)->disable_hostname_validation());
}
-TEST("TransportSecurityOptions builder does not disable hostname validation by default") {
+TEST_F(TransportSecurityOptionsTest, transport_security_options_builder_does_not_disable_hostname_validation_by_default)
+{
auto ts_builder = vespalib::net::tls::TransportSecurityOptions::Params().
ca_certs_pem("foo").
cert_chain_pem("bar").
@@ -174,67 +305,65 @@ TEST("TransportSecurityOptions builder does not disable hostname validation by d
EXPECT_FALSE(ts_opts.disable_hostname_validation());
}
-TEST("hostname validation can be explicitly disabled") {
- const char* json = R"({"files":{"private-key":"dummy_privkey.txt",
- "certificates":"dummy_certs.txt",
- "ca-certificates":"dummy_ca_certs.txt"},
- "disable-hostname-validation": true})";
+TEST_F(TransportSecurityOptionsTest, hostname_validation_can_be_explicitly_disabled)
+{
+ auto json = ConfigWriter().disable_hostname_validation("true").write();
EXPECT_TRUE(read_options_from_json_string(json)->disable_hostname_validation());
}
-TEST("hostname validation can be explicitly enabled") {
- const char* json = R"({"files":{"private-key":"dummy_privkey.txt",
- "certificates":"dummy_certs.txt",
- "ca-certificates":"dummy_ca_certs.txt"},
- "disable-hostname-validation": false})";
+TEST_F(TransportSecurityOptionsTest, hostname_validation_can_be_explicitly_enabled)
+{
+ auto json = ConfigWriter().disable_hostname_validation("false").write();
EXPECT_FALSE(read_options_from_json_string(json)->disable_hostname_validation());
}
-TEST("unknown fields are ignored at parse-time") {
- const char* json = R"({"files":{"private-key":"dummy_privkey.txt",
- "certificates":"dummy_certs.txt",
- "ca-certificates":"dummy_ca_certs.txt"},
- "flipper-the-dolphin": "*weird dolphin noises*"})";
+TEST_F(TransportSecurityOptionsTest, unknown_fields_are_ignored_at_parse_time)
+{
+ auto json = ConfigWriter().flipper_the_dolphin(R"("*weird dolphin noises*")").write();
EXPECT_TRUE(read_options_from_json_string(json).get() != nullptr); // And no exception thrown.
}
-TEST("policy without explicit capabilities implicitly get all capabilities") {
+TEST_F(TransportSecurityOptionsTest, policy_without_explicit_capabilities_implicitly_get_all_capabilities)
+{
const char* json = R"({
"required-credentials":[
{"field": "SAN_DNS", "must-match": "hello.world"}
]
})";
- EXPECT_EQUAL(authorized_peers({policy_with({required_san_dns("hello.world")},
- CapabilitySet::make_with_all_capabilities())}),
- parse_policies(json).authorized_peers());
+ EXPECT_EQ(authorized_peers({policy_with({required_san_dns("hello.world")},
+ CapabilitySet::make_with_all_capabilities())}),
+ parse_policies(json).authorized_peers());
}
-TEST("specifying a capability set adds all its underlying capabilities") {
+TEST_F(TransportSecurityOptionsTest, specifying_a_capability_set_adds_all_its_underlying_capabilities)
+{
const char* json = R"({
"required-credentials":[
{"field": "SAN_DNS", "must-match": "*.cool-content-clusters.example" }
],
"capabilities": ["vespa.content_node"]
})";
- EXPECT_EQUAL(authorized_peers({policy_with({required_san_dns("*.cool-content-clusters.example")},
- CapabilitySet::content_node())}),
- parse_policies(json).authorized_peers());
+ EXPECT_EQ(authorized_peers({policy_with({required_san_dns("*.cool-content-clusters.example")},
+ CapabilitySet::content_node())}),
+ parse_policies(json).authorized_peers());
}
-TEST("can specify single leaf capabilities") {
+TEST_F(TransportSecurityOptionsTest, can_specify_single_leaf_capabilities)
+{
const char* json = R"({
"required-credentials":[
{"field": "SAN_DNS", "must-match": "*.cool-content-clusters.example" }
],
"capabilities": ["vespa.content.metrics_api", "vespa.slobrok.api"]
})";
- EXPECT_EQUAL(authorized_peers({policy_with({required_san_dns("*.cool-content-clusters.example")},
- CapabilitySet::of({Capability::content_metrics_api(),
- Capability::slobrok_api()}))}),
- parse_policies(json).authorized_peers());
+ EXPECT_EQ(authorized_peers({policy_with({required_san_dns("*.cool-content-clusters.example")},
+ CapabilitySet::of({Capability::content_metrics_api(),
+ Capability::slobrok_api()}))}),
+ parse_policies(json).authorized_peers());
}
-TEST("specifying multiple capability sets adds union of underlying capabilities") {
+TEST_F(TransportSecurityOptionsTest, specifying_multiple_capability_sets_adds_union_of_underlying_capabilities)
+{
const char* json = R"({
"required-credentials":[
{"field": "SAN_DNS", "must-match": "*.cool-content-clusters.example" }
@@ -244,23 +373,22 @@ TEST("specifying multiple capability sets adds union of underlying capabilities"
CapabilitySet caps;
caps.add_all(CapabilitySet::content_node());
caps.add_all(CapabilitySet::container_node());
- EXPECT_EQUAL(authorized_peers({policy_with({required_san_dns("*.cool-content-clusters.example")}, caps)}),
- parse_policies(json).authorized_peers());
+ EXPECT_EQ(authorized_peers({policy_with({required_san_dns("*.cool-content-clusters.example")}, caps)}),
+ parse_policies(json).authorized_peers());
}
-TEST("empty capabilities array is not allowed") {
+TEST_F(TransportSecurityOptionsTest, empty_capabilities_array_is_not_allowed) {
const char* json = R"({
"required-credentials":[
{"field": "SAN_DNS", "must-match": "*.cool-content-clusters.example" }
],
"capabilities": []
})";
- EXPECT_EXCEPTION(parse_policies(json), vespalib::IllegalArgumentException,
- "\"capabilities\" array must either be not present (implies "
- "all capabilities) or contain at least one capability name");
+ EXPECT_THAT([json]() { parse_policies(json); },
+ testing::ThrowsMessage<IllegalArgumentException>(testing::HasSubstr("\"capabilities\" array must either be not present (implies "
+ "all capabilities) or contain at least one capability name")));
}
// TODO test parsing of multiple policies
-TEST_MAIN() { TEST_RUN_ALL(); }
-
+GTEST_MAIN_RUN_ALL_TESTS()
diff --git a/vespalib/src/tests/objects/nbostream/nbostream_test.cpp b/vespalib/src/tests/objects/nbostream/nbostream_test.cpp
index a2501b836ce..91c83656353 100644
--- a/vespalib/src/tests/objects/nbostream/nbostream_test.cpp
+++ b/vespalib/src/tests/objects/nbostream/nbostream_test.cpp
@@ -1,6 +1,7 @@
// Copyright Vespa.ai. 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/test_master.hpp>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/objects/hexdump.h>
#include <vespa/vespalib/test/insertion_operators.h>
diff --git a/vespalib/src/tests/objects/objectdump/objectdump.cpp b/vespalib/src/tests/objects/objectdump/objectdump.cpp
index a54f14a0185..f2f4920c37b 100644
--- a/vespalib/src/tests/objects/objectdump/objectdump.cpp
+++ b/vespalib/src/tests/objects/objectdump/objectdump.cpp
@@ -1,6 +1,6 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/objects/identifiable.h>
#include <vespa/vespalib/objects/visit.hpp>
@@ -103,13 +103,9 @@ Foo::visitMembers(ObjectVisitor &v) const {
IMPLEMENT_IDENTIFIABLE(Foo, Base);
-TEST_SETUP(Test);
-
-int
-Test::Main()
-{
- TEST_INIT("objectdump_test");
+TEST("objectdump_test") {
Foo foo;
fprintf(stderr, "%s", foo.asString().c_str());
- TEST_DONE();
}
+
+TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/tests/objects/objectselection/objectselection.cpp b/vespalib/src/tests/objects/objectselection/objectselection.cpp
index e1de71a7329..f6706463ae5 100644
--- a/vespalib/src/tests/objects/objectselection/objectselection.cpp
+++ b/vespalib/src/tests/objects/objectselection/objectselection.cpp
@@ -1,6 +1,6 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/objects/identifiable.hpp>
#include <vespa/vespalib/objects/objectpredicate.h>
#include <vespa/vespalib/objects/objectoperation.h>
@@ -56,12 +56,7 @@ struct ObjectCollect : public ObjectOperation
ObjectCollect::~ObjectCollect() = default;
-TEST_SETUP(Test);
-
-int
-Test::Main()
-{
- TEST_INIT("objectselection_test");
+TEST("objectselection_test") {
{
Foo f1;
Foo f2;
@@ -90,5 +85,6 @@ Test::Main()
ASSERT_TRUE(((Bar*)operation.nodes[2])->value == 3);
ASSERT_TRUE(((Bar*)operation.nodes[3])->value == 4);
}
- TEST_DONE();
}
+
+TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp b/vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp
index 212ea417524..58027e35601 100644
--- a/vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp
+++ b/vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp
@@ -1,7 +1,9 @@
// Copyright Vespa.ai. 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/test_master.hpp>
#include <vespa/vespalib/util/polymorphicarrays.h>
+#include <cassert>
using namespace vespalib;
diff --git a/vespalib/src/tests/priority_queue/priority_queue_test.cpp b/vespalib/src/tests/priority_queue/priority_queue_test.cpp
index ae85dcfa47a..0f422cacb6d 100644
--- a/vespalib/src/tests/priority_queue/priority_queue_test.cpp
+++ b/vespalib/src/tests/priority_queue/priority_queue_test.cpp
@@ -1,7 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/log/log.h>
LOG_SETUP("priority_queue_test");
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/priority_queue.h>
using namespace vespalib;
diff --git a/vespalib/src/tests/rendezvous/rendezvous_test.cpp b/vespalib/src/tests/rendezvous/rendezvous_test.cpp
index d2e2ac2fbab..13c4f968db1 100644
--- a/vespalib/src/tests/rendezvous/rendezvous_test.cpp
+++ b/vespalib/src/tests/rendezvous/rendezvous_test.cpp
@@ -2,6 +2,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/rendezvous.h>
#include <vespa/vespalib/util/time.h>
+#include <vespa/vespalib/util/count_down_latch.h>
#include <utility>
#include <thread>
diff --git a/vespalib/src/tests/rusage/rusage_test.cpp b/vespalib/src/tests/rusage/rusage_test.cpp
index 5c08c99de43..28d3db72099 100644
--- a/vespalib/src/tests/rusage/rusage_test.cpp
+++ b/vespalib/src/tests/rusage/rusage_test.cpp
@@ -1,6 +1,6 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/util/rusage.h>
using namespace vespalib;
diff --git a/vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp b/vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp
index 66f155f679b..ef13421a6ec 100644
--- a/vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp
+++ b/vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp
@@ -1,8 +1,9 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/util/adaptive_sequenced_executor.h>
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/test/insertion_operators.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
#include <condition_variable>
#include <unistd.h>
diff --git a/vespalib/src/tests/sequencedtaskexecutor/foregroundtaskexecutor_test.cpp b/vespalib/src/tests/sequencedtaskexecutor/foregroundtaskexecutor_test.cpp
index eb71709ae43..d899b8b4a2c 100644
--- a/vespalib/src/tests/sequencedtaskexecutor/foregroundtaskexecutor_test.cpp
+++ b/vespalib/src/tests/sequencedtaskexecutor/foregroundtaskexecutor_test.cpp
@@ -1,7 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/util/foregroundtaskexecutor.h>
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
#include <condition_variable>
#include <unistd.h>
diff --git a/vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp b/vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp
index 96cc23ef70e..beed490c214 100644
--- a/vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp
+++ b/vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp
@@ -4,8 +4,9 @@
#include <vespa/vespalib/util/adaptive_sequenced_executor.h>
#include <vespa/vespalib/util/blockingthreadstackexecutor.h>
#include <vespa/vespalib/util/singleexecutor.h>
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/test/insertion_operators.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
#include <condition_variable>
#include <unistd.h>
diff --git a/vespalib/src/tests/sha1/sha1_test.cpp b/vespalib/src/tests/sha1/sha1_test.cpp
index d7777189074..df7dc423b00 100644
--- a/vespalib/src/tests/sha1/sha1_test.cpp
+++ b/vespalib/src/tests/sha1/sha1_test.cpp
@@ -1,7 +1,8 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/vespalib/testkit/test_kit.h>
#include "rfc_sha1.h"
+#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
#include <vespa/vespalib/util/sha1.h>
#include <vespa/vespalib/stllike/string.h>
diff --git a/vespalib/src/tests/shared_operation_throttler/shared_operation_throttler_test.cpp b/vespalib/src/tests/shared_operation_throttler/shared_operation_throttler_test.cpp
index 0f1c6d3a083..18613c0bc79 100644
--- a/vespalib/src/tests/shared_operation_throttler/shared_operation_throttler_test.cpp
+++ b/vespalib/src/tests/shared_operation_throttler/shared_operation_throttler_test.cpp
@@ -3,6 +3,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/barrier.h>
#include <thread>
+#include <cassert>
using vespalib::steady_clock;
diff --git a/vespalib/src/tests/shutdownguard/shutdownguard_test.cpp b/vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
index 3e0935e85e0..6376386096e 100644
--- a/vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
+++ b/vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
@@ -1,5 +1,5 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/util/shutdownguard.h>
#include <vespa/vespalib/util/malloc_mmap_guard.h>
#include <thread>
diff --git a/vespalib/src/tests/singleexecutor/singleexecutor_test.cpp b/vespalib/src/tests/singleexecutor/singleexecutor_test.cpp
index 3ae0b709e31..e20b42601c5 100644
--- a/vespalib/src/tests/singleexecutor/singleexecutor_test.cpp
+++ b/vespalib/src/tests/singleexecutor/singleexecutor_test.cpp
@@ -1,6 +1,6 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/util/singleexecutor.h>
#include <vespa/vespalib/util/lambdatask.h>
@@ -82,7 +82,7 @@ void verifyResizeTaskLimit(bool up) {
EXPECT_EQUAL(1u, started);
executor.setTaskLimit(targetTaskLimit);
EXPECT_EQUAL(INITIAL_2inN, executor.getTaskLimit());
- EXPECT_EQUAL(INITIAL_2inN*waterMarkRatio, executor.get_watermark());
+ EXPECT_EQUAL(INITIAL_2inN*waterMarkRatio, static_cast<double>(executor.get_watermark()));
allowed = 5;
while (started < 6);
EXPECT_EQUAL(6u, started);
@@ -101,7 +101,7 @@ void verifyResizeTaskLimit(bool up) {
while (started < INITIAL + 1);
EXPECT_EQUAL(INITIAL + 1, started);
EXPECT_EQUAL(roundedTaskLimit, executor.getTaskLimit());
- EXPECT_EQUAL(roundedTaskLimit*waterMarkRatio, executor.get_watermark());
+ EXPECT_EQUAL(roundedTaskLimit*waterMarkRatio, static_cast<double>(executor.get_watermark()));
allowed = INITIAL + 1;
}
diff --git a/vespalib/src/tests/slime/json_slime_benchmark.cpp b/vespalib/src/tests/slime/json_slime_benchmark.cpp
index 78000a5a25d..df9492ba46c 100644
--- a/vespalib/src/tests/slime/json_slime_benchmark.cpp
+++ b/vespalib/src/tests/slime/json_slime_benchmark.cpp
@@ -4,6 +4,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <iostream>
#include <fstream>
+#include <cassert>
using namespace vespalib::slime::convenience;
diff --git a/vespalib/src/tests/slime/slime_binary_format_test.cpp b/vespalib/src/tests/slime/slime_binary_format_test.cpp
index 888016caf5f..31fa6037877 100644
--- a/vespalib/src/tests/slime/slime_binary_format_test.cpp
+++ b/vespalib/src/tests/slime/slime_binary_format_test.cpp
@@ -1,9 +1,10 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/vespalib/testkit/test_kit.h>
+#include "type_traits.h"
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/data/simple_buffer.h>
-#include "type_traits.h"
#include <vespa/vespalib/util/stringfmt.h>
+#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
using namespace vespalib::slime::convenience;
using namespace vespalib::slime::binary_format;
diff --git a/vespalib/src/tests/slime/slime_inject_test.cpp b/vespalib/src/tests/slime/slime_inject_test.cpp
index a9274e3073d..be9303879bd 100644
--- a/vespalib/src/tests/slime/slime_inject_test.cpp
+++ b/vespalib/src/tests/slime/slime_inject_test.cpp
@@ -1,7 +1,8 @@
// Copyright Vespa.ai. 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/data/slime/slime.h>
#include <vespa/vespalib/data/slime/strfmt.h>
+#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
using namespace vespalib::slime::convenience;
diff --git a/vespalib/src/tests/slime/slime_test.cpp b/vespalib/src/tests/slime/slime_test.cpp
index 591b3bd6465..68c91fc900b 100644
--- a/vespalib/src/tests/slime/slime_test.cpp
+++ b/vespalib/src/tests/slime/slime_test.cpp
@@ -1,6 +1,5 @@
// Copyright Vespa.ai. 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/data/slime/slime.h>
#include <vespa/vespalib/data/slime/object_value.h>
#include <vespa/vespalib/data/slime/array_value.h>
@@ -9,6 +8,8 @@
#include <vespa/vespalib/data/slime/symbol_table.h>
#include <vespa/vespalib/data/slime/basic_value.h>
#include <type_traits>
+#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
#include <vespa/log/log.h>
LOG_SETUP("slime_test");
diff --git a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp
index 87ecb42efa8..065984e5ed9 100644
--- a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp
+++ b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp
@@ -3,6 +3,7 @@
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/data/slime/slime.h>
+#include <cassert>
using namespace vespalib;
using namespace vespalib::slime::convenience;
diff --git a/vespalib/src/tests/state_server/state_server_test.cpp b/vespalib/src/tests/state_server/state_server_test.cpp
index 6c248b54cc8..18dc54188ef 100644
--- a/vespalib/src/tests/state_server/state_server_test.cpp
+++ b/vespalib/src/tests/state_server/state_server_test.cpp
@@ -1,6 +1,5 @@
// Copyright Vespa.ai. 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/net/connection_auth_context.h>
#include <vespa/vespalib/net/http/state_server.h>
#include <vespa/vespalib/net/http/simple_health_producer.h>
@@ -13,6 +12,8 @@
#include <vespa/vespalib/util/host_name.h>
#include <vespa/vespalib/process/process.h>
#include <sys/stat.h>
+#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
using namespace vespalib;
diff --git a/vespalib/src/tests/stllike/cache_test.cpp b/vespalib/src/tests/stllike/cache_test.cpp
index 9171f923ecf..79f8515162d 100644
--- a/vespalib/src/tests/stllike/cache_test.cpp
+++ b/vespalib/src/tests/stllike/cache_test.cpp
@@ -1,6 +1,6 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/stllike/cache.hpp>
#include <map>
diff --git a/vespalib/src/tests/stllike/hash_test.cpp b/vespalib/src/tests/stllike/hash_test.cpp
index 493ea700fb2..0f5bbf29042 100644
--- a/vespalib/src/tests/stllike/hash_test.cpp
+++ b/vespalib/src/tests/stllike/hash_test.cpp
@@ -1,6 +1,5 @@
// Copyright Vespa.ai. 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/stllike/hash_set.hpp>
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <vespa/vespalib/stllike/hash_map_equal.hpp>
@@ -8,6 +7,8 @@
#include <cstddef>
#include <algorithm>
#include <atomic>
+#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
using namespace vespalib;
using std::make_pair;
diff --git a/vespalib/src/tests/stllike/hashtable_test.cpp b/vespalib/src/tests/stllike/hashtable_test.cpp
index c7890c79164..4880c7a872d 100644
--- a/vespalib/src/tests/stllike/hashtable_test.cpp
+++ b/vespalib/src/tests/stllike/hashtable_test.cpp
@@ -4,7 +4,7 @@
#include <vespa/vespalib/stllike/hashtable.hpp>
#include <vespa/vespalib/stllike/hash_fun.h>
#include <vespa/vespalib/stllike/identity.h>
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <memory>
#include <vector>
diff --git a/vespalib/src/tests/stllike/lrucache.cpp b/vespalib/src/tests/stllike/lrucache.cpp
index 3722845919d..9f81b29394e 100644
--- a/vespalib/src/tests/stllike/lrucache.cpp
+++ b/vespalib/src/tests/stllike/lrucache.cpp
@@ -1,6 +1,6 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/stllike/lrucache_map.hpp>
diff --git a/vespalib/src/tests/stllike/vector_map_test.cpp b/vespalib/src/tests/stllike/vector_map_test.cpp
index 00794bcc1e3..18b573f323b 100644
--- a/vespalib/src/tests/stllike/vector_map_test.cpp
+++ b/vespalib/src/tests/stllike/vector_map_test.cpp
@@ -5,7 +5,7 @@
LOG_SETUP("vector_map_test");
#include <vespa/vespalib/stllike/vector_map.h>
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
using vespalib::vector_map;
diff --git a/vespalib/src/tests/sync/sync_test.cpp b/vespalib/src/tests/sync/sync_test.cpp
index df781dea423..dd15e2f0057 100644
--- a/vespalib/src/tests/sync/sync_test.cpp
+++ b/vespalib/src/tests/sync/sync_test.cpp
@@ -1,6 +1,6 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/util/gate.h>
using namespace vespalib;
diff --git a/vespalib/src/tests/testapp-generic/testapp-generic.cpp b/vespalib/src/tests/testapp-generic/testapp-generic.cpp
index e63e78040fe..9b5a5c0426a 100644
--- a/vespalib/src/tests/testapp-generic/testapp-generic.cpp
+++ b/vespalib/src/tests/testapp-generic/testapp-generic.cpp
@@ -1,7 +1,8 @@
// Copyright Vespa.ai. 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/util/stringfmt.h>
#include <stdexcept>
+#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/testkit/test_master.hpp>
using namespace vespalib;
diff --git a/vespalib/src/tests/text/lowercase/lowercase_test.cpp b/vespalib/src/tests/text/lowercase/lowercase_test.cpp
index 40803b8f295..75512a733a5 100644
--- a/vespalib/src/tests/text/lowercase/lowercase_test.cpp
+++ b/vespalib/src/tests/text/lowercase/lowercase_test.cpp
@@ -2,7 +2,6 @@
#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>
#include <fstream>
diff --git a/vespalib/src/tests/text/stringtokenizer/stringtokenizer_test.cpp b/vespalib/src/tests/text/stringtokenizer/stringtokenizer_test.cpp
index aabe9ba1980..75415f7093b 100644
--- a/vespalib/src/tests/text/stringtokenizer/stringtokenizer_test.cpp
+++ b/vespalib/src/tests/text/stringtokenizer/stringtokenizer_test.cpp
@@ -1,18 +1,13 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/log/log.h>
LOG_SETUP("stringtokenizer_test");
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/text/stringtokenizer.h>
#include <set>
using namespace vespalib;
-TEST_SETUP(Test);
-
-int
-Test::Main()
-{
- TEST_INIT("stringtokenizer_test");
+TEST("stringtokenizer_test") {
{
string s("This,is ,a,,list ,\tof,,sepa rated\n, \rtokens,");
StringTokenizer tokenizer(s);
@@ -67,5 +62,6 @@ Test::Main()
StringTokenizer tokenizer(s);
EXPECT_EQUAL(0u, tokenizer.size());
}
- TEST_DONE();
}
+
+TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/tests/text/utf8/utf8_test.cpp b/vespalib/src/tests/text/utf8/utf8_test.cpp
index 7f48537f179..ffe1e44c079 100644
--- a/vespalib/src/tests/text/utf8/utf8_test.cpp
+++ b/vespalib/src/tests/text/utf8/utf8_test.cpp
@@ -1,7 +1,6 @@
// Copyright Vespa.ai. 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/text/utf8.h>
#include <fcntl.h>
#include <unistd.h>
@@ -15,12 +14,7 @@ LOG_SETUP("utf8_test");
using namespace vespalib;
-TEST_SETUP(Test);
-
-int
-Test::Main()
-{
- TEST_INIT("utf8_test");
+TEST("utf8_test") {
for (uint32_t h = 0; h < 0x1100; h++) {
vespalib::string data;
@@ -80,5 +74,6 @@ Test::Main()
}
EXPECT_TRUE(! r.hasMore());
}
- TEST_DONE();
}
+
+TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/tests/trace/trace.cpp b/vespalib/src/tests/trace/trace.cpp
index 2b35740deb1..5dce0e5cc6b 100644
--- a/vespalib/src/tests/trace/trace.cpp
+++ b/vespalib/src/tests/trace/trace.cpp
@@ -1,5 +1,5 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/trace/trace.h>
#include <vespa/vespalib/trace/tracevisitor.h>
diff --git a/vespalib/src/tests/true/true.cpp b/vespalib/src/tests/true/true.cpp
index fee248200ad..8d2ed2aeca8 100644
--- a/vespalib/src/tests/true/true.cpp
+++ b/vespalib/src/tests/true/true.cpp
@@ -1,14 +1,10 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/log/log.h>
LOG_SETUP("true_test");
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
-TEST_SETUP(Test)
-
-int
-Test::Main()
-{
- TEST_INIT("true_test");
+TEST("true_test") {
EXPECT_TRUE(true);
- TEST_DONE();
}
+
+TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/tests/util/cgroup_resource_limits/cgroup_resource_limits_test.cpp b/vespalib/src/tests/util/cgroup_resource_limits/cgroup_resource_limits_test.cpp
index 77c109bb6eb..38e8467ff35 100644
--- a/vespalib/src/tests/util/cgroup_resource_limits/cgroup_resource_limits_test.cpp
+++ b/vespalib/src/tests/util/cgroup_resource_limits/cgroup_resource_limits_test.cpp
@@ -1,6 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/gtest/gtest.h>
+#include <vespa/vespalib/testkit/test_path.h>
#include <vespa/vespalib/util/cgroup_resource_limits.h>
#include <vespa/vespalib/util/size_literals.h>
@@ -20,7 +21,8 @@ CGroupResourceLimitsTest::~CGroupResourceLimitsTest() = default;
void
CGroupResourceLimitsTest::check_limits(const std::string &base, const std::optional<uint64_t>& memory_limit, const std::optional<uint32_t>& cpu_limit)
{
- CGroupResourceLimits cg_limits(base + "/cgroup", base + "/self");
+ auto src_base = TEST_PATH(base);
+ CGroupResourceLimits cg_limits(src_base + "/cgroup", src_base + "/self");
EXPECT_EQ(memory_limit, cg_limits.get_memory_limit());
EXPECT_EQ(cpu_limit, cg_limits.get_cpu_limit());
}
diff --git a/vespalib/src/tests/valgrind/valgrind_test.cpp b/vespalib/src/tests/valgrind/valgrind_test.cpp
index e9fd265cfa3..afecff17eb9 100644
--- a/vespalib/src/tests/valgrind/valgrind_test.cpp
+++ b/vespalib/src/tests/valgrind/valgrind_test.cpp
@@ -1,20 +1,11 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/util/valgrind.h>
using namespace vespalib;
-class Test : public TestApp
-{
- int Main() override;
- void testUninitializedUser();
- void testUninitializedSystemCall();
- void testInitializedUser();
- void testInitializedSystemCall();
-};
-
-void Test::testUninitializedUser()
+void testUninitializedUser()
{
char buf[7];
buf[0] = 7;
@@ -22,45 +13,37 @@ void Test::testUninitializedUser()
Valgrind::testUninitialized(buf, sizeof(buf));
}
-void Test::testUninitializedSystemCall()
+void testUninitializedSystemCall()
{
char buf[7];
buf[0] = 7;
buf[5] = 7;
Valgrind::testSystemCall(buf, sizeof(buf));
}
-void Test::testInitializedUser()
+void testInitializedUser()
{
char buf[7];
memset(buf, 0, sizeof(buf));
Valgrind::testUninitialized(buf, sizeof(buf));
}
-void Test::testInitializedSystemCall()
+void testInitializedSystemCall()
{
char buf[7];
memset(buf, 0, sizeof(buf));
Valgrind::testSystemCall(buf, sizeof(buf));
}
-int
-Test::Main()
-{
- TEST_INIT("valgrind_test");
-
- if (strcmp(_argv[1], "testInitializedUser") == 0) {
+TEST_MAIN() {
+ if (strcmp(argv[1], "testInitializedUser") == 0) {
testInitializedUser();
- } else if (strcmp(_argv[1], "testInitializedSystemCall") == 0) {
+ } else if (strcmp(argv[1], "testInitializedSystemCall") == 0) {
testInitializedSystemCall();
- } else if (strcmp(_argv[1], "testUninitializedUser") == 0) {
+ } else if (strcmp(argv[1], "testUninitializedUser") == 0) {
testUninitializedUser();
- } else if (strcmp(_argv[1], "testUninitializedSystemCall") == 0) {
+ } else if (strcmp(argv[1], "testUninitializedSystemCall") == 0) {
testUninitializedSystemCall();
} else {
testInitializedUser();
}
-
- TEST_DONE();
}
-
-TEST_APPHOOK(Test)
diff --git a/vespalib/src/tests/zcurve/zcurve_test.cpp b/vespalib/src/tests/zcurve/zcurve_test.cpp
index 8ed92304783..453bf6ddeba 100644
--- a/vespalib/src/tests/zcurve/zcurve_test.cpp
+++ b/vespalib/src/tests/zcurve/zcurve_test.cpp
@@ -1,6 +1,6 @@
// Copyright Vespa.ai. 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 <vespa/vespalib/geo/zcurve.h>
#include <algorithm>
#include <limits>
@@ -10,45 +10,14 @@
#include <vespa/log/log.h>
LOG_SETUP("zcurve_test");
-namespace vespalib {
+using namespace vespalib;
using geo::ZCurve;
-class ZCurveTest : public vespalib::TestApp
-{
-public:
- ZCurveTest(void)
- : vespalib::TestApp()
- {
- }
-
- void testEncoding();
-
- void testDecoding();
-
- double ftime();
-
- static inline int64_t encodexy3(int32_t x, int32_t y);
-
#define BMLIMIT 0x1000000
- template <bool decode>
- int64_t bm();
-
- template <bool decode>
- int64_t bm2();
-
- template <bool decode>
- int64_t bm3();
-
- int64_t bmcheck();
-
- int Main() override;
-};
-
-
void
-ZCurveTest::testEncoding(void)
+testEncoding(void)
{
int32_t x = 0;
int32_t y = 0;
@@ -83,7 +52,7 @@ ZCurveTest::testEncoding(void)
void
-ZCurveTest::testDecoding(void)
+testDecoding(void)
{
int32_t x = 0;
int32_t y = 0;
@@ -134,7 +103,7 @@ ZCurveTest::testDecoding(void)
double
-ZCurveTest::ftime()
+ftime()
{
struct timeval tv;
gettimeofday(&tv, NULL);
@@ -142,7 +111,7 @@ ZCurveTest::ftime()
}
int64_t
-ZCurveTest::encodexy3(int32_t x, int32_t y)
+encodexy3(int32_t x, int32_t y)
{
uint32_t resxl;
uint32_t resxh;
@@ -177,7 +146,7 @@ ZCurveTest::encodexy3(int32_t x, int32_t y)
template <bool decode>
int64_t
-ZCurveTest::bm()
+bm()
{
int64_t res = 0;
double before = ftime();
@@ -218,7 +187,7 @@ ZCurveTest::bm()
template <bool decode>
int64_t
-ZCurveTest::bm2(void)
+bm2(void)
{
int64_t res = 0;
double before = ftime();
@@ -259,7 +228,7 @@ ZCurveTest::bm2(void)
template <bool decode>
int64_t
-ZCurveTest::bm3()
+bm3()
{
int64_t res = 0;
double before = ftime();
@@ -299,7 +268,7 @@ ZCurveTest::bm3()
int64_t
-ZCurveTest::bmcheck()
+bmcheck()
{
int64_t res = 0;
double before = ftime();
@@ -340,12 +309,7 @@ ZCurveTest::bmcheck()
return res;
}
-
-int
-ZCurveTest::Main()
-{
- TEST_INIT("zcurve_test");
-
+TEST_MAIN() {
for (int32_t x = 0; x < 4; x++) {
for (int32_t y = 0; y < 4; y++) {
int64_t enc = 0;
@@ -368,7 +332,7 @@ ZCurveTest::Main()
}
testEncoding();
testDecoding();
- if (_argc >= 2) {
+ if (argc >= 2) {
int64_t enc1 = bm<true>();
int64_t enc1b = bm<false>();
int64_t enc2 = bm2<true>();
@@ -383,10 +347,4 @@ ZCurveTest::Main()
ASSERT_TRUE(enc1 == enc3b);
ASSERT_TRUE(enc1 == enc4);
}
-
- TEST_DONE();
}
-
-}
-
-TEST_APPHOOK(vespalib::ZCurveTest);