summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/test
diff options
context:
space:
mode:
authorMike Jones <mjjones@us.ibm.com>2011-08-12 11:03:30 -0500
committerNicholas E. Bofferding <bofferdn@us.ibm.com>2011-08-19 15:08:51 -0500
commit2935ed01dae82a91c1bb4c181fd36cc42b2efaf9 (patch)
treeedbde05a7cf666342b704b2eb069e6dfbcbd96c5 /src/usr/hwpf/test
parent02991f3ecb7356dc989148710e7ca40df0f7437c (diff)
downloadblackbird-hostboot-2935ed01dae82a91c1bb4c181fd36cc42b2efaf9.tar.gz
blackbird-hostboot-2935ed01dae82a91c1bb4c181fd36cc42b2efaf9.zip
HWPF Error Info Support
Change-Id: Ib060599a4b64e768cbc75184a050e851c0a39c4e Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/250 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com> Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/test')
-rw-r--r--src/usr/hwpf/test/fapiRcTest.C819
-rw-r--r--src/usr/hwpf/test/fapiTargetTest.C295
-rw-r--r--src/usr/hwpf/test/fapirctest.H437
-rw-r--r--src/usr/hwpf/test/fapitargettest.H205
-rw-r--r--src/usr/hwpf/test/hwpftest.H41
-rw-r--r--src/usr/hwpf/test/makefile1
6 files changed, 1271 insertions, 527 deletions
diff --git a/src/usr/hwpf/test/fapiRcTest.C b/src/usr/hwpf/test/fapiRcTest.C
new file mode 100644
index 000000000..8be88bcc0
--- /dev/null
+++ b/src/usr/hwpf/test/fapiRcTest.C
@@ -0,0 +1,819 @@
+/**
+ * @file fapiTargetTest.C
+ *
+ * @brief Implements Target class unit test functions.
+ */
+
+/*
+ * Change Log ******************************************************************
+ * Flag Defect/Feature User Date Description
+ * ------ -------------- ---------- ----------- ----------------------------
+ * mjjones 04/13/2011 Created.
+ * mjjones 07/26/2011 Added more tests
+ *
+ */
+
+#include <fapi.H>
+
+namespace fapi
+{
+
+//******************************************************************************
+// rcTest1. Ensures that the ReturnCode default constructor works
+//******************************************************************************
+uint32_t rcTest1()
+{
+ uint32_t l_result = 0;
+
+ // Create ReturnCode using default constructor
+ ReturnCode l_rc;
+
+ // Ensure that the embedded return code is success
+ if (l_rc != FAPI_RC_SUCCESS)
+ {
+ FAPI_ERR("rcTest1. Code is 0x%x, expected success",
+ static_cast<uint32_t>(l_rc));
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that ok function works
+ if (l_rc.ok() == false)
+ {
+ FAPI_ERR("rcTest1. ok returned false");
+ l_result = 2;
+ }
+ else
+ {
+ // Ensure that testing l_rc works
+ if (l_rc)
+ {
+ FAPI_ERR("rcTest1. testing rc returned true");
+ l_result = 3;
+ }
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest2. Ensures that the ReturnCode creator reflects the return code
+//******************************************************************************
+uint32_t rcTest2()
+{
+ uint32_t l_result = 0;
+
+ // Create ReturnCode using default constructor
+ ReturnCode l_rc;
+
+ // Set the return code to a FAPI code
+ l_rc = FAPI_RC_FAPI_MASK | 0x05;
+
+ // Ensure that the creator is FAPI
+ ReturnCode::returnCodeCreator l_creator = l_rc.getCreator();
+
+ if (l_creator != ReturnCode::CREATOR_FAPI)
+ {
+ FAPI_ERR("rcTest2. Creator is 0x%x, expected FAPI", l_creator);
+ l_result = 1;
+ }
+ else
+ {
+ // Set the return code to a PLAT code
+ l_rc = FAPI_RC_PLAT_ERR_SEE_DATA;
+
+ // Ensure that the creator is PLAT
+ l_creator = l_rc.getCreator();
+
+ if (l_creator != ReturnCode::CREATOR_PLAT)
+ {
+ FAPI_ERR("rcTest2. Creator is 0x%x, expected PLAT", l_creator);
+ l_result = 2;
+ }
+ else
+ {
+ // Set the return code to a HWP code
+ l_rc = 5;
+
+ // Ensure that the creator is HWP
+ l_creator = l_rc.getCreator();
+
+ if (l_creator != ReturnCode::CREATOR_HWP)
+ {
+ FAPI_ERR("rcTest2. Creator is 0x%x, expected HWP", l_creator);
+ l_result = 3;
+ }
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest3. Ensures that the ReturnCode constructor works when specifying a
+// return code
+//******************************************************************************
+uint32_t rcTest3()
+{
+ uint32_t l_result = 0;
+
+ // Create ReturnCode specifying a return code
+ uint32_t l_code = 4;
+ ReturnCode l_rc(l_code);
+
+ // Ensure that the embedded return code is as expected
+ uint32_t l_codeCheck = l_rc;
+
+ if (l_codeCheck != l_code)
+ {
+ FAPI_ERR("rcTest3. Code is 0x%x, expected 0x%x", l_codeCheck,
+ l_code);
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that ok function returns false
+ if (l_rc.ok())
+ {
+ FAPI_ERR("rcTest3. ok returned true");
+ l_result = 2;
+ }
+ else
+ {
+ // Ensure that testing l_rc works
+ if (!l_rc)
+ {
+ FAPI_ERR("rcTest3. testing rc returned false");
+ l_result = 3;
+ }
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest4. Ensures that the comparison operators work (comparing with another
+// ReturnCode)
+//******************************************************************************
+uint32_t rcTest4()
+{
+ uint32_t l_result = 0;
+
+ // Create similar ReturnCodes
+ uint32_t l_code = 6;
+ uint32_t l_code2 = 7;
+ ReturnCode l_rc(l_code);
+ ReturnCode l_rc2(l_code);
+
+ // Ensure that the equality comparison returns true
+ if (!(l_rc == l_rc2))
+ {
+ FAPI_ERR("rcTest5. 1. Equality comparison false");
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that the inequality comparison returns false
+ if (l_rc != l_rc2)
+ {
+ FAPI_ERR("rcTest5. 2. Inequality comparison true");
+ l_result = 2;
+ }
+ else
+ {
+ // Change the code of l_rc2
+ l_rc2 = l_code2;
+
+ // Ensure that the equality comparison returns false
+ if (l_rc == l_rc2)
+ {
+ FAPI_ERR("rcTest5. 3. Equality comparison true");
+ l_result = 3;
+ }
+ else
+ {
+ // Ensure that the inequality comparison returns true
+ if (!(l_rc != l_rc2))
+ {
+ FAPI_ERR("rcTest5. 4. Inequality comparison false");
+ l_result = 4;
+ }
+ }
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest5. Ensures that the comparison operators work (comparing with a return
+// code value)
+//******************************************************************************
+uint32_t rcTest5()
+{
+ uint32_t l_result = 0;
+
+ // Create a ReturnCode
+ uint32_t l_code = 6;
+ uint32_t l_code2 = 7;
+ ReturnCode l_rc(l_code);
+
+ // Ensure that the equality comparison returns true when comparing to the
+ // same return code value
+ if (!(l_rc == l_code))
+ {
+ FAPI_ERR("rcTest6. 1. Equality comparison false");
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that the inequality comparison returns false when comparing to
+ // the same return code value
+ if (l_rc != l_code)
+ {
+ FAPI_ERR("rcTest6. 2. Inequality comparison true");
+ l_result = 2;
+ }
+ else
+ {
+ // Ensure that the equality comparison returns false when comparing
+ // to a different return code value
+ if (l_rc == l_code2)
+ {
+ FAPI_ERR("rcTest6. 3. Equality comparison true");
+ l_result = 3;
+ }
+ else
+ {
+ // Ensure that the inequality comparison returns true when
+ // comparing to a different return code value
+ if (!(l_rc != l_code2))
+ {
+ FAPI_ERR("rcTest6. 4. Inequality comparison false");
+ l_result = 4;
+ }
+ }
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest6. Ensures that the getPlatData and releasePlatData functions work when
+// there is no attached data
+//******************************************************************************
+uint32_t rcTest6()
+{
+ uint32_t l_result = 0;
+
+ // Create a ReturnCode
+ uint32_t l_code = 6;
+ ReturnCode l_rc(l_code);
+
+ // Ensure that the getPlatData function returns NULL
+ void * l_pData = reinterpret_cast<void *> (0x12345678);
+
+ l_pData = l_rc.getPlatData();
+
+ if (l_pData != NULL)
+ {
+ FAPI_ERR("rcTest7. getPlatData did not return NULL");
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that the releasePlatData function returns NULL
+ l_pData = reinterpret_cast<void *> (0x12345678);
+
+ l_pData = l_rc.releasePlatData();
+
+ if (l_pData != NULL)
+ {
+ FAPI_ERR("rcTest7. releasePlatData did not return NULL");
+ l_result = 2;
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest7. Ensures that the getPlatData function works when there is attached
+// data
+//******************************************************************************
+uint32_t rcTest7()
+{
+ uint32_t l_result = 0;
+
+ // Create a ReturnCode
+ uint32_t l_code = 10;
+ ReturnCode l_rc(l_code);
+
+ // Assign PlatData. Note that this should really be an errlHndl_t, because
+ // the FSP deleteData function will attempt to delete an error log, but this
+ // is just for test, the data will be released before the ReturnCode is
+ // destructed.
+ uint32_t l_myData = 6;
+ void * l_pMyData = reinterpret_cast<void *> (&l_myData);
+ (void) l_rc.setPlatData(l_pMyData);
+
+ // Ensure that getPlatData retrieves the PlatData
+ void * l_pMyDataCheck = l_rc.getPlatData();
+
+ if (l_pMyDataCheck != l_pMyData)
+ {
+ FAPI_ERR("rcTest8. 1. getPlatData returned unexpected data ptr");
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that getPlatData retrieves the PlatData again
+ l_pMyDataCheck = NULL;
+ l_pMyDataCheck = l_rc.getPlatData();
+
+ if (l_pMyDataCheck != l_pMyData)
+ {
+ FAPI_ERR("rcTest8. 2. getPlatData returned unexpected data ptr");
+ l_result = 2;
+ }
+ }
+
+ // Release the data to avoid ReturnCode from deleting in on destruction
+ l_pMyDataCheck = l_rc.releasePlatData();
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest8. Ensures that the releasePlatData function works when there is
+// attached data
+//******************************************************************************
+uint32_t rcTest8()
+{
+ uint32_t l_result = 0;
+
+ // Create a ReturnCode
+ uint32_t l_code = 10;
+ ReturnCode l_rc(l_code);
+
+ // Assign PlatData. Note that this should really be an errlHndl_t, because
+ // the FSP deleteData function will attempt to delete an error log, but this
+ // is just for test, the data will be released before the ReturnCode is
+ // destructed.
+ uint32_t l_myData = 6;
+ void * l_pMyData = reinterpret_cast<void *> (&l_myData);
+ (void) l_rc.setPlatData(l_pMyData);
+
+ // Ensure that releasePlatData retrieves the PlatData
+ void * l_pMyDataCheck = l_rc.releasePlatData();
+
+ if (l_pMyDataCheck != l_pMyData)
+ {
+ FAPI_ERR("rcTest9. getPlatData returned unexpected data ptr");
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that releasePlatData now returns NULL
+ l_pMyDataCheck = NULL;
+ l_pMyDataCheck = l_rc.releasePlatData();
+
+ if (l_pMyDataCheck != NULL)
+ {
+ FAPI_ERR("rcTest9. 2. getPlatData returned non NULL ptr");
+ l_result = 2;
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest9. Ensures that the copy constructor works when there is attached
+// PlatData and that the getPlatData function works
+//******************************************************************************
+uint32_t rcTest9()
+{
+ uint32_t l_result = 0;
+
+ // Create a ReturnCode
+ uint32_t l_code = 10;
+ ReturnCode l_rc(l_code);
+
+ // Assign PlatData. Note that this should really be an errlHndl_t, because
+ // the FSP deleteData function will attempt to delete an error log, but this
+ // is just for test, the data will be released before the ReturnCode is
+ // destructed.
+ uint32_t l_myData = 6;
+ void * l_pMyData = reinterpret_cast<void *> (&l_myData);
+ (void) l_rc.setPlatData(l_pMyData);
+
+ // Create a ReturnCode using the copy constructor
+ ReturnCode l_rc2(l_rc);
+
+ // Ensure that the two ReturnCodes are the same
+ if (l_rc != l_rc2)
+ {
+ FAPI_ERR("rcTest10. ReturnCodes differ");
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that getPlatData retrieves the PlatData from l_rc
+ void * l_pMyDataCheck = l_rc.getPlatData();
+
+ if (l_pMyDataCheck != l_pMyData)
+ {
+ FAPI_ERR("rcTest10. 1. getPlatData returned unexpected data ptr");
+ l_result = 2;
+ }
+ else
+ {
+ // Ensure that getPlatData retrieves the PlatData from l_rc2
+ l_pMyDataCheck = NULL;
+ l_pMyDataCheck = l_rc2.getPlatData();
+
+ if (l_pMyDataCheck != l_pMyData)
+ {
+ FAPI_ERR("rcTest10. 2. getPlatData returned unexpected data ptr");
+ l_result = 3;
+ }
+ }
+ }
+
+ // Release the data to avoid ReturnCode from deleting in on destruction.
+ // This will release the data from both copies of the ReturnCode.
+ (void) l_rc.releasePlatData();
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest10. Ensures that the assignment operator works when there is attached
+// PlatData and that the releasePlatData function works
+//******************************************************************************
+uint32_t rcTest10()
+{
+ uint32_t l_result = 0;
+
+ // Create a ReturnCode
+ uint32_t l_code = 10;
+ ReturnCode l_rc(l_code);
+
+ // Assign PlatData. Note that this should really be an errlHndl_t, because
+ // the PLAT deleteData function will attempt to delete an error log, but
+ // this is just for test, the data will be released before the ReturnCode is
+ // destructed.
+ uint32_t l_myData = 6;
+ void * l_pMyData = reinterpret_cast<void *> (&l_myData);
+ (void) l_rc.setPlatData(l_pMyData);
+
+ // Create a ReturnCode using the assignment operator
+ ReturnCode l_rc2;
+ l_rc2 = l_rc;
+
+ // Ensure that the two ReturnCodes are the same
+ if (l_rc != l_rc2)
+ {
+ FAPI_ERR("rcTest11. ReturnCodes differ");
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that releasePlatData retrieves the PlatData from l_rc
+ void * l_pMyDataCheck = l_rc.releasePlatData();
+
+ if (l_pMyDataCheck != l_pMyData)
+ {
+ FAPI_ERR("rcTest11. releasePlatData returned unexpected data ptr");
+ l_result = 2;
+ }
+ else
+ {
+ // Ensure that releasePlatData retrieves NULL from l_rc2
+ l_pMyDataCheck = NULL;
+ l_pMyDataCheck = l_rc2.releasePlatData();
+
+ if (l_pMyDataCheck != NULL)
+ {
+ FAPI_ERR("rcTest11. releasePlatData returned non NULL ptr");
+ l_result = 3;
+ }
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest11. Ensures that the getHwpFfdc functions works when there is no FFDC
+//******************************************************************************
+uint32_t rcTest11()
+{
+ uint32_t l_result = 0;
+
+ // Create a ReturnCode
+ uint32_t l_code = 6;
+ ReturnCode l_rc(l_code);
+
+ // Ensure that the getHwpFfdc function returns NULL
+ const void * l_pFfdc = reinterpret_cast<const void *> (0x12345678);
+
+ // Get FFDC pointer
+ uint32_t l_size = 0;
+ l_pFfdc = l_rc.getHwpFfdc(l_size);
+
+ if (l_pFfdc != NULL)
+ {
+ FAPI_ERR("rcTest11. getHwpFfdc did not return NULL");
+ l_result = 1;
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest12. Ensures that the getHwpFfdc function works when there is FFDC
+//******************************************************************************
+uint32_t rcTest12()
+{
+ uint32_t l_result = 0;
+ uint32_t l_code = 10;
+
+ // Create a ReturnCode
+ ReturnCode l_rc(l_code);
+
+ // Add HwpFfdc.
+ uint32_t l_myData[2] = {4, 5};
+ void * l_pMyData = reinterpret_cast<void *> (l_myData);
+ (void) l_rc.setHwpFfdc(l_pMyData, sizeof(l_myData));
+
+ // Ensure that getHwpFfdc returns a pointer to the same data
+ uint32_t l_size = 0;
+ const uint32_t * l_pMyDataCheck = reinterpret_cast<const uint32_t *>
+ (l_rc.getHwpFfdc(l_size));
+
+ if (l_size != sizeof(l_myData))
+ {
+ FAPI_ERR("rcTest12. getHwpFfdc returned bad size %d", l_size);
+ l_result = 1;
+ }
+ else if ((l_pMyDataCheck[0] != 4) || (l_pMyDataCheck[1] != 5))
+ {
+ FAPI_ERR("rcTest12. getHwpFfdc returned bad data");
+ l_result = 2;
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest13. Ensures that the copy constructor works when there is FFDC and that
+// the getHwpFfdc function works
+//******************************************************************************
+uint32_t rcTest13()
+{
+ uint32_t l_result = 0;
+ uint32_t l_code = 10;
+
+ // Create a ReturnCode
+ ReturnCode l_rc(l_code);
+
+ // Add HwpFfdc.
+ uint32_t l_myData[2] = {4, 5};
+ void * l_pMyData = reinterpret_cast<void *> (l_myData);
+ (void) l_rc.setHwpFfdc(l_pMyData, sizeof(l_myData));
+
+ // Create a ReturnCode using the copy constructor
+ ReturnCode l_rc2(l_rc);
+
+ // Ensure that the two ReturnCodes are the same
+ if (l_rc != l_rc2)
+ {
+ FAPI_ERR("rcTest13. ReturnCodes differ");
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that getHwpFfdc returns a pointer to the same data from l_rc
+ uint32_t l_size = 0;
+ const uint32_t * l_pMyDataCheck = reinterpret_cast<const uint32_t *>
+ (l_rc.getHwpFfdc(l_size));
+
+ if (l_size != sizeof(l_myData))
+ {
+ FAPI_ERR("rcTest13. getHwpFfdc returned bad size %d", l_size);
+ l_result = 2;
+ }
+ else if ((l_pMyDataCheck[0] != 4) || (l_pMyDataCheck[1] != 5))
+ {
+ FAPI_ERR("rcTest13. getHwpFfdc returned bad data");
+ l_result = 3;
+ }
+ else
+ {
+ // Ensure that getHwpFfdc returns a pointer to the same data from
+ // l_rc2
+ uint32_t l_size2 = 0;
+ const uint32_t * l_pMyDataCheck2 = reinterpret_cast<const uint32_t *>
+ (l_rc2.getHwpFfdc(l_size2));
+
+ if (l_size2 != sizeof(l_myData))
+ {
+ FAPI_ERR("rcTest13. getHwpFfdc(2) returned bad size %d",
+ l_size2);
+ l_result = 4;
+ }
+ else if ((l_pMyDataCheck2[0] != 4) || (l_pMyDataCheck2[1] != 5))
+ {
+ FAPI_ERR("rcTest13. getHwpFfdc(2) returned bad data");
+ l_result = 5;
+ }
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest14. Ensures that the assignment operator works when there is FFDC and
+// that the getHwpFfdc function works
+//******************************************************************************
+uint32_t rcTest14()
+{
+ uint32_t l_result = 0;
+ uint32_t l_code = 10;
+
+ // Create a ReturnCode
+ ReturnCode l_rc(l_code);
+
+ // Add HwpFfdc.
+ uint32_t l_myData[2] = {4, 5};
+ void * l_pMyData = reinterpret_cast<void *> (l_myData);
+ (void) l_rc.setHwpFfdc(l_pMyData, sizeof(l_myData));
+
+ // Create a ReturnCode using the assignment operator
+ ReturnCode l_rc2;
+ l_rc2 = l_rc;
+
+ // Ensure that the two ReturnCodes are the same
+ if (l_rc != l_rc2)
+ {
+ FAPI_ERR("rcTest14. ReturnCodes differ");
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that getHwpFfdc returns a pointer to the same data from l_rc
+ uint32_t l_size = 0;
+ const uint32_t * l_pMyDataCheck = reinterpret_cast<const uint32_t *>
+ (l_rc.getHwpFfdc(l_size));
+
+ if (l_size != sizeof(l_myData))
+ {
+ FAPI_ERR("rcTest14. getHwpFfdc returned bad size %d", l_size);
+ l_result = 2;
+ }
+ else if ((l_pMyDataCheck[0] != 4) || (l_pMyDataCheck[1] != 5))
+ {
+ FAPI_ERR("rcTest14. getHwpFfdc returned bad data");
+ l_result = 3;
+ }
+ else
+ {
+ // Ensure that getHwpFfdc returns a pointer to the same data from
+ // l_rc2
+ uint32_t l_size2 = 0;
+ const uint32_t * l_pMyDataCheck2 = reinterpret_cast<const uint32_t *>
+ (l_rc2.getHwpFfdc(l_size2));
+
+ if (l_size2 != sizeof(l_myData))
+ {
+ FAPI_ERR("rcTest14. getHwpFfdc(2) returned bad size %d",
+ l_size2);
+ l_result = 4;
+ }
+ else if ((l_pMyDataCheck2[0] != 4) || (l_pMyDataCheck2[1] != 5))
+ {
+ FAPI_ERR("rcTest14. getHwpFfdc(2) returned bad data");
+ l_result = 5;
+ }
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest15. Ensures that the setErrTarget function works when there is no error
+//******************************************************************************
+uint32_t rcTest15()
+{
+ uint32_t l_result = 0;
+
+ // Create a ReturnCode
+ ReturnCode l_rc;
+
+ // Create a Target
+ uint8_t l_handle = 7;
+ void * l_pHandle = reinterpret_cast<void *>(&l_handle);
+ Target l_target(TARGET_TYPE_DIMM, l_pHandle);
+
+ // Set the error target
+ l_rc.setErrTarget(l_target);
+
+ // Retreive the Error target (should be null because no error)
+ Target * l_pTarget = l_rc.getErrTarget();
+
+ if (l_pTarget != NULL)
+ {
+ FAPI_ERR("rcTest15. getErrTarget returned non-null pointer");
+ l_result = 1;
+ }
+
+ // Set the handle pointer to NULL to prevent any problem on destruction
+ l_target.set(NULL);
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest16. Ensures that the setErrTarget function works when there is an error
+//******************************************************************************
+uint32_t rcTest16()
+{
+ uint32_t l_result = 0;
+
+ // Create a ReturnCode with an error
+ ReturnCode l_rc(8);
+
+ // Create a Target
+ uint8_t l_handle = 7;
+ void * l_pHandle = reinterpret_cast<void *>(&l_handle);
+ Target l_target(TARGET_TYPE_DIMM, l_pHandle);
+
+ // Set the error target
+ l_rc.setErrTarget(l_target);
+
+ // Retreive the Error target
+ Target * l_pTarget = l_rc.getErrTarget();
+
+ if (*l_pTarget != l_target)
+ {
+ FAPI_ERR("rcTest16. getErrTarget returned bad target");
+ l_result = 1;
+ }
+
+ // Set the handle pointer to NULL to prevent any problem on destruction
+ l_target.set(NULL);
+
+ return l_result;
+}
+
+//******************************************************************************
+// rcTest17. Ensures that the setErrTarget function works when there is an error
+// and an existing Target
+//******************************************************************************
+uint32_t rcTest17()
+{
+ uint32_t l_result = 0;
+
+ // Create a ReturnCode with an error
+ ReturnCode l_rc(8);
+
+ // Create a Target
+ uint8_t l_handle = 7;
+ void * l_pHandle = reinterpret_cast<void *>(&l_handle);
+ Target l_target(TARGET_TYPE_DIMM, l_pHandle);
+
+ // Create another Target
+ uint8_t l_handle2 = 8;
+ void * l_pHandle2 = reinterpret_cast<void *>(&l_handle2);
+ Target l_target2(TARGET_TYPE_DIMM, l_pHandle2);
+
+ // Set the error target
+ l_rc.setErrTarget(l_target);
+
+ // Attempt to set the error target again (should not be set because there is
+ // already an error target)
+ l_rc.setErrTarget(l_target2);
+
+ // Retreive the Error target
+ Target * l_pTarget = l_rc.getErrTarget();
+
+ if (*l_pTarget != l_target)
+ {
+ FAPI_ERR("rcTest17. getErrTarget returned bad target");
+ l_result = 1;
+ }
+
+ // Set the handle pointer to NULL to prevent any problem on destruction
+ l_target.set(NULL);
+
+ return l_result;
+}
+
+}
diff --git a/src/usr/hwpf/test/fapiTargetTest.C b/src/usr/hwpf/test/fapiTargetTest.C
new file mode 100644
index 000000000..634a42222
--- /dev/null
+++ b/src/usr/hwpf/test/fapiTargetTest.C
@@ -0,0 +1,295 @@
+/**
+ * @file fapitargetTest.C
+ *
+ * @brief Implements Target class unit test functions.
+ */
+
+/*
+ * Change Log ******************************************************************
+ * Flag Defect/Feature User Date Description
+ * ------ -------------- ---------- ----------- ----------------------------
+ * mjjones 04/13/2011 Created.
+ *
+ */
+
+#include <fapi.H>
+
+namespace fapi
+{
+
+//******************************************************************************
+// targetTest1
+//******************************************************************************
+uint32_t targetTest1()
+{
+ uint32_t l_result = 0;
+
+ // Create Target using default constructor
+ Target l_target;
+
+ // Ensure that the handle pointer is NULL
+ void * l_pHandle = l_target.get();
+
+ if (l_pHandle != NULL)
+ {
+ FAPI_ERR("targetTest1. Handle is not NULL");
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that the type is TARGET_TYPE_NONE
+ TargetType l_type = l_target.getType();
+
+ if (l_type != TARGET_TYPE_NONE)
+ {
+ FAPI_ERR("targetTest1. Type is 0x%x, expected NONE", l_type);
+ l_result = 2;
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// targetTest2
+//******************************************************************************
+uint32_t targetTest2()
+{
+ uint32_t l_result = 0;
+ uint8_t l_handle = 7;
+ void * l_pHandle = reinterpret_cast<void *>(&l_handle);
+
+ // Create Target
+ Target l_target(TARGET_TYPE_DIMM, l_pHandle);
+
+ // Ensure that the handle pointer is as expected
+ void * l_pHandleCheck = l_target.get();
+
+ if (l_pHandleCheck != l_pHandle)
+ {
+ FAPI_ERR("targetTest2. Handle is not as expected");
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that the type is TARGET_TYPE_DIMM
+ TargetType l_type = l_target.getType();
+
+ if (l_type != TARGET_TYPE_DIMM)
+ {
+ FAPI_ERR("targetTest2. Type is 0x%x, expected DIMM", l_type);
+ l_result = 2;
+ }
+ }
+
+ // Set the handle pointer to NULL to prevent any problem on destruction
+ l_target.set(NULL);
+
+ return l_result;
+}
+
+//******************************************************************************
+// targetTest3
+//******************************************************************************
+uint32_t targetTest3()
+{
+ uint32_t l_result = 0;
+
+ // Create Target using default constructor
+ Target l_target;
+
+ // Set the handle
+ uint8_t l_handle = 7;
+ void * l_pHandle = reinterpret_cast<void *>(&l_handle);
+ l_target.set(l_pHandle);
+
+ // Ensure that the handle pointer is as expected
+ void * l_pHandleCheck = l_target.get();
+
+ if (l_pHandleCheck != l_pHandle)
+ {
+ FAPI_ERR("targetTest3. Handle is not as expected");
+ l_result = 1;
+ }
+ else
+ {
+ // Set the type
+ l_target.setType(TARGET_TYPE_DIMM);
+
+ // Ensure that the type is TARGET_TYPE_DIMM
+ TargetType l_type = l_target.getType();
+
+ if (l_type != TARGET_TYPE_DIMM)
+ {
+ FAPI_ERR("targetTest3. Type is 0x%x, expected DIMM", l_type);
+ l_result = 2;
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// targetTest4
+//******************************************************************************
+uint32_t targetTest4()
+{
+ uint32_t l_result = 0;
+
+ // Create Target
+ uint8_t l_handle = 7;
+ void * l_pHandle = reinterpret_cast<void *>(&l_handle);
+ Target l_target(TARGET_TYPE_DIMM, l_pHandle);
+
+ // Create Target using copy constructor
+ Target l_target2(l_target);
+
+ // Ensure that the target types are the same
+ TargetType l_type = l_target.getType();
+ TargetType l_type2 = l_target2.getType();
+
+ if (l_type != l_type2)
+ {
+ FAPI_ERR("targetTest4. Types are not the same (0x%x, 0x%x)", l_type,
+ l_type2);
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that the handles are the same
+ void * l_han1 = l_target.get();
+ void * l_han2 = l_target2.get();
+
+ if (l_han1 != l_han2)
+ {
+ FAPI_ERR("targetTest4. Handles are not the same");
+ l_result = 2;
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// targetTest5
+//******************************************************************************
+uint32_t targetTest5()
+{
+ uint32_t l_result = 0;
+
+ // Create Target
+ uint8_t l_handle = 7;
+ void * l_pHandle = reinterpret_cast<void *>(&l_handle);
+ Target l_target(TARGET_TYPE_DIMM, l_pHandle);
+
+ // Create Target using assignment operator
+ Target l_target2;
+ l_target2 = l_target;
+
+ // Ensure that the target types are the same
+ TargetType l_type = l_target.getType();
+ TargetType l_type2 = l_target2.getType();
+
+ if (l_type != l_type2)
+ {
+ FAPI_ERR("targetTest5. Types are not the same (0x%x, 0x%x)", l_type,
+ l_type2);
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that the handles are the same
+ void * l_han1 = l_target.get();
+ void * l_han2 = l_target2.get();
+
+ if (l_han1 != l_han2)
+ {
+ FAPI_ERR("targetTest5. Handles are not the same");
+ l_result = 2;
+ }
+ }
+
+ return l_result;
+}
+
+//******************************************************************************
+// targetTest6
+//******************************************************************************
+uint32_t targetTest6()
+{
+ uint32_t l_result = 0;
+
+ // Create similar Targets
+ uint8_t l_handle = 7;
+ void * l_pHandle = reinterpret_cast<void *>(&l_handle);
+ Target l_target(TARGET_TYPE_DIMM, l_pHandle);
+ Target l_target2(TARGET_TYPE_DIMM, l_pHandle);
+
+ // Ensure that the equality comparison returns true
+ if (!(l_target == l_target2))
+ {
+ FAPI_ERR("targetTest6. 1. Equality comparison false");
+ l_result = 1;
+ }
+ else
+ {
+ // Ensure that the inequality comparison returns false
+ if (l_target != l_target2)
+ {
+ FAPI_ERR("targetTest6. 2. Inequality comparison true");
+ l_result = 2;
+ }
+ else
+ {
+ // Change the target type of l_target2
+ (void)l_target2.setType(TARGET_TYPE_PROC_CHIP);
+
+ // Ensure that the equality comparison returns false
+ if (l_target == l_target2)
+ {
+ FAPI_ERR("targetTest6. 3. Equality comparison true");
+ l_result = 3;
+ }
+ else
+ {
+ // Ensure that the inequality comparison returns true
+ if (!(l_target != l_target2))
+ {
+ FAPI_ERR("targetTest6. 4. Inequality comparison false");
+ l_result = 4;
+ }
+ else
+ {
+ // Reset the target type of l_target2
+ (void)l_target2.setType(TARGET_TYPE_DIMM);
+
+ // Change the handle of l_target
+ uint8_t l_handle2 = 7;
+ void * l_pHandle2 = reinterpret_cast<void *>(&l_handle2);
+ (void)l_target.set(l_pHandle2);
+
+ // Ensure that the equality comparison returns false
+ if (l_target == l_target2)
+ {
+ FAPI_ERR("targetTest6. 5. Equality comparison true");
+ l_result = 5;
+ }
+ else
+ {
+ // Ensure that the inequality comparison returns true
+ if (!(l_target != l_target2))
+ {
+ FAPI_ERR("targetTest6. 6. Inequality comparison "
+ "false");
+ l_result = 6;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return l_result;
+}
+
+}
diff --git a/src/usr/hwpf/test/fapirctest.H b/src/usr/hwpf/test/fapirctest.H
index 140882483..8f9c3a502 100644
--- a/src/usr/hwpf/test/fapirctest.H
+++ b/src/usr/hwpf/test/fapirctest.H
@@ -9,6 +9,7 @@
#include <cxxtest/TestSuite.H>
#include <fapi.H>
+#include "fapiRcTest.C"
using namespace fapi;
@@ -21,31 +22,12 @@ public:
*/
void testRc1(void)
{
- // Create ReturnCode using default constructor
- ReturnCode l_rc;
+ uint32_t l_res = rcTest1();
- // Ensure that the embedded return code is success
- if (l_rc != FAPI_RC_SUCCESS)
+ if (l_res != 0)
{
- TS_FAIL("testRc1. ReturnCode init is not FAPI_RC_SUCCESS");
+ TS_FAIL("testRc1. Fail");
}
- else
- {
- // Ensure that OK function works
- if (l_rc.ok() == false)
- {
- TS_FAIL("testRc1. ok() returned false");
- }
- else
- {
- // Ensure that testing l_rc works
- if (l_rc)
- {
- TS_FAIL("testRc1. testing rc returned true");
- }
- }
- }
- return;
}
@@ -54,47 +36,12 @@ public:
*/
void testRc2()
{
+ uint32_t l_res = rcTest2();
- // Create ReturnCode using default constructor
- ReturnCode l_rc;
-
- // Set the return code to a FAPI code
- l_rc = FAPI_RC_FAPI_MASK | 0x05;
-
- // Ensure that the creator is FAPI
- ReturnCode::returnCodeCreator l_creator = l_rc.getCreator();
-
- if (l_creator != ReturnCode::CREATOR_FAPI)
+ if (l_res != 0)
{
- TS_FAIL("testRc2. Creator is not CREATOR_FAPI");
+ TS_FAIL("testRc2. Fail");
}
- else
- {
- // Set the return code to a PLAT code
- l_rc = FAPI_RC_PLAT_ERR_SEE_DATA;
-
- // Ensure that the creator is PLAT
- l_creator = l_rc.getCreator();
-
- if (l_creator != ReturnCode::CREATOR_PLAT)
- {
- TS_FAIL("testRc2. Creator is not CREATOR_PLAT");
- }
- else
- {
- l_rc = 5;
-
- // Ensure that the creator is HWP
- l_creator = l_rc.getCreator();
-
- if (l_creator != ReturnCode::CREATOR_HWP)
- {
- TS_FAIL("testRc2. Creator is not CREATOR_HWP");
- }
- }
- }
-
- return;
}
/**
@@ -102,35 +49,12 @@ public:
*/
void testRc3()
{
- uint32_t l_code = 4;
+ uint32_t l_res = rcTest3();
- // Create ReturnCode specifying a return code
- ReturnCode l_rc(l_code);
-
- // Ensure that the embedded return code is as expected
- uint32_t l_codeCheck = l_rc;
-
- if (l_codeCheck != l_code)
+ if (l_res != 0)
{
- TS_FAIL("testRc3. Code is not set as desired");
+ TS_FAIL("testRc3. Fail");
}
- else
- {
- // Ensure that ok function returns false
- if (l_rc.ok())
- {
- TS_FAIL("testRc3. ok returned true");
- }
- else
- {
- // Ensure that testing l_rc works
- if (!l_rc)
- {
- TS_FAIL("testRc3. testing rc returned false");
- }
- }
- }
-
return;
}
@@ -139,46 +63,12 @@ public:
*/
void testRc4()
{
- uint32_t l_code = 6;
- uint32_t l_code2 = 7;
-
- // Create similar ReturnCodes
- ReturnCode l_rc(l_code);
- ReturnCode l_rc2(l_code);
+ uint32_t l_res = rcTest4();
- // Ensure that the equality comparison returns true
- if (!(l_rc == l_rc2))
+ if (l_res != 0)
{
- TS_FAIL("testRc4. Equality comparison false");
+ TS_FAIL("testRc4. Fail");
}
- else
- {
- // Ensure that the inequality comparison returns false
- if (l_rc != l_rc2)
- {
- TS_FAIL("testRc4.Inequality comparison true");
- }
- else
- {
- // Change the code of l_rc2
- l_rc2 = l_code2;
-
- // Ensure that the equality comparison returns false
- if (l_rc == l_rc2)
- {
- TS_FAIL("testRc4. Equality comparison true");
- }
- else
- {
- // Ensure that the inequality comparison returns true
- if (!(l_rc != l_rc2))
- {
- TS_FAIL("testRc4. Inequality comparison false");
- }
- }
- }
- }
-
return;
}
@@ -187,46 +77,12 @@ public:
*/
void testRc5()
{
- uint32_t l_code = 6;
- uint32_t l_code2 = 7;
+ uint32_t l_res = rcTest5();
- // Create a ReturnCode
- ReturnCode l_rc(l_code);
-
- // Ensure that the equality comparison returns true when comparing to the
- // same return code value
- if (!(l_rc == l_code))
- {
- TS_FAIL("testRc5. 1. Equality comparison false");
- }
- else
+ if (l_res != 0)
{
- // Ensure that the inequality comparison returns false when comparing to
- // the same return code value
- if (l_rc != l_code)
- {
- TS_FAIL("testRc5. 2. Inequality comparison true");
- }
- else
- {
- // Ensure that the equality comparison returns false when comparing
- // to a different return code value
- if (l_rc == l_code2)
- {
- TS_FAIL("testRc5. 3. Equality comparison true");
- }
- else
- {
- // Ensure that the inequality comparison returns true when
- // comparing to a different return code value
- if (!(l_rc != l_code2))
- {
- TS_FAIL("testRc5. 4. Inequality comparison false");
- }
- }
- }
+ TS_FAIL("testRc5. Fail");
}
-
return;
}
@@ -235,32 +91,12 @@ public:
*/
void testRc6()
{
- uint32_t l_code = 6;
-
- // Create a ReturnCode
- ReturnCode l_rc(l_code);
-
- // Ensure that the getData function returns NULL
- void * l_pData = reinterpret_cast<void *> (0x12345678);
+ uint32_t l_res = rcTest6();
- l_pData = l_rc.getData();
- if (l_pData != NULL)
+ if (l_res != 0)
{
- TS_FAIL("testRc6. getData did not return NULL");
+ TS_FAIL("testRc6. Fail");
}
- else
- {
- // Ensure that the releaseData function returns NULL
- l_pData = reinterpret_cast<void *> (0x12345678);
-
- l_pData = l_rc.releaseData();
-
- if (l_pData != NULL)
- {
- TS_FAIL("testRc6. releaseData did not return NULL");
- }
- }
-
return;
}
@@ -269,41 +105,12 @@ public:
*/
void testRc7()
{
- uint32_t l_code = 10;
-
- // Create a ReturnCode
- ReturnCode l_rc(l_code);
+ uint32_t l_res = rcTest7();
- // Assign ReturnCodeData. Note that this should really be an errlHndl_t,
- // because the FSP deleteData function will attempt to delete an error
- // log, but this is just for test, the data will be released before the
- // ReturnCode is destructed.
- uint32_t l_myData = 6;
- void * l_pMyData = reinterpret_cast<void *> (&l_myData);
- (void) l_rc.setData(l_pMyData);
-
- // Ensure that getData retrieves the ReturnCodeData
- void * l_pMyDataCheck = l_rc.getData();
-
- if (l_pMyDataCheck != l_pMyData)
- {
- TS_FAIL("testRc7. getData returned unexpected data ptr");
- }
- else
+ if (l_res != 0)
{
- // Ensure that getData retrieves the ReturnCodeData again
- l_pMyDataCheck = NULL;
- l_pMyDataCheck = l_rc.getData();
-
- if (l_pMyDataCheck != l_pMyData)
- {
- TS_FAIL("testRc7. getData returned unexpected data ptr");
- }
+ TS_FAIL("testRc7. Fail");
}
-
- // Release the data to avoid ReturnCode from deleting in on destruction
- l_pMyDataCheck = l_rc.releaseData();
-
return;
}
@@ -312,150 +119,138 @@ public:
*/
void testRc8()
{
- uint32_t l_code = 10;
+ uint32_t l_res = rcTest8();
- // Create a ReturnCode
- ReturnCode l_rc(l_code);
-
- // Assign ReturnCodeData. Note that this should really be an errlHndl_t,
- // because the FSP deleteData function will attempt to delete an error
- // log, but this is just for test, the data will be released before the
- // ReturnCode is destructed.
- uint32_t l_myData = 6;
- void * l_pMyData = reinterpret_cast<void *> (&l_myData);
- (void) l_rc.setData(l_pMyData);
+ if (l_res != 0)
+ {
+ TS_FAIL("testRc8. Fail");
+ }
+ }
- // Ensure that releaseData retrieves the ReturnCodeData
- void * l_pMyDataCheck = l_rc.releaseData();
+ /**
+ * @brief Test FAPI return codes #9
+ */
+ void testRc9()
+ {
+ uint32_t l_res = rcTest9();
- if (l_pMyDataCheck != l_pMyData)
+ if (l_res != 0)
{
- TS_FAIL("testRc8. getData returned unexpected data ptr");
+ TS_FAIL("testRc9. Fail");
}
- else
+ return;
+ }
+
+ /**
+ * @brief Test FAPI return codes #10
+ */
+ void testRc10()
+ {
+ uint32_t l_res = rcTest10();
+
+ if (l_res != 0)
{
- // Ensure that releaseData now returns NULL
- l_pMyDataCheck = NULL;
- l_pMyDataCheck = l_rc.releaseData();
-
- if (l_pMyDataCheck != NULL)
- {
- TS_FAIL("testRc8. getData returned non NULL ptr");
- }
+ TS_FAIL("testRc10. Fail");
}
-
return;
}
/**
- * @brief Test FAPI return codes #9
+ * @brief Test FAPI return codes #11
*/
- void testRc9()
+ void testRc11(void)
{
- uint32_t l_code = 10;
+ uint32_t l_res = rcTest11();
- // Create a ReturnCode
- ReturnCode l_rc(l_code);
+ if (l_res != 0)
+ {
+ TS_FAIL("testRc11. Fail");
+ }
+ }
- // Assign ReturnCodeData. Note that this should really be an errlHndl_t,
- // because the FSP deleteData function will attempt to delete an error
- // log, but this is just for test, the data will be released before the
- // ReturnCode is destructed.
- uint32_t l_myData = 6;
- void * l_pMyData = reinterpret_cast<void *> (&l_myData);
- (void) l_rc.setData(l_pMyData);
- // Create a ReturnCode using the copy constructor
- ReturnCode l_rc2(l_rc);
+ /**
+ * @brief Test FAPI return codes #12
+ */
+ void testRc12()
+ {
+ uint32_t l_res = rcTest12();
- // Ensure that the two ReturnCodes are the same
- if (l_rc != l_rc2)
- {
- TS_FAIL("testRc9. ReturnCodes differ");
- }
- else
+ if (l_res != 0)
{
- // Ensure that getData retrieves the ReturnCodeData from l_rc
- void * l_pMyDataCheck = l_rc.getData();
-
- if (l_pMyDataCheck != l_pMyData)
- {
- TS_FAIL("testRc9. getData returned unexpected data ptr (1)");
- }
- else
- {
- // Ensure that getData retrieves the ReturnCodeData from l_rc2
- l_pMyDataCheck = NULL;
- l_pMyDataCheck = l_rc2.getData();
-
- if (l_pMyDataCheck != l_pMyData)
- {
- TS_FAIL("testRc9. getData returned unexpected data ptr (2)");
- }
- }
+ TS_FAIL("testRc12. Fail");
}
+ }
- // Release the data to avoid ReturnCode from deleting in on destruction.
- // This will release the data from both copies of the ReturnCode.
- (void) l_rc.releaseData();
+ /**
+ * @brief Test FAPI return codes #13
+ */
+ void testRc13()
+ {
+ uint32_t l_res = rcTest13();
+ if (l_res != 0)
+ {
+ TS_FAIL("testRc13. Fail");
+ }
return;
}
/**
- * @brief Test FAPI return codes #10
+ * @brief Test FAPI return codes #14
*/
- void testRc10()
+ void testRc14()
{
- uint32_t l_code = 10;
+ uint32_t l_res = rcTest14();
- // Create a ReturnCode
- ReturnCode l_rc(l_code);
-
- // Assign ReturnCodeData. Note that this should really be an errlHndl_t,
- // because the FSP deleteData function will attempt to delete an error
- // log, but this is just for test, the data will be released before the
- // ReturnCode is destructed.
- uint32_t l_myData = 6;
- void * l_pMyData = reinterpret_cast<void *> (&l_myData);
- (void) l_rc.setData(l_pMyData);
+ if (l_res != 0)
+ {
+ TS_FAIL("testRc14. Fail");
+ }
+ return;
+ }
- // Create a ReturnCode using the assignment operator
- ReturnCode l_rc2;
- l_rc2 = l_rc;
+ /**
+ * @brief Test FAPI return codes #15
+ */
+ void testRc15()
+ {
+ uint32_t l_res = rcTest15();
- // Ensure that the two ReturnCodes are the same
- if (l_rc != l_rc2)
+ if (l_res != 0)
{
- TS_FAIL("testRc10. ReturnCodes differ");
+ TS_FAIL("testRc15. Fail");
}
- else
+ return;
+ }
+
+ /**
+ * @brief Test FAPI return codes #16
+ */
+ void testRc16()
+ {
+ uint32_t l_res = rcTest16();
+
+ if (l_res != 0)
{
- // Ensure that releaseData retrieves the ReturnCodeData from l_rc
- void * l_pMyDataCheck = l_rc.releaseData();
-
- if (l_pMyDataCheck != l_pMyData)
- {
- TS_FAIL("testRc10. releaseData returned unexpected data ptr");
- }
- else
- {
- // Ensure that releaseData retrieves NULL from l_rc2
- l_pMyDataCheck = NULL;
- l_pMyDataCheck = l_rc2.releaseData();
-
- if (l_pMyDataCheck != NULL)
- {
- TS_FAIL("testRc10. releaseData returned non NULL ptr");
- }
- }
+ TS_FAIL("testRc16. Fail");
}
-
return;
}
+ /**
+ * @brief Test FAPI return codes #17
+ */
+ void testRc17()
+ {
+ uint32_t l_res = rcTest17();
-
+ if (l_res != 0)
+ {
+ TS_FAIL("testRc17. Fail");
+ }
+ return;
+ }
};
#endif
diff --git a/src/usr/hwpf/test/fapitargettest.H b/src/usr/hwpf/test/fapitargettest.H
index 6cd8fd9b8..74f68bfc6 100644
--- a/src/usr/hwpf/test/fapitargettest.H
+++ b/src/usr/hwpf/test/fapitargettest.H
@@ -9,6 +9,7 @@
#include <cxxtest/TestSuite.H>
#include <fapi.H>
+#include "fapiTargetTest.C"
using namespace fapi;
@@ -21,27 +22,12 @@ public:
*/
void testTarget1()
{
- // Create Target using default constructor
- Target l_target;
+ uint32_t l_res = targetTest1();
- // Ensure that the handle pointer is NULL
- void * l_pHandle = l_target.get();
-
- if (l_pHandle != NULL)
- {
- TS_FAIL("testTarget1. Handle is not NULL");
- }
- else
+ if (l_res != 0)
{
- // Ensure that the type is TARGET_TYPE_NONE
- TargetType l_type = l_target.getType();
- if (l_type != TARGET_TYPE_NONE)
- {
- TS_FAIL("testTarget1. Type is not TARGET_TYPE_NONE");
- }
+ TS_FAIL("testTarget1. Fail");
}
-
- return;
}
/**
@@ -49,34 +35,12 @@ public:
*/
void testTarget2()
{
- uint8_t l_handle = 7;
- void * l_pHandle = reinterpret_cast<void *>(&l_handle);
-
- // Create Target
- Target l_target(TARGET_TYPE_DIMM, l_pHandle);
+ uint32_t l_res = targetTest2();
- // Ensure that the handle pointer is as expected
- void * l_pHandleCheck = l_target.get();
-
- if (l_pHandleCheck != l_pHandle)
+ if (l_res != 0)
{
- TS_FAIL("testTarget2. Handle is not as expected");
+ TS_FAIL("testTarget2. Fail");
}
- else
- {
- // Ensure that the type is TARGET_TYPE_DIMM
- TargetType l_type = l_target.getType();
-
- if (l_type != TARGET_TYPE_DIMM)
- {
- TS_FAIL("testTarget2. Type is not TARGET_TYPE_DIMM");
- }
- }
-
- // Set the handle pointer to NULL to prevent any problem on destruction
- l_target.set(NULL);
-
- return;
}
/**
@@ -84,36 +48,12 @@ public:
*/
void testTarget3()
{
- // Create Target using default constructor
- Target l_target;
-
- // Set the handle
- uint8_t l_handle = 7;
- void * l_pHandle = reinterpret_cast<void *>(&l_handle);
- l_target.set(l_pHandle);
-
- // Ensure that the handle pointer is as expected
- void * l_pHandleCheck = l_target.get();
+ uint32_t l_res = targetTest3();
- if (l_pHandleCheck != l_pHandle)
+ if (l_res != 0)
{
- TS_FAIL("testTarget3. Handle is not as expected");
+ TS_FAIL("testTarget3. Fail");
}
- else
- {
- // Set the type
- l_target.setType(TARGET_TYPE_DIMM);
-
- // Ensure that the type is TARGET_TYPE_DIMM
- TargetType l_type = l_target.getType();
-
- if (l_type != TARGET_TYPE_DIMM)
- {
- TS_FAIL("testTarget3. Type is not TARGET_TYPE_DIMM");
- }
- }
-
- return;
}
/**
@@ -121,35 +61,12 @@ public:
*/
void testTarget4()
{
- // Create Target
- uint8_t l_handle = 7;
- void * l_pHandle = reinterpret_cast<void *>(&l_handle);
- Target l_target(TARGET_TYPE_DIMM, l_pHandle);
-
- // Create Target using copy constructor
- Target l_target2(l_target);
+ uint32_t l_res = targetTest4();
- // Ensure that the target types are the same
- TargetType l_type = l_target.getType();
- TargetType l_type2 = l_target2.getType();
-
- if (l_type != l_type2)
+ if (l_res != 0)
{
- TS_FAIL("testTarget4. Types are not the same ");
+ TS_FAIL("testTarget4. Fail");
}
- else
- {
- // Ensure that the handles are the same
- void * l_han1 = l_target.get();
- void * l_han2 = l_target2.get();
-
- if (l_han1 != l_han2)
- {
- TS_FAIL("testTarget4. Handles are not the same");
- }
- }
-
- return;
}
/**
@@ -157,36 +74,12 @@ public:
*/
void testTarget5()
{
- // Create Target
- uint8_t l_handle = 7;
- void * l_pHandle = reinterpret_cast<void *>(&l_handle);
- Target l_target(TARGET_TYPE_DIMM, l_pHandle);
+ uint32_t l_res = targetTest5();
- // Create Target using assignment operator
- Target l_target2;
- l_target2 = l_target;
-
- // Ensure that the target types are the same
- TargetType l_type = l_target.getType();
- TargetType l_type2 = l_target2.getType();
-
- if (l_type != l_type2)
- {
- TS_FAIL("testTarget5. Types are not the same");
- }
- else
+ if (l_res != 0)
{
- // Ensure that the handles are the same
- void * l_han1 = l_target.get();
- void * l_han2 = l_target2.get();
-
- if (l_han1 != l_han2)
- {
- TS_FAIL("testTarget5. Handles are not the same");
- }
+ TS_FAIL("testTarget5. Fail");
}
-
- return;
}
/**
@@ -194,73 +87,13 @@ public:
*/
void testTarget6()
{
- // Create similar Targets
- uint8_t l_handle = 7;
- void * l_pHandle = reinterpret_cast<void *>(&l_handle);
- Target l_target(TARGET_TYPE_DIMM, l_pHandle);
- Target l_target2(TARGET_TYPE_DIMM, l_pHandle);
+ uint32_t l_res = targetTest6();
- // Ensure that the equality comparison returns true
- if (!(l_target == l_target2))
+ if (l_res != 0)
{
- TS_FAIL("testTarget6. 1. Equality comparison false");
+ TS_FAIL("testTarget6. Fail");
}
- else
- {
- // Ensure that the inequality comparison returns false
- if (l_target != l_target2)
- {
- TS_FAIL("testTarget6. 2. Inequality comparison true");
- }
- else
- {
- // Change the target type of l_target2
- (void)l_target2.setType(TARGET_TYPE_PROC_CHIP);
-
- // Ensure that the equality comparison returns false
- if (l_target == l_target2)
- {
- TS_FAIL("testTarget6. 3. Equality comparison true");
- }
- else
- {
- // Ensure that the inequality comparison returns true
- if (!(l_target != l_target2))
- {
- TS_FAIL("testTarget6. 4. Inequality comparison false");
- }
- else
- {
- // Reset the target type of l_target2
- (void)l_target2.setType(TARGET_TYPE_DIMM);
-
- // Change the handle of l_target
- uint8_t l_handle2 = 7;
- void * l_pHandle2 = reinterpret_cast<void *>(&l_handle2);
- (void)l_target.set(l_pHandle2);
-
- // Ensure that the equality comparison returns false
- if (l_target == l_target2)
- {
- TS_FAIL("testTarget6. 5. Equality comparison true");
- }
- else
- {
- // Ensure that the inequality comparison returns true
- if (!(l_target != l_target2))
- {
- TS_FAIL("testTarget6. 6. Inequality comparison "
- "false");
- }
- }
- }
- }
- }
- }
-
- return;
}
-
};
#endif
diff --git a/src/usr/hwpf/test/hwpftest.H b/src/usr/hwpf/test/hwpftest.H
index 2bfd6734d..a4a1a12da 100644
--- a/src/usr/hwpf/test/hwpftest.H
+++ b/src/usr/hwpf/test/hwpftest.H
@@ -55,7 +55,7 @@ public:
/**
- * @brief Test HWPF: calling a procedure
+ * @brief Test HWPF: call a test procedure
*/
void testHwpf2()
{
@@ -65,43 +65,44 @@ public:
// Set processor chip to the master
TARGETING::Target* l_testTarget = MASTER_PROCESSOR_CHIP_TARGET_SENTINEL;
- // Call the hardware procedure
- bool l_clocksOn = false;
- l_err = invokeHwpIsP7EM0ChipletClockOn(l_testTarget, l_clocksOn);
+ // Call the test hardware procedure
+ l_err = invokeHwpInitialTest(l_testTarget);
if (l_err)
{
- TS_FAIL("testHwpf2: Unit Test failed. invokeHwpIsP7EM0ChipletClockOn failed. Error logged");
+ TS_FAIL("testHwpf2: Unit Test failed. invokeHwpInitialTest failed. Error logged");
// Commit/delete error
errlCommit(l_err);
}
else
{
- if (l_clocksOn)
- {
- TS_TRACE("testHwpf2: Success. Clocks are on");
- }
- else
- {
- TS_TRACE("testHwpf2: Success. Clocks are off");
- }
+ TS_TRACE("testHwpf2: Unit test passed! invokeHwpInitialTest");
}
+ }
- // Call test procedure too
- l_err = invokeHwpInitialTest(l_testTarget);
+ /**
+ * @brief Test HWPF: call a test procedure that generates an error
+ */
+ void testHwpf3()
+ {
+ // Call a test hardware procedure
+ errlHndl_t l_err = NULL;
+
+ // Set processor chip to the master
+ TARGETING::Target* l_testTarget = MASTER_PROCESSOR_CHIP_TARGET_SENTINEL;
+
+ // Call the procedure that generates an error to test out error handling
+ l_err = invokeHwpTestError(l_testTarget);
if (l_err)
{
- TS_FAIL("testHwpf2: Unit Test failed. invokeHwpInitialTest failed. Error logged");
+ TS_TRACE("testHwpf3: Unit Test passed. invokeHwpTestError failed. Error logged");
// Commit/delete error
errlCommit(l_err);
}
else
{
- TS_TRACE("testHwpf2: Unit test passed! invokeHwpInitialTest");
+ TS_FAIL("testHwpf3: Unit Test failed. invokeHwpTestError passed. Error logged");
}
-
- return;
}
-
};
#endif
diff --git a/src/usr/hwpf/test/makefile b/src/usr/hwpf/test/makefile
index c32529276..1a210d08d 100644
--- a/src/usr/hwpf/test/makefile
+++ b/src/usr/hwpf/test/makefile
@@ -3,6 +3,7 @@ ROOTPATH = ../../../..
EXTRAINCDIR += ${ROOTPATH}/src/include/usr/ecmddatabuffer
EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/fapi
EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/plat
+EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/hwp
MODULE = testhwpf
TESTS = *.H
OpenPOWER on IntegriCloud