summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wenning <wenning@us.ibm.com>2011-09-30 15:09:57 -0500
committerMark W. Wenning <wenning@us.ibm.com>2011-11-01 10:58:00 -0500
commit14cd4e689a68a7440309090d0a6f82d25f8b6984 (patch)
tree92210b10941c76565af27bc9a5b68502b89daac4
parentbeb8da45e9ad11796185bfb99f47fce35a090f9e (diff)
downloadblackbird-hostboot-14cd4e689a68a7440309090d0a6f82d25f8b6984.tar.gz
blackbird-hostboot-14cd4e689a68a7440309090d0a6f82d25f8b6984.zip
RTC3964: ErrorLog User Data Parser
- created - add unittest for FILENAME - add unittest for StackTrace - still need to handle x86 (mini-errl) side - post-review changes - Monte's suggestions - Thi's suggestions - remove appendToLog() - combine with addToLog() - fix merge error - fsi was in both BASE and EXTENDED Change-Id: I863aae9f75aad5d576e839a9ef3099af6943982b Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/429 Tested-by: Jenkins Server Reviewed-by: Mark W. Wenning <wenning@us.ibm.com>
-rw-r--r--src/include/usr/errl/errlentry.H14
-rw-r--r--src/include/usr/errl/errlreasoncodes.H3
-rw-r--r--src/include/usr/errl/errltypes.H34
-rwxr-xr-xsrc/include/usr/errl/errluserdetails.H257
-rw-r--r--src/makefile11
-rw-r--r--src/usr/errl/errlentry.C16
-rw-r--r--src/usr/errl/errluserdetails.C150
-rw-r--r--src/usr/errl/makefile3
-rw-r--r--src/usr/errl/test/errltest.H8
-rw-r--r--src/usr/errl/test/errluserdetailtest.H236
10 files changed, 701 insertions, 31 deletions
diff --git a/src/include/usr/errl/errlentry.H b/src/include/usr/errl/errlentry.H
index 51a0df843..5046cd1c6 100644
--- a/src/include/usr/errl/errlentry.H
+++ b/src/include/usr/errl/errlentry.H
@@ -31,6 +31,16 @@
* is used to log errors from all firmware running in Host Boot environment.
*
*/
+/**
+ * @page errlog Error Log
+ *
+ * @section Base Error Log
+ * See Host Boot Error Logging LLDD, Version 0.7 09/01/2011
+ *
+ * @section Adding User-Defined error blocks
+ *
+ *
+ */
/*****************************************************************************/
// I n c l u d e s
@@ -45,6 +55,7 @@
#include <errl/errlud.H>
#include <hbotcompid.H>
+
namespace ERRORLOG
{
@@ -278,7 +289,7 @@ public:
/**
- * @brief Allows the caller to add a chunk of data in a log
+ * @brief Allows the caller to add a chunk of FFDC data in a log
*
* @param[in] i_compId Component Id of the caller
* @param[in] i_dataPtr Pointer to FFDC data
@@ -316,7 +327,6 @@ public:
const uint32_t i_dataLen);
-
/**
* @brief Collect component trace
* The given component's trace is collected (if possible)
diff --git a/src/include/usr/errl/errlreasoncodes.H b/src/include/usr/errl/errlreasoncodes.H
index 241fb2a4e..346f563c7 100644
--- a/src/include/usr/errl/errlreasoncodes.H
+++ b/src/include/usr/errl/errlreasoncodes.H
@@ -36,6 +36,7 @@
enum
{
ERRL_FIRST_MODULE_ID = 0x00,
+ ERRL_USERDETAILS_MODULE_ID,
//........
ERRL_LAST_MODULE_ID = 0xFF
};
@@ -44,6 +45,8 @@ enum
enum errlReasonCode
{
ERRL_FIRST_ERR = ERRL_COMP_ID | 0x01,
+ ERRL_ADDTOLOG_FAIL = ERRL_COMP_ID | 0x02,
+ ERRL_APPENDTOLOG_FAIL = ERRL_COMP_ID | 0x03,
//........
ERRL_LAST_ERR = ERRL_COMP_ID | 0xFF
};
diff --git a/src/include/usr/errl/errltypes.H b/src/include/usr/errl/errltypes.H
index af5067ea4..e3435eef5 100644
--- a/src/include/usr/errl/errltypes.H
+++ b/src/include/usr/errl/errltypes.H
@@ -34,6 +34,7 @@
* on pool machines, so the stuff in here needs to be generic.
*
*/
+#include <hbotcompid.H> // compId_t
/**
* @brief Pointer to an ErrlEntry object
@@ -83,7 +84,7 @@ namespace ERRORLOG
/**
* @brief Scope is found in user header section.
-
+
*/
enum errlScope_t
{
@@ -157,10 +158,10 @@ enum errlSectionId_t
/**
* @brief Enumeration of error log severity.
* Needs to fit into 1 byte for flattening purposes.
- *
+ *
* Severity resides in the user header of the PEL log.
- *
- * Refer to this ErrlEntry setter:
+ *
+ * Refer to this ErrlEntry setter:
* void ErrlEntry::setSev(const errlSeverity_t i_sev)
*/
enum errlSeverity_t
@@ -177,9 +178,9 @@ enum errlSeverity_t
/**
* @brief Event (error) type
* Needs to fit into 1 byte for flattening purposes.
- *
+ *
* Event type resides in user header of PEL log.
- *
+ *
* Refer to this ErrlEntry setter:
* void ErrlEntry::setEventType(const errlEventType_t i_eventType)
*/
@@ -200,10 +201,10 @@ enum errlEventType_t
/**
* @brief SRC type definitions
* Needs to fit into 1 byte for flattening purposes.
- *
+ *
* This represents the byte in an SRC in position
* XX...... such as B1 in B181F00B.
- *
+ *
* Refer to errlentry.H and this setter:
* void ErrlEntry::setSrcType(const srcType_t i_srcType)
*
@@ -224,8 +225,8 @@ enum srcType_t
* Needs to fit into 1 byte for flattening purposes.
* This represents the byte in an SRC in position
* ..XX.... such as 81 in B181F00B.
- *
- * Refer to errentry.H and this setter:
+ *
+ * Refer to errentry.H and this setter:
* void ErrlEntry::setSubSys(const epubSubSystem_t i_subSys);
*/
enum epubSubSystem_t
@@ -297,9 +298,22 @@ enum errlUserDataVersion
*/
const uint32_t ERRL_STORAGE_SIZE = 65536;
+/**
+ *
+ * @typedef version number
+ * version number of the user data
+ */
+typedef uint8_t errlver_t;
+
+/**
+ * @typedef errlsubsec_t
+ * errorlog subsection id of the user data
+ */
+typedef uint8_t errlsubsec_t;
/**
+
* @brief The RAM storage for committed error logs starts with this
* header. This structure is org'ed at &g_ErrlStorage[0]. All
* offsets are based from &g_achErrlStorage[0], so the first
diff --git a/src/include/usr/errl/errluserdetails.H b/src/include/usr/errl/errluserdetails.H
new file mode 100755
index 000000000..af7e004d1
--- /dev/null
+++ b/src/include/usr/errl/errluserdetails.H
@@ -0,0 +1,257 @@
+// IBM_PROLOG_BEGIN_TAG
+// This is an automatically generated prolog.
+//
+// $Source: src/include/usr/errl/errluserdetails.H $
+//
+// IBM CONFIDENTIAL
+//
+// COPYRIGHT International Business Machines Corp. 2011
+//
+// p1
+//
+// Object Code Only (OCO) source materials
+// Licensed Internal Code Source Materials
+// IBM HostBoot Licensed Internal Code
+//
+// 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.
+//
+// Origin: 30
+//
+// IBM_PROLOG_END
+#ifndef ERRL_ERRLUSERDETAILS_H
+#define ERRL_ERRLUSERDETAILS_H
+
+/**
+ * @file errluserdetails.H
+ *
+ * Error Log User Detail Data Helper
+ *
+ * Framework defining how User Detail Data sections of error logs should
+ * be created and parsed.
+ *
+ * Creation methods will show up when the PARSER macro is NOT defined.
+ * These will compile and run under HostBoot.
+ *
+ * Parsing methods will show up when the PARSER macro IS defined.
+ * These will compile and run in the errl tool.
+ *
+*/
+
+//
+// @page ErrlUserDetails Error Log User Details
+//
+//
+
+
+/*****************************************************************************/
+// I n c l u d e s
+/*****************************************************************************/
+#include <hbotcompid.H> // list of compid's supported
+
+#include <errl/errltypes.H> // errlver_t, errlsubsec_t
+#include <errl/errlentry.H> // addFFDC, appendFFDC
+
+
+
+/*****************************************************************************/
+// Typedefs
+/*****************************************************************************/
+
+
+namespace ERRORLOG
+{
+
+#ifndef PARSER
+
+/**
+ * @brief ERRL User Data Details
+ *
+ * HostBoot Support - base class for Errorlog User Details.
+ *
+ *
+*/
+class ErrlUserDetails
+{
+public:
+
+ /**
+ * @brief Constructor
+ *
+ * Sets up instance variables. A derived class should set up the instance
+ * variables to reflect a specific format of user detail data
+ *
+ */
+ ErrlUserDetails();
+
+ /**
+ * @brief Destructor
+ *
+ * Performs any necessary cleanup
+ *
+ */
+ virtual ~ErrlUserDetails();
+
+ /**
+ * @brief Adds or appends more user detail data to error log
+ *
+ * Adds or appends user detail data stored in the internal buffer to
+ * the error log
+ * Subclasses should override if the detail data is not stored in the
+ * internal buffer.
+ *
+ * @param i_errl
+ * Error log handle to add detail data to.
+ * This will call appendFFDC() in the errorlog.
+ *
+ * @param i_pappendBuf
+ * pointer to the new data buffer to append.
+ *
+ * @param i_pappendBufLen
+ * length of the new data buffer to append in bytes.
+ *
+ * @return None
+ *
+ */
+ virtual void addToLog(
+ errlHndl_t i_errl,
+ const void *i_paddBuf=NULL,
+ const uint32_t i_addBufLen=0 );
+
+protected:
+
+ /**
+ * @brief Allocates the internal data buffer for storing detail data
+ *
+ * If the internal buffer is already allocated then it is freed. The
+ * data buffer is allocated with the specified size.
+ *
+ * @param i_size
+ * Size of buffer
+ *
+ * @return uint8_t*
+ * Pointer to the data buffer
+ *
+ */
+ uint8_t * allocUsrBuf(const uint32_t i_size);
+
+ /**
+ * @brief Returns the size of the internal data buffer
+ *
+ * @return uint32_t
+ * Size of the internal data buffer
+ *
+ */
+ uint32_t getUsrBufSize() const;
+
+ /**
+ * Protected Data: ID of component adding user details
+ */
+ compId_t iv_CompId;
+
+ /**
+ * Protected Data: Version number of the user details
+ */
+ errlver_t iv_Version;
+
+ /**
+ * Protected Data: Subsection number of the user details
+ */
+ errlsubsec_t iv_SubSection;
+
+ /**
+ * Pointer to the ErrlFFDC passed back by addFFDC()
+ */
+ ErrlFFDC *iv_pErrlFFDC;
+
+private:
+
+ // Disabled
+ ErrlUserDetails(const ErrlUserDetails &);
+ ErrlUserDetails & operator=(const ErrlUserDetails &);
+
+ /**
+ * Private Data members (the internal buffer should be accessed through
+ * public member functions)
+ */
+ uint8_t * iv_pBuffer; // Pointer to internal buffer
+ uint32_t iv_BufLen; // Length of internal buffer
+
+};
+
+#else // (if PARSER defined)
+
+/**
+ *
+ * @brief Error Log User Detail Data Helper
+ *
+ * Framework defining how User Detail Data sections of error logs should
+ * be created and parsed.
+ *
+ * Creation methods will show up when the PARSER macro is NOT defined.
+ * These will compile and run under HostBoot.
+ *
+ * Parsing methods will show up when the PARSER macro IS defined.
+ * These will compile and run in the errl tool.
+ *
+*/
+class ErrlUserDetails
+{
+public:
+
+ /**
+ * @brief Constructor
+ *
+ */
+ ErrlUserDetails()
+ {
+ }
+
+ /**
+ * @brief Destructor
+ *
+ */
+ virtual ~ErrlUserDetails()
+ {
+ }
+
+ /**
+ * @brief Parses user detail data from an error log
+ *
+ * Parses the supplied user detail data and outputs info to i_parser. This
+ * is a pure virtual function that must be overridden by a concrete derived
+ * class that is specific to a particular component, version and subsection
+ *
+ * @param i_version
+ * Version of the data
+ *
+ * @param i_parse
+ * ErrlUsrParser object for outputting information
+ *
+ * @param i_pBuffer
+ * Pointer to buffer containing detail data
+ *
+ * @param i_buflen
+ * Length of the buffer
+ *
+ * @return None
+ *
+ */
+ virtual void parse(errlver_t i_version,
+ ErrlUsrParser & i_parser,
+ const void * i_pBuffer,
+ const uint32_t i_buflen) const = 0;
+
+private:
+
+ // Disabled
+ ErrlUserDetails(const ErrlUserDetails &);
+ ErrlUserDetails & operator=(const ErrlUserDetails &);
+};
+
+#endif //PARSER
+
+} // end namespace
+
+#endif
diff --git a/src/makefile b/src/makefile
index bfd6a8d60..66f795e1d 100644
--- a/src/makefile
+++ b/src/makefile
@@ -36,19 +36,18 @@ DIRECT_BOOT_OBJECTS = start.o kernel.o taskmgr.o cpumgr.o syscall.o \
syscall_msg.o syscall_mmio.o syscall_time.o \
syscall_mm.o init_main.o vfs_main.o sync.o futexmgr.o \
ptmgr.o segmentmgr.o basesegment.o devicesegment.o \
- block.o cxxtest_data.o cpuid.o misc.o msghandler.o \
- blockmsghdlr.o stacksegment.o softpatch_p7.o
+ block.o cxxtest_data.o cpuid.o misc.o msghandler.o \
+ blockmsghdlr.o stacksegment.o softpatch_p7.o
## STUB_TESTCASE_OBJECT = cxxtest_stub.o
RUNTIME_OBJECTS =
-BASE_MODULES = trace errl devicefw scom xscom initservice taskargs pnor i2c \
- vfs
-
+BASE_MODULES = trace errl devicefw scom xscom initservice taskargs \
+ pnor i2c fsi vfs
EXTENDED_MODULES = targeting ecmddatabuffer hwpf fapi hwp plat \
- extinitsvc istepdisp hwas fsiscom fsi
+ extinitsvc istepdisp hwas fsiscom
DIRECT_BOOT_MODULES = example
RUNTIME_MODULES =
diff --git a/src/usr/errl/errlentry.C b/src/usr/errl/errlentry.C
index fc171fbfc..902d43544 100644
--- a/src/usr/errl/errlentry.C
+++ b/src/usr/errl/errlentry.C
@@ -38,6 +38,7 @@
#include <trace/interface.H>
#include <arch/ppc.H>
+
namespace ERRORLOG
{
@@ -60,6 +61,7 @@ ErrlEntry::ErrlEntry(const errlSeverity_t i_sev,
iv_termState(TERM_STATE_UNKNOWN)
{
+
}
@@ -131,8 +133,6 @@ void ErrlEntry::appendToFFDC(ErrlUD * i_pErrlUD,
}
-
-
///////////////////////////////////////////////////////////////////////////////
// Return a Boolean indication of success.
@@ -143,8 +143,8 @@ bool ErrlEntry::collectTrace(const char i_name[], const uint32_t i_max)
do
{
// By passing nil arguments, obtain the size of the buffer.
- uint64_t l_cbFull = TRACE::Trace::getTheInstance().getBuffer( i_name,
- NULL,
+ uint64_t l_cbFull = TRACE::Trace::getTheInstance().getBuffer( i_name,
+ NULL,
0 );
if( 0 == l_cbFull )
{
@@ -153,14 +153,14 @@ bool ErrlEntry::collectTrace(const char i_name[], const uint32_t i_max)
break;
}
- if( 0 == i_max )
+ if( 0 == i_max )
{
// Full trace buffer desired. Allocate the buffer.
char l_traceBuffer[ l_cbFull ];
// Get the data into the buffer.
- TRACE::Trace::getTheInstance().getBuffer( i_name,
- l_traceBuffer,
+ TRACE::Trace::getTheInstance().getBuffer( i_name,
+ l_traceBuffer,
l_cbFull );
// Save the trace buffer as a UD section on this.
@@ -170,7 +170,7 @@ bool ErrlEntry::collectTrace(const char i_name[], const uint32_t i_max)
ERRL_UDV_DEFAULT_VER_1,
ERRL_UDT_TRACE );
- // Add the trace section to the vector of sections
+ // Add the trace section to the vector of sections
// for this error log.
iv_SectionVector.push_back( l_udSection );
diff --git a/src/usr/errl/errluserdetails.C b/src/usr/errl/errluserdetails.C
new file mode 100644
index 000000000..2ee87f49a
--- /dev/null
+++ b/src/usr/errl/errluserdetails.C
@@ -0,0 +1,150 @@
+// IBM_PROLOG_BEGIN_TAG
+// This is an automatically generated prolog.
+//
+// $Source: src/usr/errl/errluserdetails.C $
+//
+// IBM CONFIDENTIAL
+//
+// COPYRIGHT International Business Machines Corp. 2011
+//
+// p1
+//
+// Object Code Only (OCO) source materials
+// Licensed Internal Code Source Materials
+// IBM HostBoot Licensed Internal Code
+//
+// 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.
+//
+// Origin: 30
+//
+// IBM_PROLOG_END
+/**
+ * @file errluserdetails.C
+ *
+ * @brief Implementation for ErrlUsrDetails
+ *
+ * 2011-09-28 mww Forked from /esw/fips740/Builds/b0824a_1135.740/src/util/fsp
+ *
+*/
+
+
+/******************************************************************************/
+// I n c l u d e s
+/*****************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h> // memcpy
+
+#include <hbotcompid.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <errl/errlreasoncodes.H>
+
+#include <errl/errluserdetails.H>
+
+#include "errlsctn.H"
+#include <errl/errlud.H> // ErrlFFDC
+
+
+namespace ERRORLOG
+{
+
+/*****************************************************************************/
+// ErrlUserDetails default constructor
+/*****************************************************************************/
+ErrlUserDetails::ErrlUserDetails()
+: iv_CompId(ERRL_COMP_ID),
+ iv_Version(0),
+ iv_SubSection(0),
+ iv_pErrlFFDC(NULL),
+ iv_pBuffer(NULL),
+ iv_BufLen(0)
+{
+}
+
+/*****************************************************************************/
+// ErrlUserDetails Destructor
+/*****************************************************************************/
+ErrlUserDetails::~ErrlUserDetails()
+{
+ if (iv_pBuffer)
+ {
+ delete [] iv_pBuffer;
+ iv_pBuffer = NULL;
+ }
+
+}
+
+
+/*****************************************************************************/
+// ErrlUserDetails add/appendToLog
+/*****************************************************************************/
+void ErrlUserDetails::addToLog(
+ errlHndl_t i_errl,
+ const void *i_paddBuf,
+ const uint32_t i_addBufLen )
+{
+
+ assert( i_errl != NULL );
+
+ if ( iv_pErrlFFDC == NULL )
+ {
+ // first time through, do an addFFDC() and save the returned handle
+ iv_pErrlFFDC = i_errl->addFFDC(
+ iv_CompId,
+ iv_pBuffer,
+ iv_BufLen,
+ iv_Version,
+ iv_SubSection );
+
+ // assert if fails to addFFDC
+ assert( iv_pErrlFFDC != NULL );
+ }
+
+ // if there is a buffer/len , append it to the existing FFDC.
+ if ( ( i_paddBuf != NULL ) && ( i_addBufLen > 0 ) )
+ {
+ i_errl->appendToFFDC(
+ iv_pErrlFFDC,
+ i_paddBuf,
+ i_addBufLen );
+ }
+}
+
+
+/*****************************************************************************/
+// ErrlUserDetails allocUsrBuf
+/*****************************************************************************/
+uint8_t * ErrlUserDetails::allocUsrBuf(const uint32_t i_size)
+{
+ uint8_t * pNewBuffer = new uint8_t[i_size];
+ if (iv_pBuffer)
+ {
+ if (iv_BufLen <= i_size)
+ {
+ memcpy(pNewBuffer, iv_pBuffer, iv_BufLen);
+ }
+ else
+ {
+ memcpy(pNewBuffer, iv_pBuffer, i_size);
+ }
+ delete [] iv_pBuffer;
+ }
+
+ iv_pBuffer = pNewBuffer;
+ iv_BufLen = i_size;
+
+ return (iv_pBuffer);
+}
+
+/*****************************************************************************/
+// ErrlUserDetails getUsrBufSize
+/*****************************************************************************/
+uint32_t ErrlUserDetails::getUsrBufSize() const
+{
+ return iv_BufLen;
+}
+
+} // end namespace
diff --git a/src/usr/errl/makefile b/src/usr/errl/makefile
index 924f34623..1a219ccb3 100644
--- a/src/usr/errl/makefile
+++ b/src/usr/errl/makefile
@@ -23,7 +23,8 @@
ROOTPATH = ../../..
MODULE = errl
-OBJS = errlentry.o errlmanager.o errlsctn.o errlsctnhdr.o errlprvt.o errluh.o errlud.o errlsrc.o
+OBJS = errlentry.o errlmanager.o errlsctn.o errlsctnhdr.o errlprvt.o errluh.o \
+ errlud.o errlsrc.o errluserdetails.o
SUBDIRS = test.d parser.d
diff --git a/src/usr/errl/test/errltest.H b/src/usr/errl/test/errltest.H
index c2808b32c..aab205414 100644
--- a/src/usr/errl/test/errltest.H
+++ b/src/usr/errl/test/errltest.H
@@ -73,9 +73,9 @@ public:
// the two 64-bit user data parameters in the error log.
// l_userData1 = 16bit(0):l_bit8_1:l_bit8_2:l_32bit_1
uint8_t l_8bit_1 = TEST_USR_8BIT_1; // 0x80
- uint8_t l_8bit_2 = TEST_USR_8BIT_2; // 0x93
+ uint8_t l_8bit_2 = TEST_USR_8BIT_2; // 0x93
uint32_t l_32bit_1 = TEST_USR_32BIT_1; // 0x80000001
- uint64_t l_userData1 =
+ uint64_t l_userData1 =
TWO_UINT32_TO_UINT64( TO_UINT32(TWO_UINT8_TO_UINT16(l_8bit_1, l_8bit_2)), l_32bit_1);
// yields 0x0000809380000001
@@ -114,14 +114,14 @@ public:
TS_FAIL("testErrl1: addFFDC() output NULL pointer");
}
- pch = "george washington";
+ pch = "george washington";
pffdc = l_err->addFFDC( DEVFW_COMP_ID, pch, strlen( pch ), 3, 4 );
if ( NULL == pffdc )
{
TS_FAIL("testErrl1: addFFDC() output NULL pointer");
}
- pch = "dwight eisenhour";
+ pch = "dwight eisenhour";
pffdc = l_err->addFFDC( SCOM_COMP_ID, pch, strlen( pch ), 5, 6 );
if ( NULL == pffdc )
{
diff --git a/src/usr/errl/test/errluserdetailtest.H b/src/usr/errl/test/errluserdetailtest.H
new file mode 100644
index 000000000..398192d23
--- /dev/null
+++ b/src/usr/errl/test/errluserdetailtest.H
@@ -0,0 +1,236 @@
+// IBM_PROLOG_BEGIN_TAG
+// This is an automatically generated prolog.
+//
+// $Source: src/usr/errl/test/errluserdetailtest.H $
+//
+// IBM CONFIDENTIAL
+//
+// COPYRIGHT International Business Machines Corp. 2011
+//
+// p1
+//
+// Object Code Only (OCO) source materials
+// Licensed Internal Code Source Materials
+// IBM HostBoot Licensed Internal Code
+//
+// 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.
+//
+// Origin: 30
+//
+// IBM_PROLOG_END
+#ifndef __TEST_ERRLUSERDETAILSTEST_H
+#define __TEST_USERUSERDETAILSTEST_H
+
+/**
+ * @file errluserdetailstest.H
+ *
+ * @brief Test user data plugin for errorlog.
+ *
+ */
+
+#include <cxxtest/TestSuite.H>
+#include <errl/errlentry.H>
+#include <errl/errluserdetails.H>
+
+using namespace ERRORLOG;
+
+// dummy version and subsection values.
+const errlver_t TEST_FILENAME_VER = 1;
+const errlsubsec_t TEST_FILENAME_SUBSECT = 4;
+const errlver_t TEST_STACKDUMP_VER = 2;
+const errlsubsec_t TEST_STACKDUMP_SUBSECT = 5;
+
+
+/**
+ * Declare a test UserDetails derived class to post a filename string to
+ * the errorlog
+ * This is just for test purposes, it will not show up in production code.
+ */
+class TestFilename : public ErrlUserDetails
+{
+public:
+
+ TestFilename(const char *i_filename)
+ {
+ iv_CompId = ERRL_COMP_ID;
+ iv_Version = TEST_FILENAME_VER;
+ iv_SubSection = TEST_FILENAME_SUBSECT;
+
+ // Store the string in the internal buffer
+ char * l_pString = (char *)allocUsrBuf( strlen(i_filename)+1 );
+ strcpy(l_pString, i_filename );
+ }
+
+ /**
+ * @brief Destructor
+ *
+ */
+ virtual ~TestFilename() {}
+
+private:
+
+ // Disabled
+ TestFilename(const TestFilename &);
+ TestFilename & operator=(const TestFilename &);
+};
+
+/**
+ * Declare a test User Details "StackDump" class to store an array of (32-bit)
+ * Stack Addresses. the first 32-bit number will be the number of following
+ * Stack Addresses.
+ *
+ * This is just a test program, it will not be used in production code.
+ * 64-bit stack addrs will need other support
+ */
+class TestStackDump : public ErrlUserDetails
+{
+public:
+
+
+ TestStackDump( const uint64_t i_numAddrs, const uint64_t * i_paddrs )
+ {
+
+ iv_CompId = ERRL_COMP_ID;
+ iv_Version = TEST_STACKDUMP_VER;
+ iv_SubSection = TEST_STACKDUMP_SUBSECT;
+
+ // allocUsrBuf returns a buffer of uint8_t
+ uint64_t *l_pList =
+ reinterpret_cast<uint64_t *>( allocUsrBuf( (i_numAddrs+1)*sizeof(void*) ) );
+
+ l_pList[0] = i_numAddrs;
+ for (uint64_t i=0; i<i_numAddrs; i++ )
+ {
+ l_pList[i+1] = i_paddrs[i];
+ }
+ }
+
+ /**
+ * @brief Destructor
+ *
+ */
+ virtual ~TestStackDump() {}
+
+private:
+
+ // Disabled
+ TestStackDump(const TestStackDump &);
+ TestStackDump & operator=(const TestStackDump &);
+};
+
+
+
+
+//
+// begin actual test code..
+//
+class UtilErrlUsrDataTest: public CxxTest::TestSuite
+{
+public:
+
+ /**
+ * @test testFILENAME - create a simple UD section in the errorlog that
+ * stores a filename string
+ */
+ void testFILENAME(void)
+ {
+ errlHndl_t l_errl = NULL;
+
+ TS_TRACE( "testFILENAME user data buffer for errorlog");
+
+ l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ TEST_MOD_ID,
+ ERRL_COMP_ID | 0x55, // compid/reasoncode
+ 0x1234567890, // user1
+ 0x9876543210 ); // user2
+ if( l_errl == NULL )
+ {
+ TS_FAIL("Could not create errlog.\n");
+ return;
+ }
+
+ // create the filename userdata object
+ //
+ TestFilename l_FN_userdata( "foobar.txt" );
+
+ // Add filename user data block to errorlog. this should add
+ // the original constructor string, and the second string passed
+ // in here.
+ const char testfnstr1[] = "secondfilename.txt";
+ l_FN_userdata.addToLog( l_errl, testfnstr1, sizeof(testfnstr1) );
+
+
+ //
+ // Add another string.
+ //
+ const char testfnstr2[] = "thirdfilename.txt";
+ l_FN_userdata.addToLog( l_errl, testfnstr2, sizeof(testfnstr2) );
+
+ // commit the errorlog
+ errlCommit(l_errl );
+
+ // Maybe do some stuff here to find the committed errorlog back and
+ // see if it is still correct? Later.
+
+ }
+
+ /**
+ * @test testStackDump - dump a User Data section of a stackdump.
+ *
+ * first 32-bit entry is the # of following 32-bit addresses, followed
+ * by the list of addresses.
+ *
+ */
+ void testStackDump(void)
+ {
+ errlHndl_t l_errl = NULL;
+ uint64_t l_addrs[] =
+ {
+ 0x01234567,
+ 0xDEADBEEF,
+ 0x5555aaaa,
+ 0x69696969,
+ 0x34920781,
+ 0xaaaa5555,
+ 0x68392090,
+ 0x95720856,
+ 0xabcdef01,
+ 0x12345670
+ };
+
+ TS_TRACE( "testStackDump add Userdata Section ot errorlog");
+
+
+ l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ TEST_MOD_ID,
+ ERRL_COMP_ID | 0x56, // compid/reasoncode
+ 0x0101010101, // user1
+ 0x0202020202 ); // user2
+ if( l_errl == NULL )
+ {
+ TS_FAIL("Could not create errlog.\n");
+ return;
+ }
+
+ TS_TRACE("Create Stackdump object. ");
+ TestStackDump l_stackDump(
+ (sizeof(l_addrs)/sizeof(uint64_t)),
+ &(l_addrs[0]) );
+
+ TS_TRACE("run addToLog");
+ l_stackDump.addToLog( l_errl );
+
+ errlCommit( l_errl );
+
+ }
+
+};
+
+
+
+#endif
+
OpenPOWER on IntegriCloud