diff options
author | Thi Tran <thi@us.ibm.com> | 2011-06-28 11:17:12 -0500 |
---|---|---|
committer | Thi N. Tran <thi@us.ibm.com> | 2011-06-30 08:19:52 -0500 |
commit | e93bda2d2a30ff9959384dce0563ab143bc30aad (patch) | |
tree | dea7e740ae61ae2fe343823ad31654fbce6992bf /src/usr/hwpf/test | |
parent | a4809cd65ce96d0b56ec316b14836087cf1d647b (diff) | |
download | blackbird-hostboot-e93bda2d2a30ff9959384dce0563ab143bc30aad.tar.gz blackbird-hostboot-e93bda2d2a30ff9959384dce0563ab143bc30aad.zip |
Initial HWPF delivery
Update after pass-around review
Change-Id: I8f81dd7820b61607e9a98d17c81e74fface42c54
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/160
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/test')
-rw-r--r-- | src/usr/hwpf/test/fapirctest.H | 461 | ||||
-rw-r--r-- | src/usr/hwpf/test/fapitargettest.H | 266 | ||||
-rw-r--r-- | src/usr/hwpf/test/hwpftest.H | 94 | ||||
-rw-r--r-- | src/usr/hwpf/test/makefile | 11 |
4 files changed, 832 insertions, 0 deletions
diff --git a/src/usr/hwpf/test/fapirctest.H b/src/usr/hwpf/test/fapirctest.H new file mode 100644 index 000000000..140882483 --- /dev/null +++ b/src/usr/hwpf/test/fapirctest.H @@ -0,0 +1,461 @@ +#ifndef __FAPItestRc_H +#define __FAPItestRc_H + +/** + * @file fapitestRc.H + * + * @brief Test case for FAPI return codes +*/ + +#include <cxxtest/TestSuite.H> +#include <fapi.H> + +using namespace fapi; + +class FapitestRc: public CxxTest::TestSuite +{ +public: + + /** + * @brief Test FAPI return codes #1 + */ + void testRc1(void) + { + // Create ReturnCode using default constructor + ReturnCode l_rc; + + // Ensure that the embedded return code is success + if (l_rc != FAPI_RC_SUCCESS) + { + TS_FAIL("testRc1. ReturnCode init is not FAPI_RC_SUCCESS"); + } + 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; + } + + + /** + * @brief Test FAPI return codes #2 + */ + void testRc2() + { + + // 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) + { + TS_FAIL("testRc2. Creator is not CREATOR_FAPI"); + } + 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; + } + + /** + * @brief Test FAPI return codes #3 + */ + void testRc3() + { + uint32_t l_code = 4; + + // 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) + { + TS_FAIL("testRc3. Code is not set as desired"); + } + 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; + } + + /** + * @brief Test FAPI return codes #4 + */ + 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); + + // Ensure that the equality comparison returns true + if (!(l_rc == l_rc2)) + { + TS_FAIL("testRc4. Equality comparison false"); + } + 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; + } + + /** + * @brief Test FAPI return codes #5 + */ + void testRc5() + { + uint32_t l_code = 6; + uint32_t l_code2 = 7; + + // 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 + { + // 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"); + } + } + } + } + + return; + } + + /** + * @brief Test FAPI return codes #6 + */ + 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); + + l_pData = l_rc.getData(); + if (l_pData != NULL) + { + TS_FAIL("testRc6. getData did not return NULL"); + } + 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; + } + + /** + * @brief Test FAPI return codes #7 + */ + void testRc7() + { + uint32_t l_code = 10; + + // 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); + + // 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 + { + // 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"); + } + } + + // Release the data to avoid ReturnCode from deleting in on destruction + l_pMyDataCheck = l_rc.releaseData(); + + return; + } + + /** + * @brief Test FAPI return codes #8 + */ + void testRc8() + { + uint32_t l_code = 10; + + // 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); + + // Ensure that releaseData retrieves the ReturnCodeData + void * l_pMyDataCheck = l_rc.releaseData(); + + if (l_pMyDataCheck != l_pMyData) + { + TS_FAIL("testRc8. getData returned unexpected data ptr"); + } + else + { + // 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"); + } + } + + return; + } + + /** + * @brief Test FAPI return codes #9 + */ + void testRc9() + { + uint32_t l_code = 10; + + // 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); + + // 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) + { + TS_FAIL("testRc9. ReturnCodes differ"); + } + else + { + // 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)"); + } + } + } + + // 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(); + + return; + } + + /** + * @brief Test FAPI return codes #10 + */ + void testRc10() + { + uint32_t l_code = 10; + + // 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); + + // 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) + { + TS_FAIL("testRc10. ReturnCodes differ"); + } + else + { + // 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"); + } + } + } + + return; + } + + + +}; + +#endif diff --git a/src/usr/hwpf/test/fapitargettest.H b/src/usr/hwpf/test/fapitargettest.H new file mode 100644 index 000000000..6cd8fd9b8 --- /dev/null +++ b/src/usr/hwpf/test/fapitargettest.H @@ -0,0 +1,266 @@ +#ifndef __FAPITARGETTEST_H +#define __FAPITARGETTEST_H + +/** + * @file fapitargettest.H + * + * @brief Test case for FAPI targets +*/ + +#include <cxxtest/TestSuite.H> +#include <fapi.H> + +using namespace fapi; + +class FapiTargetTest: public CxxTest::TestSuite +{ +public: + + /** + * @brief Test target #1 + */ + void testTarget1() + { + // 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) + { + TS_FAIL("testTarget1. Handle is not NULL"); + } + else + { + // 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"); + } + } + + return; + } + + /** + * @brief Test target #2 + */ + 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); + + // Ensure that the handle pointer is as expected + void * l_pHandleCheck = l_target.get(); + + if (l_pHandleCheck != l_pHandle) + { + TS_FAIL("testTarget2. Handle is not as expected"); + } + 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; + } + + /** + * @brief Test target #3 + */ + 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(); + + if (l_pHandleCheck != l_pHandle) + { + TS_FAIL("testTarget3. Handle is not as expected"); + } + 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; + } + + /** + * @brief Test target #4 + */ + 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); + + // 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("testTarget4. Types are not the same "); + } + 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; + } + + /** + * @brief Test target #5 + */ + 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); + + // 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 + { + // 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"); + } + } + + return; + } + + /** + * @brief Test target #6 + */ + 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); + + // Ensure that the equality comparison returns true + if (!(l_target == l_target2)) + { + TS_FAIL("testTarget6. 1. Equality comparison false"); + } + 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 new file mode 100644 index 000000000..fa9a1c555 --- /dev/null +++ b/src/usr/hwpf/test/hwpftest.H @@ -0,0 +1,94 @@ +#ifndef __HWPFTEST_H +#define __HWPFTEST_H + +/** + * @file hwpftest.H + * + * @brief Test case for HWPF implementation +*/ + +#include <cxxtest/TestSuite.H> +#include <fapi.H> +#include <fapiPlatHwpInvoker.H> +#include <errl/errlentry.H> +#include <errl/errlmanager.H> +#include <targeting/targetservice.H> + +using namespace fapi; +using namespace TARGETING; + +class HwpfTest: public CxxTest::TestSuite +{ +public: + + /** + * @brief Test HWPF trace + */ + void testHwpf1() + { + // Trace into all the FAPI trace buffers + uint32_t l_val = 4; + const char * l_pStr = "test-str"; + + FAPI_INF("Test INF Trace"); + FAPI_INF("Test INF Trace. hex: 0x%x", l_val); + FAPI_INF("Test INF Trace. string: %s", l_pStr); + FAPI_INF("Test INF Trace. 0x%x, %s", l_val, l_pStr); + + FAPI_IMP("Test IMP Trace"); + FAPI_IMP("Test IMP Trace. hex: 0x%x", l_val); + FAPI_IMP("Test IMP Trace. string: %s", l_pStr); + FAPI_IMP("Test IMP Trace. 0x%x, %s", l_val, l_pStr); + + FAPI_ERR("Test ERR Trace"); + FAPI_ERR("Test ERR Trace. hex: 0x%x", l_val); + FAPI_ERR("Test ERR Trace. string: %s", l_pStr); + FAPI_ERR("Test ERR Trace. 0x%x, %s", l_val, l_pStr); + + FAPI_DBG("Test DBG Trace"); + FAPI_DBG("Test DBG Trace. hex: 0x%x", l_val); + FAPI_DBG("Test DBG Trace. string: %s", l_pStr); + FAPI_DBG("Test DBG Trace. 0x%x, %s", l_val, l_pStr); + + return; + } + + + /** + * @brief Test HWPF: calling a procedure + */ + void testHwpf2() + { + // 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 hardware procedure + bool l_clocksOn = false; + l_err = invokeHwpIsP7EM0ChipletClockOn(l_testTarget, l_clocksOn); + if (l_err) + { + TS_FAIL("testHwpf2: Unit Test failed. HWP 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"); + } + } + + return; + } + +}; + +#endif diff --git a/src/usr/hwpf/test/makefile b/src/usr/hwpf/test/makefile new file mode 100644 index 000000000..c32529276 --- /dev/null +++ b/src/usr/hwpf/test/makefile @@ -0,0 +1,11 @@ +ROOTPATH = ../../../.. + +EXTRAINCDIR += ${ROOTPATH}/src/include/usr/ecmddatabuffer +EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/fapi +EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/plat + +MODULE = testhwpf +TESTS = *.H + +include ${ROOTPATH}/config.mk + |