diff options
author | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2019-06-25 13:29:21 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2019-06-26 08:54:37 +0000 |
commit | fb6db2f639381f384807aaac0ec2701c4e4013fb (patch) | |
tree | 369ce0084ec3a5cc4289537557934ad56903c5fb | |
parent | 3de18f8a3dbeb0cda98fd3f86920784be154cb9a (diff) |
Remove CppUnit dependencies in modules
Move test config helpers out of cppunit submodule.
35 files changed, 17 insertions, 586 deletions
diff --git a/metrics/CMakeLists.txt b/metrics/CMakeLists.txt index 938617e09d3..6cf1eadd6f7 100644 --- a/metrics/CMakeLists.txt +++ b/metrics/CMakeLists.txt @@ -10,9 +10,6 @@ vespa_define_module( LIBS src/vespa/metrics - TEST_EXTERNAL_DEPENDS - cppunit - TESTS src/tests ) diff --git a/metrics/src/tests/metricmanagertest.cpp b/metrics/src/tests/metricmanagertest.cpp index f260089ec84..1d954a641b6 100644 --- a/metrics/src/tests/metricmanagertest.cpp +++ b/metrics/src/tests/metricmanagertest.cpp @@ -895,8 +895,6 @@ public: void verifyDimensions(size_t metricIndex, const std::string& name, const Metric::Tags& dimensions) { - // Works to do this outside of main test body because cppunit uses - // exceptions for its failures. EXPECT_EQ(name, nthMetricName(metricIndex)) << _jsonText; EXPECT_EQ(dimensions.size(), nthMetricDimensionCount(metricIndex)) << _jsonText; for (auto& dim : dimensions) { diff --git a/storage/CMakeLists.txt b/storage/CMakeLists.txt index f77c11eb350..418d8dbe430 100644 --- a/storage/CMakeLists.txt +++ b/storage/CMakeLists.txt @@ -49,9 +49,6 @@ vespa_define_module( vdstestlib atomic - TEST_EXTERNAL_DEPENDS - cppunit - TESTS src/tests src/tests/bucketdb diff --git a/storage/src/tests/CMakeLists.txt b/storage/src/tests/CMakeLists.txt index f93ea7ef00d..e92d15c14e3 100644 --- a/storage/src/tests/CMakeLists.txt +++ b/storage/src/tests/CMakeLists.txt @@ -1,16 +1,3 @@ # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -# Runner for unit tests written in CppUnit (DEPRECATED). -# NOTE: All new tests should be written in gtest. Each test sub-module has a gtest runner. -vespa_add_executable(storage_testrunner_app TEST - SOURCES - testrunner.cpp - DEPENDS - storage_testcommon - storage_testhostreporter -) - -vespa_add_test( - NAME storage_testrunner_app - COMMAND storage_testrunner_app -) +# Currently empty; test executables are in library subdirs diff --git a/storage/src/tests/bucketdb/initializertest.cpp b/storage/src/tests/bucketdb/initializertest.cpp index 57bb3a865d5..63f990f7cc1 100644 --- a/storage/src/tests/bucketdb/initializertest.cpp +++ b/storage/src/tests/bucketdb/initializertest.cpp @@ -12,8 +12,8 @@ #include <vespa/storageapi/message/state.h> #include <tests/common/teststorageapp.h> #include <tests/common/dummystoragelink.h> -#include <tests/common/testhelper.h> // TODO decouple from CppUnit -#include <vespa/vdstestlib/cppunit/dirconfig.hpp> // TODO decouple from CppUnit +#include <tests/common/testhelper.h> +#include <vespa/vdstestlib/config/dirconfig.hpp> #include <vespa/vespalib/gtest/gtest.h> #include <vespa/log/log.h> diff --git a/storage/src/tests/common/testhelper.h b/storage/src/tests/common/testhelper.h index cc7f503e028..8c553ccce40 100644 --- a/storage/src/tests/common/testhelper.h +++ b/storage/src/tests/common/testhelper.h @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <vespa/messagebus/testlib/slobrok.h> -#include <vespa/vdstestlib/cppunit/dirconfig.h> +#include <vespa/vdstestlib/config/dirconfig.h> #include <fstream> #include <sstream> diff --git a/storage/src/tests/gtest_runner.cpp b/storage/src/tests/gtest_runner.cpp deleted file mode 100644 index 0eb65b00d49..00000000000 --- a/storage/src/tests/gtest_runner.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/vespalib/gtest/gtest.h> - -#include <vespa/log/log.h> -LOG_SETUP("storage_gtest_runner"); - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp index f6b8fc3b3f0..7db47572e22 100644 --- a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp +++ b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp @@ -1,6 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <tests/common/testhelper.h> // FIXME +#include <tests/common/testhelper.h> #include <tests/common/dummystoragelink.h> #include <tests/common/teststorageapp.h> #include <tests/persistence/filestorage/forwardingmessagesender.h> diff --git a/storage/src/tests/storageserver/fnet_listener_test.cpp b/storage/src/tests/storageserver/fnet_listener_test.cpp index b9f2ca74df3..f82af1f8e5c 100644 --- a/storage/src/tests/storageserver/fnet_listener_test.cpp +++ b/storage/src/tests/storageserver/fnet_listener_test.cpp @@ -8,7 +8,7 @@ #include <vespa/storageapi/message/state.h> #include <vespa/vdslib/state/clusterstate.h> #include <vespa/vespalib/stllike/asciistream.h> -#include <vespa/vdstestlib/cppunit/dirconfig.hpp> +#include <vespa/vdstestlib/config/dirconfig.hpp> #include <vespa/messagebus/testlib/slobrok.h> #include <tests/common/testhelper.h> #include <vespa/vespalib/gtest/gtest.h> diff --git a/storage/src/tests/storageserver/service_layer_error_listener_test.cpp b/storage/src/tests/storageserver/service_layer_error_listener_test.cpp index dc5324c00e3..ec38e09a673 100644 --- a/storage/src/tests/storageserver/service_layer_error_listener_test.cpp +++ b/storage/src/tests/storageserver/service_layer_error_listener_test.cpp @@ -3,7 +3,7 @@ #include <vespa/storage/storageserver/service_layer_error_listener.h> #include <vespa/storage/storageserver/mergethrottler.h> #include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h> -#include <vespa/vdstestlib/cppunit/dirconfig.h> +#include <vespa/vdstestlib/config/dirconfig.h> #include <tests/common/testhelper.h> #include <tests/common/teststorageapp.h> #include <vespa/vespalib/gtest/gtest.h> diff --git a/storage/src/tests/testrunner.cpp b/storage/src/tests/testrunner.cpp deleted file mode 100644 index 9f871997873..00000000000 --- a/storage/src/tests/testrunner.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/vdstestlib/cppunit/cppunittestrunner.h> - -#include <vespa/log/log.h> -LOG_SETUP("storagecppunittests"); - -int -main(int argc, const char *argv[]) -{ - vdstestlib::CppUnitTestRunner testRunner; - return testRunner.run(argc, argv); -} diff --git a/storageapi/src/tests/CMakeLists.txt b/storageapi/src/tests/CMakeLists.txt index ddc43c70004..8b820adb467 100644 --- a/storageapi/src/tests/CMakeLists.txt +++ b/storageapi/src/tests/CMakeLists.txt @@ -1,13 +1,12 @@ # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -# Runner for unit tests written in gtest. -# NOTE: All new test classes should be added here. vespa_add_executable(storageapi_gtest_runner_app TEST SOURCES gtest_runner.cpp DEPENDS storageapi_testbuckets storageapi_testmbusprot + storageapi_testmessageapi storageapi gtest ) @@ -17,17 +16,3 @@ vespa_add_test( COMMAND storageapi_gtest_runner_app ) -# Runner for unit tests written in CppUnit (DEPRECATED). -vespa_add_executable(storageapi_testrunner_app TEST - SOURCES - testrunner.cpp - DEPENDS - storageapi_testmessageapi - storageapi - vdstestlib -) - -vespa_add_test( - NAME storageapi_testrunner_app - COMMAND storageapi_testrunner_app -) diff --git a/storageapi/src/tests/testrunner.cpp b/storageapi/src/tests/testrunner.cpp deleted file mode 100644 index f21df6bdb86..00000000000 --- a/storageapi/src/tests/testrunner.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/vdstestlib/cppunit/cppunittestrunner.h> - -#include <vespa/log/log.h> -LOG_SETUP("storageapicppunittestrunner"); - -int -main(int argc, const char *argv[]) -{ - vdstestlib::CppUnitTestRunner testRunner; - return testRunner.run(argc, argv); -} diff --git a/storageframework/CMakeLists.txt b/storageframework/CMakeLists.txt index 2211a4c009d..db6a14d0386 100644 --- a/storageframework/CMakeLists.txt +++ b/storageframework/CMakeLists.txt @@ -20,7 +20,6 @@ vespa_define_module( src/vespa/storageframework/generic/thread TEST_EXTERNAL_DEPENDS - cppunit vdstestlib TESTS diff --git a/storageserver/src/tests/testhelper.h b/storageserver/src/tests/testhelper.h index 7dbaaecdbf4..a0d5da20eb8 100644 --- a/storageserver/src/tests/testhelper.h +++ b/storageserver/src/tests/testhelper.h @@ -4,7 +4,7 @@ #include <fstream> #include <sstream> #include <vespa/messagebus/testlib/slobrok.h> -#include <vespa/vdstestlib/cppunit/dirconfig.h> +#include <vespa/vdstestlib/config/dirconfig.h> namespace storage { diff --git a/streamingvisitors/CMakeLists.txt b/streamingvisitors/CMakeLists.txt index 88278bbc86a..26eb77fa4ce 100644 --- a/streamingvisitors/CMakeLists.txt +++ b/streamingvisitors/CMakeLists.txt @@ -12,9 +12,6 @@ vespa_define_module( vdslib vsm - TEST_EXTERNAL_DEPENDS - cppunit - LIBS src/vespa/searchvisitor diff --git a/valgrind-suppressions.txt b/valgrind-suppressions.txt index 2587552ceff..13be6234a94 100644 --- a/valgrind-suppressions.txt +++ b/valgrind-suppressions.txt @@ -24,57 +24,6 @@ fun:(below main) } { - This is a bug in cppunit. - Memcheck:Leak - fun:_Znwm - fun:*addTestsToSuite*CppUnit*TestSuiteBuilderContextBase* -} -{ - Bug in cppunit. This suppression is created on CentOS7. - Memcheck:Leak - match-leak-kinds: definite - fun:_Znwm - fun:addTestsToSuite - fun:suite - fun:*makeTest* - fun:_ZN7CppUnit19TestFactoryRegistry14addTestToSuiteEPNS_9TestSuiteE - fun:_ZN7CppUnit19TestFactoryRegistry8makeTestEv - fun:_ZN10vdstestlib17CppUnitTestRunner3runEiPKPKc - fun:main -} -{ - Bug in cppunit. This suppression is created on CentOS7. - Memcheck:Leak - match-leak-kinds: definite - fun:_Znwm - fun:allocate - fun:_S_create - fun:_S_construct<char const*> - fun:_S_construct_aux<char const*> - fun:_S_construct<char const*> - fun:_ZNSsC1EPKcRKSaIcE - fun:_ZN7CppUnit10TestRunnerC1Ev - fun:_ZN7CppUnit14TextTestRunnerC1EPNS_9OutputterE - fun:_ZN10vdstestlib17CppUnitTestRunner3runEiPPKc - fun:main -} -{ - Bug in cppunit. This suppression is created on CentOS7. - Memcheck:Leak - match-leak-kinds: definite - fun:_Znwm - fun:allocate - fun:_S_create - fun:_ZNSs12_S_constructIPKcEEPcT_S3_RKSaIcESt20forward_iterator_tag - fun:_S_construct_aux<char const*> - fun:_S_construct<char const*> - fun:_ZNSsC1EPKcRKSaIcE - fun:_ZN7CppUnit10TestRunnerC1Ev - fun:_ZN7CppUnit14TextTestRunnerC1EPNS_9OutputterE - fun:_ZN10vdstestlib17CppUnitTestRunner3runEiPPKc - fun:main -} -{ RHEL6 strlen is eager and will read 16 bytes blocks. Memcheck:Cond fun:__strlen_sse42 diff --git a/vdslib/CMakeLists.txt b/vdslib/CMakeLists.txt index 0480ea266e5..b997bf5f983 100644 --- a/vdslib/CMakeLists.txt +++ b/vdslib/CMakeLists.txt @@ -18,7 +18,6 @@ vespa_define_module( TEST_DEPENDS vdstestlib - cppunit TESTS src/tests diff --git a/vdstestlib/CMakeLists.txt b/vdstestlib/CMakeLists.txt index 10ee29bdcc5..8fd97fe8168 100644 --- a/vdstestlib/CMakeLists.txt +++ b/vdstestlib/CMakeLists.txt @@ -5,10 +5,9 @@ vespa_define_module( vespalib TESTS - src/tests/cppunit src/tests/dirconfig LIBS src/vespa/vdstestlib - src/vespa/vdstestlib/cppunit + src/vespa/vdstestlib/config ) diff --git a/vdstestlib/src/tests/cppunit/.gitignore b/vdstestlib/src/tests/cppunit/.gitignore deleted file mode 100644 index ec991c2f0cd..00000000000 --- a/vdstestlib/src/tests/cppunit/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.depend -Makefile -testrunner -vdstestlib_testrunner_app diff --git a/vdstestlib/src/tests/cppunit/CMakeLists.txt b/vdstestlib/src/tests/cppunit/CMakeLists.txt deleted file mode 100644 index 1b8e857fe30..00000000000 --- a/vdstestlib/src/tests/cppunit/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vdstestlib_testrunner_app TEST - SOURCES - testrunner.cpp - cppunittest.cpp - DEPENDS - vdstestlib -) - -vespa_add_test( - NAME vdstestlib_testrunner_app - NO_VALGRIND - COMMAND vdstestlib_testrunner_app -) diff --git a/vdstestlib/src/tests/cppunit/cppunittest.cpp b/vdstestlib/src/tests/cppunit/cppunittest.cpp deleted file mode 100644 index bf8b38e696e..00000000000 --- a/vdstestlib/src/tests/cppunit/cppunittest.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vdstestlib/cppunit/macros.h> - -namespace vespalib { - -struct CppunitTest : public CppUnit::TestFixture { - - void testSomething(); - - CPPUNIT_TEST_SUITE(CppunitTest); - CPPUNIT_TEST(testSomething); - CPPUNIT_TEST_SUITE_END(); - -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(CppunitTest); - -void -CppunitTest::testSomething() -{ - CPPUNIT_ASSERT_EQUAL_MESSAGE("hmm", "foo", "foo"); -} - -} // vespalib diff --git a/vdstestlib/src/tests/cppunit/testrunner.cpp b/vdstestlib/src/tests/cppunit/testrunner.cpp deleted file mode 100644 index 3b686d132bb..00000000000 --- a/vdstestlib/src/tests/cppunit/testrunner.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/vdstestlib/cppunit/cppunittestrunner.h> - -int main(int argc, const char *argv[]) -{ - vdstestlib::CppUnitTestRunner testRunner; - return testRunner.run(argc, argv); -} - diff --git a/vdstestlib/src/tests/dirconfig/dirconfigtest.cpp b/vdstestlib/src/tests/dirconfig/dirconfigtest.cpp index 9d8e5c47143..f985150e497 100644 --- a/vdstestlib/src/tests/dirconfig/dirconfigtest.cpp +++ b/vdstestlib/src/tests/dirconfig/dirconfigtest.cpp @@ -2,7 +2,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/exceptions.h> -#include <vespa/vdstestlib/cppunit/dirconfig.h> +#include <vespa/vdstestlib/config/dirconfig.h> #include <fstream> #include <iostream> diff --git a/vdstestlib/src/vespa/vdstestlib/CMakeLists.txt b/vdstestlib/src/vespa/vdstestlib/CMakeLists.txt index ce80f8dd644..86ca3461302 100644 --- a/vdstestlib/src/vespa/vdstestlib/CMakeLists.txt +++ b/vdstestlib/src/vespa/vdstestlib/CMakeLists.txt @@ -1,8 +1,6 @@ # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_library(vdstestlib SOURCES - $<TARGET_OBJECTS:vdstestlib_vdstestlib_cppunit> + $<TARGET_OBJECTS:vdstestlib_vdstestlib_config> INSTALL lib64 - DEPENDS - cppunit ) diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/.gitignore b/vdstestlib/src/vespa/vdstestlib/config/.gitignore index 583460ae288..583460ae288 100644 --- a/vdstestlib/src/vespa/vdstestlib/cppunit/.gitignore +++ b/vdstestlib/src/vespa/vdstestlib/config/.gitignore diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/CMakeLists.txt b/vdstestlib/src/vespa/vdstestlib/config/CMakeLists.txt index e7d8705b07d..90b7c95fe50 100644 --- a/vdstestlib/src/vespa/vdstestlib/cppunit/CMakeLists.txt +++ b/vdstestlib/src/vespa/vdstestlib/config/CMakeLists.txt @@ -1,7 +1,6 @@ # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_library(vdstestlib_vdstestlib_cppunit OBJECT +vespa_add_library(vdstestlib_vdstestlib_config OBJECT SOURCES - cppunittestrunner.cpp dirconfig.cpp DEPENDS ) diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.cpp b/vdstestlib/src/vespa/vdstestlib/config/dirconfig.cpp index 3a26ed9dec8..3a26ed9dec8 100644 --- a/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.cpp +++ b/vdstestlib/src/vespa/vdstestlib/config/dirconfig.cpp diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.h b/vdstestlib/src/vespa/vdstestlib/config/dirconfig.h index 388348c880e..c0a1571f52c 100644 --- a/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.h +++ b/vdstestlib/src/vespa/vdstestlib/config/dirconfig.h @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. /** * \class vdstestlib::DirConfig - * \ingroup cppunit + * \ingroup config * * \brief Helper class for generating dir config * diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.hpp b/vdstestlib/src/vespa/vdstestlib/config/dirconfig.hpp index f5d886c089a..5d127879e34 100644 --- a/vdstestlib/src/vespa/vdstestlib/cppunit/dirconfig.hpp +++ b/vdstestlib/src/vespa/vdstestlib/config/dirconfig.hpp @@ -2,7 +2,7 @@ #pragma once -#include <vespa/vdstestlib/cppunit/dirconfig.h> +#include <vespa/vdstestlib/config/dirconfig.h> #include <sstream> #include <boost/lexical_cast.hpp> diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.cpp b/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.cpp deleted file mode 100644 index dbedf1ee900..00000000000 --- a/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/vdstestlib/cppunit/cppunittestrunner.h> - -#include <cppunit/extensions/TestFactoryRegistry.h> -#include <cppunit/ui/text/TestRunner.h> -#include <cppunit/TextTestProgressListener.h> -#include <vespa/log/log.h> -#include <iostream> - -LOG_SETUP(".cppunittestrunner"); - -using CppUnit::Test; -using CppUnit::TestSuite; - -namespace vdstestlib { - -namespace { - struct WantedTestList : public CppUnit::Test::Filter { - std::vector<std::string> _wanted; - bool _includeStressTests; - - WantedTestList(int argc, const char *argv[], - bool includeStressTests) - : _wanted(), - _includeStressTests(includeStressTests) - { - for (int i=1; i<argc; ++i) { - if (argv[i][0] != '-') { - std::cerr << "Running tests matching '*" - << argv[i] << "*'.\n"; - _wanted.push_back(argv[i]); - } - } - char* testpat = getenv("TEST_SUBSET"); - if (testpat != 0) { - std::string pat = std::string("*") + testpat; - if (pat[pat.size() - 1] != '$') pat += "*"; - std::cerr << "Running tests matching '" << pat << "'." - " (Taken from TEST_SUBSET environment variable)\n"; - _wanted.push_back(testpat); - } - if (CppUnit::Test::disabledCount > 0) { - std::cerr << CppUnit::Test::disabledCount - << " tests are currently disabled and won't be " - << "attempted run.\n"; - } - if (CppUnit::Test::ignoredCount > 0) { - std::cerr << CppUnit::Test::ignoredCount - << " tests are currently set to ignore failures.\n"; - } - } - - std::string getWantedString(uint32_t index) const { - std::string s = _wanted[index]; - if (s[s.size() - 1] == '$') { - return s.substr(0, s.size() - 1); - } - return s; - } - - bool requiresTailMatch(uint32_t index) const { - std::string s = _wanted[index]; - return (s[s.size() - 1] == '$'); - } - - bool include(const std::string& name) const override { - if ((name.find("stress") != std::string::npos || - name.find("Stress") != std::string::npos) - && !_includeStressTests) - { - std::cerr << "Excluding stress test " << name << "\n"; - } else { - if (_wanted.size() == 0) return true; - for (uint32_t i=0; i<_wanted.size(); ++i) { - std::string::size_type pos = name.rfind(getWantedString(i)); - if (pos == std::string::npos) continue; - if (!requiresTailMatch(i) - || pos == name.size() - getWantedString(i).size()) - { - return true; - } - } - } - return false; - } - }; - - struct LogHook : public CppUnit::TextTestProgressListener::TestStartHook { - std::string lastTest; - void startedTest(const std::string& testName) override { - LOG(info, "Starting test: %s", testName.c_str()); - lastTest = testName; - } - void stoppedTest() override { - LOG(info, "Stopped test: %s", lastTest.c_str()); - } - }; -} - -void CppUnitTestRunner::listTests(const TestSuite *tests) { - for (const auto & test : tests->getTests()) { - std::cout << test->getName() << std::endl; - } -} - -CppUnitTestRunner::CppUnitTestRunner() -{ - std::ios::sync_with_stdio(); -} - -int -CppUnitTestRunner::run(int argc, const char *argv[]) -{ - CppUnit::TextUi::TestRunner runner; - CppUnit::TestFactoryRegistry& registry( - CppUnit::TestFactoryRegistry::getRegistry()); - - Test *tests = registry.makeTest(); - TestSuite *suite = dynamic_cast<TestSuite *>(tests); - - bool includeStressTests = false; - bool logStartStop = false; - bool verbose = false; - if (getenv("TEST_VERBOSE") != 0) { - verbose = true; - } - - for (int i=1; i<argc; ++i) { - std::string arg(argv[i]); - if (arg == "--verbose") { - verbose = true; - logStartStop = true; - } else if (arg == "--includestress") { - includeStressTests = true; - } else if (arg == "--list") { - listTests(suite); - exit(0); - } else if (argv[i][0] == '-') { - std::cerr << "Illegal option " << arg << "\n"; - exit(1); - } else { - // Arguments will be passed as patterns - } - } - - WantedTestList wantedList(argc, argv, includeStressTests); - suite->filter(wantedList); - runner.addTest(tests); - CppUnit::TextTestProgressListener::verboseProgress = verbose; - if (logStartStop) { - CppUnit::TextTestProgressListener::startHook.reset(new LogHook); - } - return (runner.run("", false) ? 0 : -1); -} - -} // vdstestlib diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.h b/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.h deleted file mode 100644 index 057f116a7d2..00000000000 --- a/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -/** - * @class CppUnitTestRunner - * @ingroup cppunit - * - * @brief Application for running cppunit tests. - * - * This is an application to use when running cppunit tests, currently used - * in document,vdslib,storageapi and storage. - * - * It is built like a library, as one need to create one per project, but the - * cppunit test application file in each project can now only contain a little - * main method, creating an instance of this class and calling run. - * - * See storage/src/cpp/tests/testrunner.h for an example of simple app using - * this. - * - * When using this test binary you have the following options. - * - * If the TEST_SUBSET environment variable is set, only tests matching the - * pattern given in the environment is run. For instance, by doing - * TEST_SUBSET=foo ./testrunner, only tests that match the regular expression - * .*foo.* will be run. Optionally you can postfix your expression with a - * dollar, to only run tests that end with the given string. You can match - * against any part of the function shown in verbose mode. For instance - * TEST_SUBSET=foo::bar$ will run tests whose test class ends in foo, and - * having test name bar. - * - * You can specify --verbose mode. In verbose mode, each test name is printed - * to stdout when started, and after completion, the runtime of the test is - * shown. This is very useful to identify slow unit tests which should be - * improved, and also to see in what test the system might be hung up in. In - * addition, in verbose mode, a vespa log entry is given at the start and end - * of each test, such that one can identify which parts of the vespa log belongs - * to each test, in case you are redirecting the log to a file. - * - * You can also use the --includestress option to also include tests that match - * the regular expression '.*[sS]tress.*'. These are excluded by default, such - * that regular test runs can be quick. - */ - -#pragma once - -#include <cppunit/TestSuite.h> - -namespace vdstestlib { - -class CppUnitTestRunner { -public: - CppUnitTestRunner(); - - void listTests(const CppUnit::TestSuite *tests); - int run(int argc, const char * argv[]); - -}; - -} // vdstestlib - diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/macros.h b/vdstestlib/src/vespa/vdstestlib/cppunit/macros.h deleted file mode 100644 index fdde94bbbd6..00000000000 --- a/vdstestlib/src/vespa/vdstestlib/cppunit/macros.h +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -/** - * This file contains additional CPPUNIT macros to simplify tests. - */ -#pragma once -#include <cppunit/extensions/HelperMacros.h> -#include <vespa/vespalib/test/insertion_operators.h> - - -// Wrapper for CPPUNIT_ASSERT_EQUAL_MESSAGE to prevent it from evaluating -// message if val1 is equal to val2 -#define CPPUNIT_ASSERT_EQUAL_MSG(message, val1, val2) \ - { \ - if (!((val1) == (val2))) { \ - CPPUNIT_ASSERT_EQUAL_MESSAGE(message, val1, val2); \ - } \ - } - -#define CPPUNIT_ASSERT_EQUAL_ESCAPED(val1, val2) \ - { \ - if (!((val1) == (val2))) { \ - std::ostringstream out1; \ - std::ostringstream out2; \ - out1 << "[" << val1 << "]"; \ - out2 << "[" << val2 << "]"; \ - CPPUNIT_ASSERT_EQUAL( \ - document::StringUtil::escape(out1.str()), \ - document::StringUtil::escape(out2.str())); \ - } \ - } - -// Wrapper for CPPUNIT_ASSERT_MESSAGE to prevent it from evaluating message if -// val is true -#define CPPUNIT_ASSERT_MSG(message, val) \ - { \ - if (!(val)) { \ - CPPUNIT_ASSERT_MESSAGE(message, val); \ - } \ - } - -// Assert that value starts with prefix -#define CPPUNIT_ASSERT_PREFIX(prefix, value) \ - { \ - std::ostringstream pre; \ - pre << prefix; \ - std::ostringstream val; \ - val << value; \ - if (val.str().find(pre.str()) != 0) { \ - CPPUNIT_FAIL("Value of '" + val.str() + "' does not contain " \ - "prefix '" + pre.str() + "'."); \ - } \ - } - -// Assert that value contains given substring -#define CPPUNIT_ASSERT_CONTAIN(contained, value) \ - { \ - std::ostringstream cont; \ - cont << contained; \ - std::ostringstream val; \ - val << value; \ - if (val.str().find(cont.str()) == std::string::npos) { \ - CPPUNIT_FAIL("Value of '" + val.str() + "' does not contain '" \ - + cont.str() + "'."); \ - } \ - } - -// Assert that value contains given substring, add message to output on error -#define CPPUNIT_ASSERT_CONTAIN_MESSAGE(message, contained, value) \ - { \ - std::ostringstream cont; \ - cont << contained; \ - std::ostringstream val; \ - val << value; \ - std::string mess = message; \ - if (val.str().find(cont.str()) == std::string::npos) { \ - CPPUNIT_FAIL(mess + ": Value of '" + val.str() \ - + "' does not contain '" + cont.str() + "'."); \ - } \ - } - -// Assert that given expression matches the given regular expression. -#include <vespa/vespalib/util/regexp.h> -#define CPPUNIT_ASSERT_MATCH_REGEX(expression, value) \ - { \ - std::ostringstream _ost_; \ - _ost_ << value; \ - std::string _s_(_ost_.str()); \ - vespalib::Regexp _myregex_(expression); \ - if (!_myregex_.match(_s_)) { \ - CPPUNIT_FAIL("Value of '" + _s_ + "' does not match regex '" \ - + expression + "'."); \ - } \ - } - -// Assert that given expression matches the given regular expression. -#include <vespa/vespalib/util/regexp.h> -#define CPPUNIT_ASSERT_MATCH_REGEX_MSG(message, expression, value) \ - { \ - std::ostringstream _ost_; \ - _ost_ << value; \ - std::string _s_(_ost_.str()); \ - vespalib::Regexp _myregex_(expression); \ - std::string mess = message; \ - if (!_myregex_.match(_s_)) { \ - CPPUNIT_FAIL("Value of '" + _s_ + "' does not match regex '" \ - + expression + "'. Message: '" + mess + "'"); \ - } \ - } - -#define CPPUNIT_ASSERT_FILE_CONTAINS(expected, filename) \ - { \ - std::ostringstream value; \ - value << expected; \ - std::ostringstream ost; \ - std::string line; \ - std::ifstream input(filename); \ - while (std::getline(input, line, '\n')) { \ - ost << line << '\n'; \ - } \ - CPPUNIT_ASSERT_EQUAL(value.str(), ost.str()); \ - } - -#define CPPUNIT_ASSERT_SUBSTRING_COUNT(source, expectedCount, substring) \ - { \ - uint32_t count = 0; \ - std::ostringstream value; /* Let value be non-strings */ \ - value << source; \ - std::string s(value.str()); \ - std::string::size_type pos = s.find(substring); \ - while (pos != std::string::npos) { \ - ++count; \ - pos = s.find(substring, pos+1); \ - } \ - if (count != (uint32_t) expectedCount) { \ - std::ostringstream error; \ - error << "Value of '" << s << "' contained " << count \ - << " instances of substring '" << substring << "', not " \ - << expectedCount << " as expected."; \ - CPPUNIT_FAIL(error.str()); \ - } \ - } - -#include <ostream> -#include <map> -#include <unordered_map> -#include <vector> - -// Create output operator for containers. -// Needed so we can use CPPUNIT_ASSERT_EQUAL with them. - -template<typename S, typename T> -std::ostream& -operator<<(std::ostream& out, const std::unordered_map<S, T>& umap) -{ - out << "std::unordered_map(" << umap.size() << ") {"; - for (auto keyValue : umap) { - out << "\n " << keyValue.first << ": " << keyValue.second; - } - if (!umap.empty()) { - out << "\n"; - } - out << "}"; - return out; -} diff --git a/vespalib/src/tests/testkit-testhook/CMakeLists.txt b/vespalib/src/tests/testkit-testhook/CMakeLists.txt index c4662adc8a8..4febe6ebb75 100644 --- a/vespalib/src/tests/testkit-testhook/CMakeLists.txt +++ b/vespalib/src/tests/testkit-testhook/CMakeLists.txt @@ -4,6 +4,5 @@ vespa_add_executable(vespalib_testkit-testhook_test_app TEST testkit-testhook_test.cpp DEPENDS vespalib - cppunit ) vespa_add_test(NAME vespalib_testkit-testhook_test_app COMMAND vespalib_testkit-testhook_test_app) diff --git a/vespalib/src/tests/testkit-testhook/testkit-testhook_test.cpp b/vespalib/src/tests/testkit-testhook/testkit-testhook_test.cpp index 164f4cd7247..df7916dd56d 100644 --- a/vespalib/src/tests/testkit-testhook/testkit-testhook_test.cpp +++ b/vespalib/src/tests/testkit-testhook/testkit-testhook_test.cpp @@ -1,7 +1,5 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> - -#include <cppunit/extensions/HelperMacros.h> #include <stdexcept> //----------------------------------------------------------------------------- @@ -150,12 +148,7 @@ IGNORE_TEST("passed tests can also be ignored") { //----------------------------------------------------------------------------- -TEST("cppunit unwind will result in 1 failed test and 1 failed check") { - CPPUNIT_ASSERT_EQUAL_MESSAGE("cppunit happy", 1, 1); - CPPUNIT_ASSERT_EQUAL_MESSAGE("cppunit not happy", 1, 2); -} - -TEST("std::excpetion unwind will result in 1 failed test and 1 failed check") { +TEST("std::exception unwind will result in 1 failed test and 1 failed check") { throw std::runtime_error("something failed"); } @@ -172,7 +165,7 @@ TEST("verify and ignore check failures from previous tests") { TEST("verify that all appropriate tests have been executed") { TEST_FLUSH(); - EXPECT_EQUAL(25u, TEST_MASTER.getProgress().passCnt); + EXPECT_EQUAL(24u, TEST_MASTER.getProgress().passCnt); } //----------------------------------------------------------------------------- |