summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMark Wenning <wenning@us.ibm.com>2011-07-22 16:08:28 -0500
committerMark W. Wenning <wenning@us.ibm.com>2011-07-28 19:01:14 -0500
commitf5b3b1b3de680ef354419b74b50afe8b93012a4e (patch)
tree90374aade4a6a72dc38ae5a49b4b128e22fffafb /src
parentd7e9478f1de907b1b3d4923b507964222cb224fe (diff)
downloadtalos-hostboot-f5b3b1b3de680ef354419b74b50afe8b93012a4e.tar.gz
talos-hostboot-f5b3b1b3de680ef354419b74b50afe8b93012a4e.zip
RTC 3367, 3321 TS_FAIL and TS_WARN should send to trace buffer instead of printk
- first commit - add cxxtesttest.H unit test - comment out warn and fail from unit tests, leave for sandbox builds - make citest finishes OK - merge problems with gerrit Change-Id: Id9157837e1511eb1aebb13aeadd2286a8dce5eb3 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/210 Tested-by: Jenkins Server Reviewed-by: Mark W. Wenning <wenning@us.ibm.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/build/citest/autocitest120
-rwxr-xr-xsrc/include/usr/cxxtest/TestSuite.H27
-rw-r--r--src/include/usr/trace/interface.H4
-rw-r--r--src/makefile2
-rwxr-xr-xsrc/usr/cxxtest/TestSuite.C43
-rw-r--r--src/usr/cxxtest/makefile19
-rw-r--r--src/usr/cxxtest/test/cxxtesttest.H120
-rw-r--r--src/usr/cxxtest/test/makefile23
8 files changed, 322 insertions, 36 deletions
diff --git a/src/build/citest/autocitest b/src/build/citest/autocitest
index 45abdd4b0..6d5cbb00b 100755
--- a/src/build/citest/autocitest
+++ b/src/build/citest/autocitest
@@ -1,4 +1,21 @@
#!/bin/bash
+#############################################################################
+# $IBMCopyrightBlock:
+#
+# IBM Confidential
+#
+# Licensed Internal Code Source Materials
+#
+# IBM HostBoot Licensed Internal Code
+#
+# (C) Copyright IBM Corp. 2011
+#
+# The source code for this program is not published or other-
+# wise divested of its trade secrets, irrespective of what has
+# been deposited with the U.S. Copyright Office.
+#$
+#############################################################################
+
################################################################################
## Simics automation using autosim
## 2011-05-23 mww modified to run hostboot in simics
@@ -49,6 +66,46 @@ function stopserver()
}
+function runtraceHB()
+{
+
+ echo "Collect traceHB info..."
+ `pwd`
+
+ autosim $NOWIN --simcmd "@os.environ[\"HOSTBOOT_STRINGFILE\"]=\"${SBXHOME}/img/hbotStringFile\" "
+ if [ $? -ne 0 ] ; then
+ echo "ERROR 1: Unable to run $?"
+ stopsim
+ stopserver
+ exit 1
+ fi
+
+ autosim $NOWIN --simcmd "@os.environ[\"HOSTBOOT_SYMS\"]=\"${SBXHOME}/img/hbicore_test.syms\" "
+ if [ $? -ne 0 ] ; then
+ echo "ERROR 2: Unable to run $?"
+ stopsim
+ stopserver
+ exit 1
+ fi
+
+ autosim $NOWIN --simcmd "run-python-file ${SBXHOME}/src/build/trace/traceHB.py"
+ if [ $? -ne 0 ] ; then
+ echo "ERROR 3: Unable to run $?"
+ stopsim
+ stopserver
+ exit 1
+ fi
+
+ autosim $NOWIN --simcmd "hb-trace"
+ if [ $? -ne 0 ] ; then
+ echo "ERROR 4 : Unable to run $?"
+ stopsim
+ stopserver
+ exit 1
+ fi
+
+}
+
## mww verbose is the default.
VERBOSE=" --verbose"
@@ -101,20 +158,29 @@ fi
## Find the .syms file for the image. Remove extension, add .syms.
HBICORE_TEST_SYMS="${HBICORE_TEST%%.*}.syms"
+## Find the hbotStringfile for traceHB.
+HBICORE_TEST_STRINGFILE="${SBXHOME}/img/hbotStringFile"
+
+## Set the path to the traceHB.py script
+TRACEHB_PYTHON_FILE="${SBXHOME}/src/build/trace/traceHB.py"
+
+CPFILES="${SBXHOME}/src/build/tools/cpfiles.pl"
## let's get set up
cd $SBXHOME
echo "$0"
-echo "VERBOSE = $VERBOSE"
-echo "NOWIN = $NOWIN"
-echo "BACKING_TREE = $DRIVER"
-echo "TEST_SANDBOX = $TEST_SANDBOX"
-echo "HBICORE_TEST = $HBICORE_TEST"
-echo "HBICORE_TEST_SYMS = $HBICORE_TEST_SYMS"
-echo "SANDBOXRC = $SANDBOXRC"
-echo "SBXHOME = $SBXHOME"
+echo "VERBOSE = $VERBOSE"
+echo "NOWIN = $NOWIN"
+echo "BACKING_TREE = $DRIVER"
+echo "TEST_SANDBOX = $TEST_SANDBOX"
+echo "HBICORE_TEST = $HBICORE_TEST"
+echo "HBICORE_TEST_SYMS = $HBICORE_TEST_SYMS"
+echo "HBICORE_TEST_STRINGFILE = $HBICORE_TEST_STRINGFILE"
+echo "TRACEHB_PYTHON_FILE = $TRACEHB_PYTHON_FILE"
+echo "SANDBOXRC = $SANDBOXRC"
+echo "SBXHOME = $SBXHOME"
echo "current directory is " `pwd`
waitkb
@@ -158,6 +224,7 @@ else
fi
fi
+
waitkb
# Run set up in current shell
@@ -174,12 +241,20 @@ if [ $? -ne 0 ] ; then
exit 1
fi
-
waitkb
## under normal circumstances $sb would be set by start_simics
export sb=$SBXHOME/$TEST_SANDBOX/src
-echo $sb
+echo "sandbox dir = $sb"
+
+
+## waitkb
+##
+## echo "Set up for traceHB.py:"
+## echo "Copy .syms, bin, hbotStringfile, etc to base sandbox dir."
+## echo "$sb"
+## $CPFILES $sb
+
echo "** Set up simics directories **"
echo "start_simics -no_start -machine $MACHINE" > $sb/my_simics_env_setup
@@ -262,7 +337,12 @@ mods_started_addr=`grep "CxxTest::g_ModulesStarted" \
${SBXHOME}/${HBICORE_TEST_SYMS} | awk '{split($0,a,","); print a[2]}'`
mods_completed_addr=`grep "CxxTest::g_ModulesCompleted" \
${SBXHOME}/${HBICORE_TEST_SYMS} | awk '{split($0,a,","); print a[2]}'`
-
+
+## borrowed from CamVan's python script
+trace_buffer_addr=`grep "g_desc_array" \
+ ${SBXHOME}/${HBICORE_TEST_SYMS} | awk '{split($0,a,","); print a[2]}'`
+trace_buffer_size=`grep "g_desc_array" \
+ ${SBXHOME}/${HBICORE_TEST_SYMS} | awk '{split($0,a,","); print a[4]}'`
## note, don't use $VERBOSE here or you get all sorts of extra junk in the output file.
echo "Wait for unit test completion."
@@ -341,8 +421,19 @@ echo "ERROR: Unable to run $?"
exit 1
fi
+## run CamVan's python script to dump out the trace logs
+echo "====> dump trace buffer(s)..."
+runtraceHB 1> $SBXHOME/traceHB.log 2> /dev/null
+if [ $? -ne 0 ] ; then
+echo "ERROR: Unable to run $?"
+ stopsim
+ stopserver
+exit 1
+fi
+########################################################
## done. Stop the simulation
+########################################################
stopsim
@@ -350,13 +441,18 @@ stopsim
stopserver
-
## print out ending.
timestamp=`date +'%H:%M:%S'`
echo "----------------- Printk Buffer -------------------"
cat $SBXHOME/testprintk.log
+echo "----------------- traceHB Buffer -------------------"
+cat $SBXHOME/traceHB.log
+
+
+
+
echo
echo "==================================================="
if [ $timeout = 0 ] ; then
diff --git a/src/include/usr/cxxtest/TestSuite.H b/src/include/usr/cxxtest/TestSuite.H
index 5674bf164..e3fa332d1 100755
--- a/src/include/usr/cxxtest/TestSuite.H
+++ b/src/include/usr/cxxtest/TestSuite.H
@@ -65,13 +65,18 @@ public:
class AbortTest {};
-void doTrace( void );
-void doWarn( const char *file, unsigned line, const char *message );
-void doFailTest( const char *file, unsigned line, const char *message );
-void doFailAssert( const char *file, unsigned line, const char *expression, const char *message );
+void doTrace( );
+void doWarn( );
+void doFailTest( );
+void doFailTest( const char *filename, uint32_t linenum );
+void doFailAssert( const char *file,
+ unsigned line,
+ const char *expression,
+ const char *message );
-void reportTotalTests( const char *suitename, uint64_t numtests );
+void reportTotalTests( const char *suitename,
+ uint64_t numtests );
extern uint64_t g_ModulesCompleted;
@@ -85,16 +90,18 @@ extern uint64_t g_ModulesCompleted;
#define _TS_CATCH_ABORT(b)
// TS_TRACE
-#define TS_TRACE(...) TRACDCOMP( g_trac_test, __VA_ARGS__); CxxTest::doTrace()
+#define TS_TRACE(...) TRACDCOMP( g_trac_test, "TS_TRACE> "__VA_ARGS__ ); \
+ CxxTest::doTrace( )
// TS_WARN
-#define _TS_WARN(f,l,e) CxxTest::doWarn( (f), (l), e )
-#define TS_WARN(e) _TS_WARN( __FILE__, __LINE__, e )
+#define TS_WARN(...) TRACDCOMP( g_trac_test, "!TS_WARN> " __VA_ARGS__ ); \
+ CxxTest::doWarn( )
+
// TS_FAIL
-#define _TS_FAIL(f,l,e) CxxTest::doFailTest( (f), (l), e )
-#define TS_FAIL(e) _TS_FAIL( __FILE__, __LINE__, e )
+#define TS_FAIL(...) TRACDCOMP( g_trac_test, "!!!TS_FAIL> " __VA_ARGS__); \
+ CxxTest::doFailTest( __FILE__, __LINE__ )
}
diff --git a/src/include/usr/trace/interface.H b/src/include/usr/trace/interface.H
index 84c2e5217..432b69648 100644
--- a/src/include/usr/trace/interface.H
+++ b/src/include/usr/trace/interface.H
@@ -7,7 +7,7 @@
*
* IBM HostBoot Licensed Internal Code
*
- * (C) Copyright IBM Corp. 2011
+ * (C) Copyright IBM Corp. 2004 - 2011
*
* The source code for this program is not published or other-
* wise divested of its trade secrets, irrespective of what has
@@ -45,6 +45,8 @@
#define ENTER_MRK ">>"
#define EXIT_MRK "<<"
#define ERR_MRK "E>"
+#define FAIL_MRK "F>"
+#define WARN_MRK "W>"
#define INFO_MRK "I>"
#define ARG_MRK "A>"
diff --git a/src/makefile b/src/makefile
index 3cf18cf52..3c1a75a15 100644
--- a/src/makefile
+++ b/src/makefile
@@ -43,7 +43,7 @@ DIRECT_BOOT_MODULES = example
RUNTIME_MODULES =
TESTCASE_MODULES = cxxtest testerrl testdevicefw testsyslib \
testscom testxscom testtargeting testinitservice testkernel \
- testhwpf testecmddatabuffer tasktest2
+ testhwpf testecmddatabuffer tasktest2 testcxxtest
RELOCATABLE_IMAGE_LDFLAGS = -pie --export-dynamic
diff --git a/src/usr/cxxtest/TestSuite.C b/src/usr/cxxtest/TestSuite.C
index 2af815346..071c322d2 100755
--- a/src/usr/cxxtest/TestSuite.C
+++ b/src/usr/cxxtest/TestSuite.C
@@ -46,12 +46,11 @@ void TestSuite::tearDown() {}
* @return void
*
*/
-void doTrace( void )
+void doTrace( )
{
__sync_add_and_fetch( &g_TraceCalls, 1 );
- return;
}
/**
@@ -65,11 +64,24 @@ void doTrace( void )
* @return void
*
*/
-void doWarn( const char *file, unsigned line, const char *message )
+void doWarn( )
{
- printk("WARN: %s %u %s\n", file, line, message);
__sync_add_and_fetch( &g_Warnings, 1 );
+
+}
+
+/**
+ * @brief Implement Fail action in unit tests
+ *
+ * @return none
+ */
+
+void doFailTest( )
+{
+
+ __sync_add_and_fetch( &g_FailedTests, 1 );
+
}
/**
@@ -77,18 +89,22 @@ void doWarn( const char *file, unsigned line, const char *message )
*
* @param [in] pointer to filename (not used right now )
* @param [in] line number
- * @param [in] failure message
*
- * @return void
+ * @return none
*/
-void doFailTest( const char *file, unsigned line, const char *message )
+void doFailTest( const char *filename, uint32_t linenum )
{
-
- printk("FAIL: %s %u %s\n", file, line, message);
+ TRACDBIN( g_trac_test,
+ "!!! > Test Failed: ",
+ filename,
+ strlen( filename) );
+ TRACDCOMP( g_trac_test,
+ "!!! >at line %d ",
+ linenum );
__sync_add_and_fetch( &g_FailedTests, 1 );
-}
+}
/**
* @brief Report total number of unit tests in a test suite
*
@@ -100,11 +116,14 @@ void doFailTest( const char *file, unsigned line, const char *message )
* @param [in] trace message
*
* @return void
+ *
+ * @TODO do nothing with the suite name for now, later it may be useful
+ *
*/
-void reportTotalTests( const char *suitename, uint64_t numtests )
+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 );
TRACDBIN( g_trac_test,
"Suite Completed: ",
diff --git a/src/usr/cxxtest/makefile b/src/usr/cxxtest/makefile
index f28902c76..37ae0e43f 100644
--- a/src/usr/cxxtest/makefile
+++ b/src/usr/cxxtest/makefile
@@ -1,6 +1,25 @@
+#############################################################################
+# $IBMCopyrightBlock:
+#
+# IBM Confidential
+#
+# Licensed Internal Code Source Materials
+#
+# IBM HostBoot Licensed Internal Code
+#
+# (C) Copyright IBM Corp. 2011
+#
+# The source code for this program is not published or other-
+# wise divested of its trade secrets, irrespective of what has
+# been deposited with the U.S. Copyright Office.
+#$
+#############################################################################
+
ROOTPATH = ../../..
MODULE = cxxtest
+SUBDIRS=test.d
+
OBJS = TestSuite.o cxxtestexec.o
include ${ROOTPATH}/config.mk
diff --git a/src/usr/cxxtest/test/cxxtesttest.H b/src/usr/cxxtest/test/cxxtesttest.H
new file mode 100644
index 000000000..89a67401a
--- /dev/null
+++ b/src/usr/cxxtest/test/cxxtesttest.H
@@ -0,0 +1,120 @@
+/****************************************************************************
+ * $IBMCopyrightBlock:
+ *
+ * IBM Confidential
+ *
+ * Licensed Internal Code Source Materials
+ *
+ * IBM HostBoot Licensed Internal Code
+ *
+ * (C) Copyright IBM Corp. 2011
+ *
+ * The source code for this program is not published or other-
+ * wise divested of its trade secrets, irrespective of what has
+ * been deposited with the U.S. Copyright Office.
+ * $
+****************************************************************************/
+
+#ifndef __TEST_CXXTESTTEST_H
+#define __TEST_CXXTESTTEST_H
+
+/**
+ * @file cxxtesttest.H
+ *
+ * unit tests for TS_TRACE, TS_WARN, and TS_FAIL macros
+ *
+ */
+
+/**
+ * @class cxxtest
+ *
+ * - test TS_TRACE, TS_WARN and TS_FAIL macros
+ *
+ */
+
+#include <cxxtest/TestSuite.H>
+
+class CxxTestTest: public CxxTest::TestSuite
+{
+public:
+
+
+ /**
+ * @test TS_TRACE macro
+ *
+ */
+ void testCxxTestTrace(void)
+ {
+ int32_t l_dec = 1234567890;
+ uint32_t l_hex = 0x12345678;
+ uint64_t l_bighex = 0x1234567890abcdef;
+
+ TS_TRACE( "CxxTest Trace dec=%d", l_dec );
+ TS_TRACE( "CxxTest Trace hex=0x%x", l_hex );
+ TS_TRACE( "CxxTest Trace bighex=0x%llx", l_bighex );
+ TS_TRACE( "CxxTest Trace pointer=%p", &l_bighex );
+ TS_TRACE( "CxxTest Trace string=%s", "testing...\n" );
+
+ // all-in one.
+ TS_TRACE( "CxxTest Trace dec=%d, hex=0x%x, bighex=0x%llx, ptr=%p, str=%s",
+ l_dec, l_hex, l_bighex, &l_bighex, "testing..." );
+ }
+
+
+ /**
+ * @test TS_WARN will run if the testExampleWarn_function FAILS
+ *
+ * @note: please leave this here, but disabled. It is useful for
+ * sandbox testing.
+ */
+// void testCxxTestWarn(void)
+// {
+// int32_t l_dec = 1234567890;
+// uint32_t l_hex = 0x12345678;
+// uint64_t l_bighex = 0x1234567890abcdef;
+//
+// TS_WARN( "CxxTest Warning dec=%d", l_dec );
+// TS_WARN( "CxxTest Warning hex=0x%x", l_hex );
+// TS_WARN( "CxxTest Warning bighex=0x%llx", l_bighex );
+// TS_WARN( "CxxTest Warning pointer=%p", &l_bighex );
+// TS_WARN( "CxxTest Warning string=%s", "testing...\n" );
+//
+// // all-in one.
+// TS_WARN( "CxxTest Warn dec=%d, hex=0x%x, bighex=0x%llx, ptr=%p, str=%s",
+// l_dec, l_hex, l_bighex, &l_bighex, "testing..." );
+//
+// }
+
+
+
+ /**
+ * @test TS_FAIL will run if the testExampleFail function FAILS
+ *
+ * @note: please leave this here, but disabled. It is useful for
+ * sandbox testing.
+ */
+// void testCxxTestFail(void)
+// {
+// int32_t l_dec = 1234567890;
+// uint32_t l_hex = 0x12345678;
+// uint64_t l_bighex = 0x1234567890abcdef;
+//
+// TS_FAIL( "CxxTest Fail dec=%d", l_dec );
+// TS_FAIL( "CxxTest Fail hex=0x%x", l_hex );
+// TS_FAIL( "CxxTest Fail bighex=0x%llx", l_bighex );
+// TS_FAIL( "CxxTest Fail pointer=%p", &l_bighex );
+// TS_FAIL( "CxxTest Fail string=%s", "testing...\n" );
+//
+// // all-in one.
+// TS_FAIL( "CxxTest FAIL dec=%d, hex=0x%x, bighex=0x%llx, ptr=%p, str=%s",
+// l_dec, l_hex, l_bighex, &l_bighex, "testing..." );
+//
+// }
+
+
+
+
+}; // end class
+
+#endif
+
diff --git a/src/usr/cxxtest/test/makefile b/src/usr/cxxtest/test/makefile
new file mode 100644
index 000000000..1b57a7db3
--- /dev/null
+++ b/src/usr/cxxtest/test/makefile
@@ -0,0 +1,23 @@
+#############################################################################
+# $IBMCopyrightBlock:
+#
+# IBM Confidential
+#
+# Licensed Internal Code Source Materials
+#
+# IBM HostBoot Licensed Internal Code
+#
+# (C) Copyright IBM Corp. 2011
+#
+# The source code for this program is not published or other-
+# wise divested of its trade secrets, irrespective of what has
+# been deposited with the U.S. Copyright Office.
+#$
+#############################################################################
+
+ROOTPATH = ../../../..
+
+MODULE = testcxxtest
+TESTS = *.H
+
+include ${ROOTPATH}/config.mk
OpenPOWER on IntegriCloud