From 7da5f591449ffddd9a4f680cb65a0faf73d0353e Mon Sep 17 00:00:00 2001 From: Bill Hoffa Date: Tue, 27 Aug 2019 08:32:06 -0500 Subject: Enable Serial Testcases - Provide the ability for test modules to be defined as serial tests - Execute the serial test jobs prior to launching all of the other test modules in parallel Change-Id: Iff10ad049f6bb0e5f0f3c168a1bb30736b1b983d Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/83110 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Reviewed-by: Nicholas E Bofferding --- src/usr/cxxtest/TestSuite.C | 41 ++++++++++++++++++++++++- src/usr/cxxtest/cxxtestexec.C | 70 ++++++++++++++++++++++++++++++++++++++----- src/usr/vfs/vfsrp.C | 4 +-- 3 files changed, 104 insertions(+), 11 deletions(-) (limited to 'src/usr') diff --git a/src/usr/cxxtest/TestSuite.C b/src/usr/cxxtest/TestSuite.C index 6f7e3fb2a..3b1499889 100755 --- a/src/usr/cxxtest/TestSuite.C +++ b/src/usr/cxxtest/TestSuite.C @@ -32,7 +32,6 @@ #include #include #include - #include trace_desc_t *g_trac_test = NULL; @@ -43,6 +42,9 @@ namespace CxxTest /******************************************************************************/ // Globals/Constants /******************************************************************************/ +//This is a list of testcases that are expected to run in a serial manner +// example: std::vector CxxSerialTests{"libtestrtloader.so"}; +std::vector CxxSerialTests{"libtesthwas.so"}; // // TestSuite members @@ -104,6 +106,43 @@ void doFailTest( ) } +void sortTests(std::vector & i_list, + std::vector & o_serial_list, + std::vector & o_parallel_list) +{ + o_serial_list.clear(); + o_serial_list.reserve(32); + o_parallel_list.clear(); + o_parallel_list.reserve(32); + + //Loop through list of all tests + for(std::vector::const_iterator i = i_list.begin(); + i != i_list.end(); ++i) + { + bool is_serial = false; + + for(std::vector::const_iterator j = CxxSerialTests.begin(); + j != CxxSerialTests.end(); ++j) + { + if (0 == strcmp(*i, *j)) + { + is_serial = true; + } + } + + if (is_serial) + { + TRACFCOMP( g_trac_test, "%s is a serial test",*i); + o_serial_list.push_back(*i); + } + else + { + TRACFCOMP( g_trac_test, "%s is a parallel test",*i); + o_parallel_list.push_back(*i); + } + } +} + /** * @brief Implement Fail action in unit tests * diff --git a/src/usr/cxxtest/cxxtestexec.C b/src/usr/cxxtest/cxxtestexec.C index 145537f66..b32c661f2 100644 --- a/src/usr/cxxtest/cxxtestexec.C +++ b/src/usr/cxxtest/cxxtestexec.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2017 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -32,7 +32,6 @@ #include #include #include -# #include #include @@ -46,7 +45,6 @@ namespace CxxTest // prototype void cxxinit( errlHndl_t &io_taskRetErrl ); - trace_desc_t *g_trac_cxxtest = NULL; TRAC_INIT(&g_trac_cxxtest, CXXTEST_COMP_NAME, KILOBYTE ); @@ -75,6 +73,8 @@ void cxxinit( errlHndl_t &io_taskRetErrl ) } cxxtask; errlHndl_t l_errl = NULL; std::vector module_list; + std::vector parallel_module_list; + std::vector serial_module_list; std::vector tasks; tid_t tidrc = 0; @@ -94,12 +94,16 @@ void cxxinit( errlHndl_t &io_taskRetErrl ) // count up the number of viable modules ahead of time TRACDCOMP( g_trac_cxxtest, "Counting CxxTestExec modules:" ); + //Get all modules, then sort into parallel and serial lists VFS::find_test_modules(module_list); - // start executing the CxxTest modules + CxxTest::sortTests(module_list, serial_module_list, parallel_module_list); - TRACFCOMP( g_trac_cxxtest, ENTER_MRK "Execute CxxTestExec, totalmodules=%d.", - module_list.size()); + // start executing the CxxTest modules + TRACFCOMP( g_trac_cxxtest, ENTER_MRK "Execute CxxTestExec, totalparallelmodules=%d, totalserialmodules=%d (overall total:%d)", + parallel_module_list.size(), + serial_module_list.size(), + parallel_module_list.size()+serial_module_list.size()); printkd( "\n Begin CxxTest...\n"); __sync_add_and_fetch(&CxxTest::g_ModulesStarted, 1); @@ -111,8 +115,58 @@ void cxxinit( errlHndl_t &io_taskRetErrl ) TS_FAIL("Error logs committed previously during IPL."); } - for(std::vector::const_iterator i = module_list.begin(); - i != module_list.end(); ++i) + for(std::vector::const_iterator i = serial_module_list.begin(); + i != serial_module_list.end(); ++i) + { + __sync_add_and_fetch(&CxxTest::g_ModulesStarted, 1); + + TRACFCOMP( g_trac_cxxtest, + "Now executing Serial Test Cases!"); + + // load module and call _init() + l_errl = VFS::module_load( *i ); + if ( l_errl ) + { + // vfs could not load a module and returned an errorlog. + // commit the errorlog, mark the test failed, and + // move on. + TS_FAIL( "ERROR: Task %s could not be loaded, committing errorlog", + *i ); + errlCommit( l_errl, CXXTEST_COMP_ID ); + continue; + } + + //First run all serial testcases + tidrc = task_exec( *i, NULL ); + TRACFCOMP( g_trac_cxxtest, "Launched serial task: %s tidrc=%d", + *i, tidrc ); + int status = 0; + task_wait_tid(tidrc, &status, NULL); + + if (status != TASK_STATUS_EXITED_CLEAN) + { + TRACFCOMP( g_trac_cxxtest, "Task %d crashed with status %d.", + tidrc, status ); + if(CxxTest::g_FailedTests < CxxTest::CXXTEST_FAIL_LIST_SIZE) + { + CxxTest::CxxTestFailedEntry *l_failedEntry = + &CxxTest::g_FailedTestList[CxxTest::g_FailedTests]; + sprintf(l_failedEntry->failTestFile, + "%s crashed", + *i); + l_failedEntry->failTestData = tidrc; + } + __sync_add_and_fetch(&CxxTest::g_FailedTests, 1); + } + else + { + TRACFCOMP( g_trac_cxxtest, "Task %d finished.", tidrc ); + } + } + + //Then run all parallel testcases + for(std::vector::const_iterator i = parallel_module_list.begin(); + i != parallel_module_list.end(); ++i) { __sync_add_and_fetch(&CxxTest::g_ModulesStarted, 1); diff --git a/src/usr/vfs/vfsrp.C b/src/usr/vfs/vfsrp.C index a103a09d0..aaf4aa57d 100644 --- a/src/usr/vfs/vfsrp.C +++ b/src/usr/vfs/vfsrp.C @@ -753,7 +753,7 @@ void VfsRp::get_test_modules(std::vector & o_list) const VfsSystemModule * vfsItr = (VfsSystemModule *) (iv_pnor_vaddr + VFS_EXTENDED_MODULE_TABLE_OFFSET); - //TRACDCOMP(g_trac_vfs,"finding test modules..."); + TRACFCOMP(g_trac_vfs,"finding test modules..."); while(vfsItr->module[0] != '\0') { @@ -761,7 +761,7 @@ void VfsRp::get_test_modules(std::vector & o_list) const { if (NULL != vfsItr->start) { - //TRACDCOMP( g_trac_vfs, "%s",vfsItr->module); + TRACDCOMP( g_trac_vfs, "%s",vfsItr->module); o_list.push_back(vfsItr->module); } } -- cgit v1.2.1