Skip to content

Commit

Permalink
Enable Serial Testcases
Browse files Browse the repository at this point in the history
  - 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 <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Nicholas E Bofferding <bofferdn@us.ibm.com>
  • Loading branch information
wghoffa authored and Nicholas E Bofferding committed Dec 6, 2019
1 parent c46f1ee commit 7da5f59
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 12 deletions.
6 changes: 5 additions & 1 deletion src/include/usr/cxxtest/TestSuite.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2018 */
/* Contributors Listed Below - COPYRIGHT 2011,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -40,6 +40,7 @@
#include <trace/interface.H>
#include <sys/sync.h>
#include <usr/cxxtest/cxxtest_data.H>
#include <vector>

extern trace_desc_t *g_trac_test;

Expand Down Expand Up @@ -76,6 +77,9 @@ public:

class AbortTest {};

void sortTests(std::vector<const char *> & i_list,
std::vector<const char *> & o_serial_list,
std::vector<const char *> & o_parallel_list);
void doTrace( );
void doWarn( );
void doFailTest( );
Expand Down
41 changes: 40 additions & 1 deletion src/usr/cxxtest/TestSuite.C
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <stdarg.h>
#include <arch/ppc.H>
#include <string.h>

#include <cxxtest/TestSuite.H>

trace_desc_t *g_trac_test = NULL;
Expand All @@ -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<const char *> CxxSerialTests{"libtestrtloader.so"};
std::vector<const char *> CxxSerialTests{"libtesthwas.so"};

//
// TestSuite members
Expand Down Expand Up @@ -104,6 +106,43 @@ void doFailTest( )

}

void sortTests(std::vector<const char *> & i_list,
std::vector<const char *> & o_serial_list,
std::vector<const char *> & 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 char *>::const_iterator i = i_list.begin();
i != i_list.end(); ++i)
{
bool is_serial = false;

for(std::vector<const char *>::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
*
Expand Down
70 changes: 62 additions & 8 deletions src/usr/cxxtest/cxxtestexec.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2017 */
/* Contributors Listed Below - COPYRIGHT 2011,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand All @@ -32,7 +32,6 @@
#include <sys/sync.h>
#include <errl/errlentry.H>
#include <errl/errlmanager.H>
#
#include <initservice/taskargs.H>
#include <cxxtest/TestSuite.H>

Expand All @@ -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 );

Expand Down Expand Up @@ -75,6 +73,8 @@ void cxxinit( errlHndl_t &io_taskRetErrl )
} cxxtask;
errlHndl_t l_errl = NULL;
std::vector<const char *> module_list;
std::vector<const char *> parallel_module_list;
std::vector<const char *> serial_module_list;
std::vector<cxxtask_t> tasks;
tid_t tidrc = 0;

Expand All @@ -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);
Expand All @@ -111,8 +115,58 @@ void cxxinit( errlHndl_t &io_taskRetErrl )
TS_FAIL("Error logs committed previously during IPL.");
}

for(std::vector<const char *>::const_iterator i = module_list.begin();
i != module_list.end(); ++i)
for(std::vector<const char *>::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 char *>::const_iterator i = parallel_module_list.begin();
i != parallel_module_list.end(); ++i)
{
__sync_add_and_fetch(&CxxTest::g_ModulesStarted, 1);

Expand Down
4 changes: 2 additions & 2 deletions src/usr/vfs/vfsrp.C
Original file line number Diff line number Diff line change
Expand Up @@ -753,15 +753,15 @@ void VfsRp::get_test_modules(std::vector<const char *> & 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')
{
if (0 == memcmp(vfsItr->module, "libtest", 7))
{
if (NULL != vfsItr->start)
{
//TRACDCOMP( g_trac_vfs, "%s",vfsItr->module);
TRACDCOMP( g_trac_vfs, "%s",vfsItr->module);
o_list.push_back(vfsItr->module);
}
}
Expand Down

0 comments on commit 7da5f59

Please sign in to comment.