diff options
author | Mike Jones <mjjones@us.ibm.com> | 2012-03-12 10:12:01 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-03-16 09:13:39 -0500 |
commit | 8a1168142bd3f273dbd4edf841c53a3ae394cd5e (patch) | |
tree | 94029d881fa5b89d186073859c7de2fd6dcdfcb8 /src/usr/errl/test | |
parent | ff8472f5e338d17194b5a1300b9553dd1ac3a241 (diff) | |
download | talos-hostboot-8a1168142bd3f273dbd4edf841c53a3ae394cd5e.tar.gz talos-hostboot-8a1168142bd3f273dbd4edf841c53a3ae394cd5e.zip |
ERRL: Ensure all Hostboot code uses ErrlUserDetails framework.
RTC: 36920
Change-Id: I82667c8e63e8a99b9cc7eb1dfbbbdbe1c3b2bb2a
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/730
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/errl/test')
-rw-r--r-- | src/usr/errl/test/errltest.H | 39 | ||||
-rw-r--r-- | src/usr/errl/test/errluserdetailtest.H | 296 |
2 files changed, 27 insertions, 308 deletions
diff --git a/src/usr/errl/test/errltest.H b/src/usr/errl/test/errltest.H index 4e186a98e..8075ed232 100644 --- a/src/usr/errl/test/errltest.H +++ b/src/usr/errl/test/errltest.H @@ -98,7 +98,8 @@ public: * @reasoncode HBERRL_TEST_REASON_CODE * @severity ERRORLOG::ERRL_SEV_INFORMATIONAL * @moduleid HBERRL_TEST_MOD_ID - * @devdesc Errl test, errl log the first. + * @devdesc Errl test. Error with non-decoded string + * and lots of trace buffers. */ // Create an error log @@ -122,16 +123,8 @@ public: // but errlffdc.H is not publicly includable to give me the definition // for it. addFFDC() should return a Boolean indication of success. - const char * pch = "martha washington"; - pffdc = l_err->addFFDC( HBERRL_COMP_ID, pch, strlen( pch ), 0, HBERRL_SST_FIRSTLADY ); - if ( NULL == pffdc ) - { - TS_FAIL("testErrl1: addFFDC() output NULL pointer"); - break; - } - // really short user data - pch = "A"; + const char * pch = "A"; pffdc = l_err->addFFDC( DEVFW_COMP_ID, pch, strlen( pch )); if ( NULL == pffdc ) { @@ -139,32 +132,8 @@ public: break; } - pch = "george washington"; - pffdc = l_err->addFFDC( DEVFW_COMP_ID, pch, strlen( pch ), 0, HBERRL_SST_PRESIDENT ); - if ( NULL == pffdc ) - { - TS_FAIL("testErrl1: addFFDC() output NULL pointer"); - break; - } - - pch = "dwight eisenhour"; - pffdc = l_err->addFFDC( SCOM_COMP_ID, pch, strlen( pch ), 1, 12 ); - if ( NULL == pffdc ) - { - TS_FAIL("testErrl1: addFFDC() output NULL pointer"); - break; - } - - pch = "ronald "; - pffdc = l_err->addFFDC( HBERRL_COMP_ID, pch, strlen( pch ), 0, HBERRL_SST_PRESIDENT ); - if ( NULL == pffdc ) - { - TS_FAIL("testErrl1: addFFDC() output NULL pointer"); - break; - } - // Append data to something already added. - pch = "reagan"; + pch = " test-user-data-string"; l_err->appendToFFDC( pffdc, pch, strlen(pch) ); // Collect trace diff --git a/src/usr/errl/test/errluserdetailtest.H b/src/usr/errl/test/errluserdetailtest.H index b32a655f0..5ac4e9084 100644 --- a/src/usr/errl/test/errluserdetailtest.H +++ b/src/usr/errl/test/errluserdetailtest.H @@ -30,300 +30,50 @@ * */ -#include <cxxtest/TestSuite.H> -#include <errl/errlentry.H> -#include <errl/errluserdetails.H> -#include <errl/errlreasoncodes.H> +#include <cxxtest/TestSuite.H> +#include <errl/errlentry.H> +#include <errl/errluserdetails.H> +#include <errl/errlreasoncodes.H> +#include <errl/errludstring.H> using namespace ERRORLOG; - -enum -{ - UTIL_COMP_ID = 0x8A00, - -}; -// Subsection values, copied from FIPS. -enum -{ - UTIL_UDT_STREAM_PERC = 0x0001,///< Perc Data for Streams - UTIL_UDT_MEM_ALLOC = 0x0002,///< Memory Allocation Failure - UTIL_UDT_REG_KEYS = 0x0003,///< Registry key name, with data - UTIL_UDT_FILENAME = 0x0004,///< A null terminated filename - UTIL_UDT_FLOCK = 0x0005,///< An flock struct - UTIL_UDT_SEMAPHORE = 0x0006,///< A semaphore object - UTIL_UDT_LIBNAME = 0x0007,///< Name of the library - UTIL_UDT_REG_DATA = 0x0008,///< Payload data for UtilReg::write - UTIL_UDT_ERR_MSG = 0x0009,///< An error message string - UTIL_UDT_INOTIFY_PATH = 0x000a,///< The path name in error - UTIL_UDT_XML_TOKEN = 0x000b,///< The XML token in error - // - // dummy one for Stackdump - TEST_STACKDUMP_SUBSECT = 0x0055 // dummy subsection # for stackdump -}; - - -/** - * Declare a test UserDetails derived class to post a filename string to - * the errorlog. - * These are canned routines that are handled by the errl tool. - * - * This is just for test purposes, it will not show up in production code. - * The values for version and subsection should match the actual filename - * UD section parser routing in the errl tool - you should see it parse it - * correctly. - */ -class TestFilename : public ErrlUserDetails -{ -public: - - TestFilename(const char *i_filename) - { - - iv_CompId = UTIL_COMP_ID; - iv_Version = 1; - iv_SubSection = UTIL_UDT_FILENAME; - - // 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 UserDetails derived class to post an error message - * filename string to the errorlog - * These are canned routines that are handled by the errl tool. - * - * This is just for test purposes, it will not show up in production code. - * The values for version and subsection should match the actual filename - * UD section parser routing in the errl tool - you should see it parse it - * correctly. - */ -class TestErrorMsg : public ErrlUserDetails -{ -public: - - TestErrorMsg(const char *i_filename) - { - - iv_CompId = UTIL_COMP_ID; - iv_Version = 1; - iv_SubSection = UTIL_UDT_ERR_MSG; - - // Store the string in the internal buffer - char * l_pString = (char *)allocUsrBuf( strlen(i_filename)+1 ); - strcpy(l_pString, i_filename ); - } - - /** - * @brief Destructor - * - */ - virtual ~TestErrorMsg() {} - -private: - - // Disabled - TestErrorMsg(const TestErrorMsg &); - TestErrorMsg & operator=(const TestErrorMsg &); -}; - -/** - * Declare a test UserDetails derived class to post an XML token in error - * to the errorlog - * These are canned routines that are handled by the errl tool. - * - * This is just for test purposes, it will not show up in production code. - * The values for version and subsection should match the actual filename - * UD section parser routing in the errl tool - you should see it parse it - * correctly. - */ -class TestXMLToken : public ErrlUserDetails -{ -public: - - TestXMLToken(const char *i_filename) - { - - iv_CompId = UTIL_COMP_ID; - iv_Version = 1; - iv_SubSection = UTIL_UDT_XML_TOKEN; - - // Store the string in the internal buffer - char * l_pString = (char *)allocUsrBuf( strlen(i_filename)+1 ); - strcpy(l_pString, i_filename ); - } - - /** - * @brief Destructor - * - */ - virtual ~TestXMLToken() {} - -private: - - // Disabled - TestXMLToken(const TestXMLToken &); - TestXMLToken & operator=(const TestXMLToken &); -}; - - -// -------------------------------------------------------------------------- -// begin actual test code.. -// -------------------------------------------------------------------------- class UtilErrlUsrDataTest: public CxxTest::TestSuite { public: - + + // Note that errlUserDetailsTarget is tested in the targeting unit test + /** - * @test testFILENAME - create a simple UD section in the errorlog that - * stores a filename string + * @test testString - Capture a String in an error log */ - void testFILENAME(void) + void testString(void) { - errlHndl_t l_errl = NULL; + errlHndl_t l_errl = NULL; - TS_TRACE( "testFILENAME user data buffer for errorlog"); + TS_TRACE( "testString errorlog user detail data"); /*@ * @errortype * @severity ERRORLOG_SEV_INFORMATIONAL - * @moduleid HBERRL_USERDETAILS_MODULE_ID - * @reasoncode HBERRL_FILENAME_TEST - * @userdata1 <UNUSED> - * @userdata2 <UNUSED> - * @devdesc User Details unit test - post a filename user data section + * @moduleid HBERRL_USERDATA_TEST_MOD_ID + * @reasoncode HBERRL_TEST_STRING_UD + * @userdata1 Test data 1 + * @userdata2 Test data 2 + * @devdesc User Details unit test - create string user detail data */ l_errl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_INFORMATIONAL, - HBERRL_USERDETAILS_MODULE_ID, - HBERRL_FILENAME_TEST, // compid/reasoncode + HBERRL_USERDATA_TEST_MOD_ID, + HBERRL_TEST_STRING_UD, 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( "/path/to/myfile.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[] = "addedfilename.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, HBERRL_COMP_ID ); - - // Maybe do some stuff here to find the committed errorlog back and - // see if it is still correct? Later. - - } - - /** - * @test testErrorMsg - create a simple UD section in the errorlog - * that stores an error message - */ - void testErrorMsg(void) - { - errlHndl_t l_errl = NULL; - - TS_TRACE( "testErrorMsg user data buffer for errorlog"); - /*@ - * @errortype - * @severity ERRORLOG_SEV_INFORMATIONAL - * @moduleid HBERRL_USERDETAILS_MODULE_ID - * @reasoncode HBERRL_ERRORMSG_TEST - * @userdata1 <UNUSED> - * @userdata2 <UNUSED> - * @devdesc User Details unit test - post an error message in a - * user data section - */ - l_errl = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - HBERRL_USERDETAILS_MODULE_ID, - HBERRL_ERRORMSG_TEST, // compid/reasoncode - 0x1212121212, // user1 - 0x3434343434 ); // user2 - if( l_errl == NULL ) - { - TS_FAIL("Could not create errlog.\n"); - return; - } - - // create the filename userdata object - TestErrorMsg l_userdata( "The UserData library has failed to fail." ); - // add it to the log - l_userdata.addToLog( l_errl ); + // Create a test string and add it to the error log as user detail data + const char * l_pString = "This is a test string"; + ErrlUserDetailsString(l_pString).addToLog(l_errl); // commit the errorlog - errlCommit(l_errl, HBERRL_COMP_ID ); - - } - - /** - * @test testXMLToken - create a simple UD section in the errorlog - * that stores the name of an xml token in error. - */ - void testXMLToken(void) - { - errlHndl_t l_errl = NULL; - - TS_TRACE( "testXMLToken user data buffer for errorlog"); - /*@ - * @errortype - * @severity ERRORLOG_SEV_INFORMATIONAL - * @moduleid HBERRL_USERDETAILS_MODULE_ID - * @reasoncode HBERRL_XMLTOKEN_TEST - * @userdata1 <UNUSED> - * @userdata2 <UNUSED> - * @devdesc User Details unit test - post an XML token in error as - * a user data section - */ - l_errl = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - HBERRL_USERDETAILS_MODULE_ID, - HBERRL_XMLTOKEN_TEST, // compid/reasoncode - 0xa5a5a5a5a5, // user1 - 0xd2d2d2d2d2 ); // user2 - if( l_errl == NULL ) - { - TS_FAIL("Could not create errlog.\n"); - return; - } - - // create the filename userdata object - TestXMLToken l_userdata( "HWAS_STATE" ); - - // add it to the log - l_userdata.addToLog( l_errl ); - - // commit the errorlog - errlCommit( l_errl, HBERRL_COMP_ID ); - + errlCommit(l_errl, HBERRL_COMP_ID); } }; |