summaryrefslogtreecommitdiffstats
path: root/src/usr/cxxtest
diff options
context:
space:
mode:
authorMark Wenning <wenning@us.ibm.com>2011-05-18 15:52:46 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2011-06-01 14:07:35 -0500
commit8509613766f5b1074f89589e653bcb8a4cec2ac0 (patch)
treee5445f93b2bb1c1a9741b737f217b0385e0e5f96 /src/usr/cxxtest
parent329be941b1056a3b2e68fcfdf1bc4a9cd5335c84 (diff)
downloadtalos-hostboot-8509613766f5b1074f89589e653bcb8a4cec2ac0.tar.gz
talos-hostboot-8509613766f5b1074f89589e653bcb8a4cec2ac0.zip
CxxTest logs messages to trace buffer
- mark globals with g_ - thread safety - remove more tabs. - Add globals and accessors to track totaltests, failedtests, warnings, tracecalls. - Modify cxxtestgen.pl to add reportTotalTests() call - uncommented printk's in TestSuite.C - cxxtestgen.pl just prints out the test suite - exampletest.H has more descriptive test names, forces a FAIL, WARN, and TRACE - add a printk() to cxxtest module so that we know it ran. Change-Id: I3ff25b228f17371b6f84bdb16309015818867266 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/90 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/cxxtest')
-rwxr-xr-xsrc/usr/cxxtest/TestSuite.C147
-rw-r--r--src/usr/cxxtest/cxxtestexec.C3
-rwxr-xr-xsrc/usr/cxxtest/cxxtestgen.pl14
3 files changed, 150 insertions, 14 deletions
diff --git a/src/usr/cxxtest/TestSuite.C b/src/usr/cxxtest/TestSuite.C
index c42e23a72..17460ae3b 100755
--- a/src/usr/cxxtest/TestSuite.C
+++ b/src/usr/cxxtest/TestSuite.C
@@ -3,12 +3,38 @@
#ifndef __cxxtest__TestSuite_cpp__
#define __cxxtest__TestSuite_cpp__
-#include <cxxtest/TestSuite.H>
#include <stdarg.h>
#include <arch/ppc.H>
+#include <kernel/console.H>
+
+#include <cxxtest/TestSuite.H>
namespace CxxTest
{
+ /******************************************************************************/
+ // Globals/Constants
+ /******************************************************************************/
+
+ /**
+ * @brief global vars to keep track of unit tests.
+ *
+ * totaltests - initialized to 0, updated by reporttotaltests() below.
+ * each test suite will call reporttotaltests after all tests have
+ * run with the total number of tests for that suite.
+ * Once all the testsuites have run, the global totaltests will hold
+ * the total of number of unit test for that run.
+ *
+ * Each unit test macro (TS_TRACE, TS_WARN, and TS_FAIL) will update
+ * the proper variable. At the end the unit tester will print out
+ * the totals.
+ * // Global cxxtest values - Keep global so it can be found in syms file
+ */
+ uint64_t g_TotalTests = 0;
+ uint64_t g_TraceCalls = 0;
+ uint64_t g_Warnings = 0;
+ uint64_t g_FailedTests = 0;
+
+
//
// TestSuite members
//
@@ -16,25 +42,126 @@ namespace CxxTest
void TestSuite::setUp() {}
void TestSuite::tearDown() {}
- //
- // Some non-template functions
- //
+ /**
+ *
+ * @brief Implement trace action in unit tests
+ *
+ * @param [in] pointer to filename (not used right now )
+ * @param [in] line number
+ * @param [in] trace message
+ *
+ * @return void
+ *
+ */
void doTrace( const char *file, unsigned line, const char *message )
{
- //tracker().trace( file, line, message );
- //printk("%s %u %s\n",file,line,message);
+ // tracker().trace( file, line, message );
+ printk("TRACE: %s %u %s\n", file, line, message);
+ __sync_add_and_fetch( &g_TraceCalls, 1 );
}
+ /**
+ *
+ * @brief Implement warn action in unit tests
+ *
+ * @param [in] pointer to filename (not used right now )
+ * @param [in] line number
+ * @param [in] warning message
+ *
+ * @return void
+ *
+ */
void doWarn( const char *file, unsigned line, const char *message )
{
- //tracker().warning( file, line, message );
- //printk("%s %u %s\n",file,line,message);
+ // tracker().warning( file, line, message );
+ printk("WARN: %s %u %s\n", file, line, message);
+ __sync_add_and_fetch( &g_Warnings, 1 );
}
+ /**
+ * @brief Implement Fail action in unit tests
+ *
+ * @param [in] pointer to filename (not used right now )
+ * @param [in] line number
+ * @param [in] failure message
+ *
+ * @return void
+ */
+
void doFailTest( const char *file, unsigned line, const char *message )
{
- //tracker().failedTest( file, line, message );
- //TS_ABORT();
+ // tracker().failedTest( file, line, message );
+ printk("FAIL: %s %u %s\n", file, line, message);
+ __sync_add_and_fetch( &g_FailedTests, 1 );
+ }
+
+ /**
+ * @brief Report total number of unit tests in a test suite
+ *
+ * A unit test suite will call this to report how many tests
+ * it has. The call itself is autogenerated
+ *
+ * @param [in] pointer to filename (not used right now )
+ * @param [in] line number
+ * @param [in] trace message
+ *
+ * @return void
+ */
+ void reportTotalTests( const char *suitename, uint64_t numtests )
+ {
+
+ // $$TODO do nothing with the suite name for now, later it may be useful
+ __sync_add_and_fetch( &g_TotalTests, numtests );
+
+ return;
+ }
+
+ /**
+ * @brief accessor to read global totaltests var
+ * @TODO make these readonly accessors
+ *
+ * @return number of total tests
+ */
+ uint64_t getTotalTests(void)
+ {
+
+ return g_TotalTests;
+ }
+
+ /**
+ * @brief accessor to read global failedtests var
+ * @TODO make these readonly accessors
+ *
+ * @return total number off failures executed
+ */
+ uint64_t getFailedTests(void)
+ {
+
+ return g_FailedTests;
+ }
+
+ /**
+ * @brief accessor to read global warnings var
+ * @TODO make these readonly accessors
+ *
+ * @return total number of warnings executed
+ */
+ uint64_t getWarnings(void)
+ {
+
+ return g_Warnings;
+ }
+
+ /**
+ * @brief accessor to read global tracecalls var
+ * @TODO make these readonly accessors
+ *
+ * @return total number of trace calls executed
+ */
+ uint64_t getTraceCalls(void)
+ {
+
+ return g_TraceCalls;
}
};
diff --git a/src/usr/cxxtest/cxxtestexec.C b/src/usr/cxxtest/cxxtestexec.C
index 371bb1274..274f386ef 100644
--- a/src/usr/cxxtest/cxxtestexec.C
+++ b/src/usr/cxxtest/cxxtestexec.C
@@ -1,6 +1,7 @@
#include <sys/vfs.h>
#include <sys/task.h>
#include <string.h>
+#include <kernel/console.H>
/* Iterate through all modules in the VFS named "libtest*" and create children
* tasks to execute them.
@@ -10,6 +11,8 @@ void _start(void*)
{
VfsSystemModule* vfsItr = &VFS_MODULES[0];
+ printk( "Executing CxxTestExec module.\n");
+
while(vfsItr->module[0] != '\0')
{
if (0 == memcmp(vfsItr->module, "libtest", 7))
diff --git a/src/usr/cxxtest/cxxtestgen.pl b/src/usr/cxxtest/cxxtestgen.pl
index 65a9ac8a4..da7c13356 100755
--- a/src/usr/cxxtest/cxxtestgen.pl
+++ b/src/usr/cxxtest/cxxtestgen.pl
@@ -618,16 +618,17 @@ sub writeHostBootPreamble() {
print "#include <sys/task.h>\n";
print "#include <trace/interface.H>\n";
- ## print "#include <cxxtest/TestSuite.h>\n";
+ print "#include <cxxtest/TestSuite.H>\n";
print "\n";
$didHBPreamble = 1;
}
sub writeHostBootSuites() {
- my ( $suitecount, $suitevar );
+ my ( $suitecount, $suitevar, $testcount );
$suitecount = 1; # initialize suite count
+ $testcount = 0; # initialize test count
foreach (@suites) {
$suite = $_;
@@ -663,13 +664,18 @@ sub writeHostBootSuites() {
## run each of the tests in the list
foreach (@{suiteTests()}) {
$test = $_;
- print "\tprintk(\"Executing test module ", testName(), ".\\n\");\n";
+ if ( $debug ) { print "\tprintk(\"Executing test module ", testName(), ".\\n\");\n"; }
printf "\t$suitevar->%s();\n\n", testName();
+ $testcount++;
}
+
print "\n";
## delete the suite instance
print "\tdelete ", $suitevar, ";\n";
+
+ print "\n";
+ print "\tCxxTest::reportTotalTests( \"", suiteName(), "\", $testcount );\n";
$suitecount++; # bump to the next suite
}
@@ -682,7 +688,7 @@ sub write_start() {
print "\n";
print "trace_desc_t *g_trac_test = NULL;\n";
- print "TRAC_INIT(&g_trac_test, \"EXAMPLE\", 4096);\n";
+ print "TRAC_INIT(&g_trac_test, \"", suiteName(), "\", 4096);\n";
print "\n\n";
OpenPOWER on IntegriCloud