Skip to content

Commit

Permalink
Output list of cxxtest failures
Browse files Browse the repository at this point in the history
Include a list of the first 10 cxxtest failures with the summary
of the cxxtest results.

Change-Id: I932b63d29b26f6d5afff7c3f5a67679e2a66fd5f
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/36168
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
mgloff authored and dcrowell77 committed Feb 12, 2017
1 parent ea1efc2 commit 9fb6c6b
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 21 deletions.
18 changes: 6 additions & 12 deletions src/include/usr/cxxtest/TestSuite.H
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2016 */
/* Contributors Listed Below - COPYRIGHT 2011,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -39,6 +39,7 @@

#include <trace/interface.H>
#include <sys/sync.h>
#include <usr/cxxtest/cxxtest_data.H>

extern trace_desc_t *g_trac_test;

Expand All @@ -48,13 +49,14 @@ namespace CxxTest
/**
* @note extern declarations - see lib/cxxtest_data.C
*
* @see g_TotalTests, g_TraceCalls, g_Warnings, g_FailedTests
* @see g_TotalTests, g_TraceCalls, g_Warnings, g_FailedTests, g_FailedTestList
*/
extern uint64_t g_TotalTests;
extern uint64_t g_TraceCalls;
extern uint64_t g_Warnings;
extern uint64_t g_FailedTests;
extern barrier_t g_CxxTestBarrier;
extern CxxTestFailedEntry g_FailedTestList[CXXTEST_FAIL_LIST_SIZE];

/**
* @class TestSuite
Expand Down Expand Up @@ -87,6 +89,7 @@ void doFailAssert( const char *file,
void reportTotalTests( const char *suitename,
uint64_t numtests );

extern uint64_t g_ModulesStarted;
extern uint64_t g_ModulesCompleted;

#define _TS_TRY
Expand Down Expand Up @@ -117,15 +120,6 @@ extern uint64_t g_ModulesCompleted;
#define TS_FAIL(...) TRACFCOMP( g_trac_test, "!!!TS_FAIL> " __VA_ARGS__); \
CxxTest::doFailTest( __FILE__, __LINE__ )

// These are all implemented in the cxxtest_data.C that gets put into the base
// image.
extern uint64_t g_TotalTests;
extern uint64_t g_TraceCalls;
extern uint64_t g_Warnings;
extern uint64_t g_FailedTests;
extern uint64_t g_ModulesStarted;
extern uint64_t g_ModulesCompleted;

// Statistics structure for passing original pointers to the runtime test suite.
struct CxxTestStats
{
Expand All @@ -137,6 +131,6 @@ struct CxxTestStats
uint64_t* modulesCompleted;
};

}
} // namespace CxxTest

#endif // __cxxtest__TestSuite_h__
52 changes: 52 additions & 0 deletions src/include/usr/cxxtest/cxxtest_data.H
@@ -0,0 +1,52 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/cxxtest/cxxtest_data.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2016,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */

/** @file cxxtest_data.H
*
*/


#ifndef __cxxtest__cxxtest_data_h__
#define __cxxtest__cxxtest_data_h__


namespace CxxTest
{

enum
{
CXXTEST_FILENAME_SIZE = 50,
CXXTEST_FAIL_LIST_SIZE = 10
};

struct CxxTestFailedEntry
{
char failTestFile[CXXTEST_FILENAME_SIZE];
uint64_t failTestData;
};

} // namespace CxxTest

#endif // __cxxtest__cxxtest_data_h__
12 changes: 11 additions & 1 deletion src/lib/cxxtest_data.C
Expand Up @@ -5,7 +5,9 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* COPYRIGHT International Business Machines Corp. 2011,2014 */
/* Contributors Listed Below - COPYRIGHT 2011,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
Expand All @@ -22,6 +24,7 @@
/* IBM_PROLOG_END_TAG */

#include <stdint.h>
#include <usr/cxxtest/cxxtest_data.H>
/**
* @brief global vars to keep track of unit tests,
*
Expand All @@ -47,6 +50,10 @@
* This variable is also used to allow a code in a binary image
* not containing the testcase modules to query the number of failed tests
*
* @var g_FailedTestList - updated by TS_FAIL macro in the unit test image.
* This variable is also used to allow code in a binary image not containing
* the testcase modules to query a list of failed tests
*
*/

namespace CxxTest
Expand All @@ -59,5 +66,8 @@ uint64_t g_FailedTests = 0;
uint64_t g_ModulesStarted = 0;
uint64_t g_ModulesCompleted= 0;

struct CxxTestFailedEntry g_FailedTestList[CXXTEST_FAIL_LIST_SIZE];


}

20 changes: 19 additions & 1 deletion src/usr/cxxtest/TestSuite.C
Expand Up @@ -5,7 +5,9 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* COPYRIGHT International Business Machines Corp. 2011,2014 */
/* Contributors Listed Below - COPYRIGHT 2011,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
Expand All @@ -29,6 +31,7 @@
#include <limits.h>
#include <stdarg.h>
#include <arch/ppc.H>
#include <string.h>

#include <cxxtest/TestSuite.H>

Expand Down Expand Up @@ -89,6 +92,14 @@ void doWarn( )
void doFailTest( )
{

TRACDCOMP( g_trac_test,
"!!! > Test Failed " );
if(g_FailedTests < CXXTEST_FAIL_LIST_SIZE)
{
memcpy(g_FailedTestList[g_FailedTests].failTestFile,
"---",
3);
}
__sync_add_and_fetch( &g_FailedTests, 1 );

}
Expand All @@ -108,6 +119,13 @@ void doFailTest( const char *filename, uint32_t linenum )
"!!! > Test %s Failed at line %d ",
filename,
linenum );
if(g_FailedTests < CXXTEST_FAIL_LIST_SIZE)
{
memcpy(g_FailedTestList[g_FailedTests].failTestFile,
filename,
CXXTEST_FILENAME_SIZE);
g_FailedTestList[g_FailedTests].failTestData = linenum;
}
__sync_add_and_fetch( &g_FailedTests, 1 );

}
Expand Down
51 changes: 44 additions & 7 deletions src/usr/cxxtest/cxxtestexec.C
Expand Up @@ -5,7 +5,9 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* COPYRIGHT International Business Machines Corp. 2011,2014 */
/* Contributors Listed Below - COPYRIGHT 2011,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
Expand All @@ -24,6 +26,7 @@
#include <vfs/vfs.H>
#include <sys/task.h>
#include <string.h>
#include <stdio.h>
#include <kernel/console.H>
#include <sys/time.h>
#include <sys/sync.h>
Expand Down Expand Up @@ -65,11 +68,24 @@ TASK_ENTRY_MACRO( cxxinit );

void cxxinit( errlHndl_t &io_taskRetErrl )
{
struct cxxtask_t
{
tid_t tid;
const char * module;
} cxxtask;
errlHndl_t l_errl = NULL;
std::vector<const char *> module_list;
std::vector<tid_t> tasks;
std::vector<cxxtask_t> tasks;
tid_t tidrc = 0;

for (uint64_t i = 0; i < CxxTest::CXXTEST_FAIL_LIST_SIZE; i++)
{
memset(CxxTest::g_FailedTestList[i].failTestFile,
0x00,
CxxTest::CXXTEST_FILENAME_SIZE);
CxxTest::g_FailedTestList[i].failTestData = 0;
};

// output a blank line so that it's easier to find the beginning of
// CxxTest
TRACDCOMP( g_trac_cxxtest, " ");
Expand Down Expand Up @@ -120,28 +136,40 @@ void cxxinit( errlHndl_t &io_taskRetErrl )
tidrc = task_exec( *i, NULL );
TRACFCOMP( g_trac_cxxtest, "Launched task: %s tidrc=%d",
*i, tidrc );
tasks.push_back(tidrc);
cxxtask.tid = tidrc;
cxxtask.module = *i;
tasks.push_back(cxxtask);
}

TRACFCOMP( g_trac_cxxtest, "Waiting for all (%d) tasks to finish....",
CxxTest::g_ModulesStarted );

// wait for all the launched tasks to finish
for (std::vector<tid_t>::iterator t = tasks.begin();
for (std::vector<cxxtask_t>::iterator t = tasks.begin();
t != tasks.end();
++t)
{
int status = 0;
task_wait_tid(*t, &status, NULL);
task_wait_tid(t->tid, &status, NULL);

if (status != TASK_STATUS_EXITED_CLEAN)
{
TRACFCOMP( g_trac_cxxtest, "Task %d crashed.", *t );
TRACFCOMP( g_trac_cxxtest, "Task %d crashed with status %d.",
t->tid, 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",
t->module);
l_failedEntry->failTestData = t->tid;
}
__sync_add_and_fetch(&CxxTest::g_FailedTests, 1);
}
else
{
TRACFCOMP( g_trac_cxxtest, "Task %d finished.", *t );
TRACFCOMP( g_trac_cxxtest, "Task %d finished.", t->tid );
}
}

Expand All @@ -158,6 +186,15 @@ void cxxinit( errlHndl_t &io_taskRetErrl )
CxxTest::g_Warnings );
TRACFCOMP( g_trac_cxxtest, " trace calls: %d",
CxxTest::g_TraceCalls );
for (uint64_t i = 0;
(i < CxxTest::g_FailedTests) && (i < CxxTest::CXXTEST_FAIL_LIST_SIZE);
i++ )
{
TRACFCOMP( g_trac_cxxtest, " failed test[%d]: %s (%d)",
i,
CxxTest::g_FailedTestList[i].failTestFile,
CxxTest::g_FailedTestList[i].failTestData);
}

// @todo dump out an informational errorlog??

Expand Down

0 comments on commit 9fb6c6b

Please sign in to comment.