From e2fec417ea4e0b4f8dc32df8397e87a5e9cf0481 Mon Sep 17 00:00:00 2001 From: Mitch Watrous Date: Wed, 12 Sep 2012 14:59:21 -0700 Subject: [PATCH] Bug 1493 - test.py --list should show the test type --- src/core/model/test.cc | 30 ++++++++++++++++++++++++++---- test.py | 12 +++++++++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/core/model/test.cc b/src/core/model/test.cc index 01cd4b553..3d13d6b29 100644 --- a/src/core/model/test.cc +++ b/src/core/model/test.cc @@ -24,6 +24,7 @@ #include #include #include +#include namespace ns3 { @@ -102,7 +103,8 @@ private: std::string ReplaceXmlSpecialCharacters (std::string xml) const; void PrintReport (TestCase *test, std::ostream *os, bool xml, int level); void PrintTestNameList (std::list::const_iterator begin, - std::list::const_iterator end) const; + std::list::const_iterator end, + bool printTestType) const; void PrintTestTypeList (void) const; void PrintHelp (const char *programName) const; std::list FilterTests (std::string testName, enum TestSuite::Type testType) const; @@ -547,6 +549,7 @@ TestRunnerImpl::PrintHelp (const char *program_name) const << " --help : print these options" << std::endl << " --print-test-name-list : print the list of names of tests available" << std::endl << " --list : an alias for --print-test-name-list" << std::endl + << " --print-test-types : print the type of tests along with their names" << std::endl << " --print-test-type-list : print the list of types of tests available" << std::endl << " --print-temp-dir : Print name of temporary directory before running the tests" << std::endl << " --test-type=TYPE : Process only tests of type TYPE" << std::endl @@ -569,11 +572,25 @@ TestRunnerImpl::PrintHelp (const char *program_name) const void TestRunnerImpl::PrintTestNameList (std::list::const_iterator begin, - std::list::const_iterator end) const + std::list::const_iterator end, + bool printTestType) const { + std::map label; + + label[TestSuite::ALL] = "all "; + label[TestSuite::BVT] = "bvt "; + label[TestSuite::UNIT] = "unit "; + label[TestSuite::SYSTEM] = "system "; + label[TestSuite::EXAMPLE] = "example "; + label[TestSuite::PERFORMANCE] = "performance "; + for (std::list::const_iterator i = begin; i != end; ++i) { - TestCase *test = *i; + TestSuite * test= dynamic_cast(*i); + if (printTestType) + { + std::cout << label[test->GetTestType ()]; + } std::cout << test->GetName () << std::endl; } } @@ -624,6 +641,7 @@ TestRunnerImpl::Run (int argc, char *argv[]) bool printTempDir = false; bool printTestTypeList = false; bool printTestNameList = false; + bool printTestTypeAndName = false; char *progname = argv[0]; argv++; @@ -662,6 +680,10 @@ TestRunnerImpl::Run (int argc, char *argv[]) { printTestNameList = true; } + else if (strcmp (arg, "--print-test-types") == 0) + { + printTestTypeAndName = true; + } else if (strcmp (arg, "--print-test-type-list") == 0) { printTestTypeList = true; @@ -750,7 +772,7 @@ TestRunnerImpl::Run (int argc, char *argv[]) } if (printTestNameList) { - PrintTestNameList (tests.begin (), tests.end ()); + PrintTestNameList (tests.begin (), tests.end (), printTestTypeAndName); return 0; } if (printTestTypeList) diff --git a/test.py b/test.py index 59b598bad..a85319c96 100755 --- a/test.py +++ b/test.py @@ -1112,12 +1112,18 @@ def run_tests(): if options.list: if len(options.constrain): - path_cmd = os.path.join("utils", test_runner_name + " --print-test-name-list --test-type=%s" % options.constrain) + path_cmd = os.path.join("utils", test_runner_name + " --print-test-name-list --print-test-types --test-type=%s" % options.constrain) else: - path_cmd = os.path.join("utils", test_runner_name + " --print-test-name-list") + path_cmd = os.path.join("utils", test_runner_name + " --print-test-name-list --print-test-types") (rc, standard_out, standard_err, et) = run_job_synchronously(path_cmd, os.getcwd(), False, False) list_items = standard_out.split('\n') - print "\n".join(sorted(list_items)) + list_items.sort() + print "Test Type Test Name" + print "--------- ---------" + for item in list_items: + if len(item.strip()): + print item + print if options.kinds or options.list: return