summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-04-27 16:39:44 +0200
committerMichael Stahl <mstahl@redhat.com>2017-04-27 16:42:37 +0200
commit86931aded4e603d244c9aef17c872f0b3807bee9 (patch)
treee2d5959b02b36f6c77f058544fe50880bfaf1f40 /sal
parent3eda8234acf09cd5a31cdcde76f04631a51fcc37 (diff)
sal: cppunittester: verify that CPPUNIT_TEST_NAME contains a test
Fail the test if CPPUNIT_TEST_NAME does not contain at least one existing test, which is much better than silently reporting OK(0). Change-Id: If2137764b24aa52dc35fe2368ee8fe38cb7dbece
Diffstat (limited to 'sal')
-rw-r--r--sal/cppunittester/cppunittester.cxx16
1 files changed, 13 insertions, 3 deletions
diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx
index 11078c7cf74b..7b321643a37a 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -197,15 +197,20 @@ struct test_name_compare
std::string maName;
};
-void addRecursiveTests(const std::vector<std::string>& test_names, CppUnit::Test* pTest, CppUnit::TestRunner& rRunner)
+bool addRecursiveTests(const std::vector<std::string>& test_names, CppUnit::Test* pTest, CppUnit::TestRunner& rRunner)
{
+ bool ret(false);
for (int i = 0; i < pTest->getChildTestCount(); ++i)
{
CppUnit::Test* pNewTest = pTest->getChildTestAt(i);
- addRecursiveTests(test_names, pNewTest, rRunner);
+ ret |= addRecursiveTests(test_names, pNewTest, rRunner);
if (std::find_if(test_names.begin(), test_names.end(), test_name_compare(pNewTest->getName())) != test_names.end())
+ {
rRunner.addTest(pNewTest);
+ ret = true;
+ }
}
+ return ret;
}
}
@@ -297,7 +302,12 @@ public:
std::vector<std::string> test_names;
boost::split(test_names, pVal, boost::is_any_of("\t "));
CppUnit::Test* pTest = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
- addRecursiveTests(test_names, pTest, runner);
+ bool const added(addRecursiveTests(test_names, pTest, runner));
+ if (!added)
+ {
+ std::cerr << "\nFatal error: CPPUNIT_TEST_NAME contains no valid tests\n";
+ return false;
+ }
}
else
{