From 882f15ebfdcd4edf4a053b1d4171133daee04e95 Mon Sep 17 00:00:00 2001 From: Matthew Raybuck Date: Thu, 11 Apr 2019 08:51:46 -0500 Subject: Test Cases for deconfig updates for AXONE Unit test cases for the MC->OMIC->OMI deconfig by association path. These test cases verify that deconfiguring an MC, OMIC, or an OMI will properly deconfig the other targets in the hierarchy. Change-Id: Ief665e76893a87324dc42fa66f8abd29190da30e RTC:196804 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/70512 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: FSP CI Jenkins Tested-by: Jenkins OP HW Reviewed-by: Glenn Miles Reviewed-by: Matt Derksen Reviewed-by: Daniel M. Crowell --- src/usr/hwas/test/hwasGardTest.H | 527 +++++++++++++++++++++ .../targeting/common/xmltohb/attribute_types.xml | 15 + src/usr/targeting/common/xmltohb/target_types.xml | 3 + 3 files changed, 545 insertions(+) diff --git a/src/usr/hwas/test/hwasGardTest.H b/src/usr/hwas/test/hwasGardTest.H index b9eba88fb..01c8d1735 100644 --- a/src/usr/hwas/test/hwasGardTest.H +++ b/src/usr/hwas/test/hwasGardTest.H @@ -51,6 +51,22 @@ #define DISABLE_EX_UNIT_TESTS 1 //$$#define DISABLE_UNIT_TESTS 0 +#define DISABLE_OMI_UNIT_TESTS 0 + +#if DISABLE_OMI_UNIT_TESTS +#define ENABLE_OMI_UNIT_TEST_1 0 +#define ENABLE_OMI_UNIT_TEST_2 0 +#define ENABLE_OMI_UNIT_TEST_3 0 +#define ENABLE_OMI_UNIT_TEST_4 0 +#else +#define ENABLE_OMI_UNIT_TEST_1 1 +#define ENABLE_OMI_UNIT_TEST_2 1 +#define ENABLE_OMI_UNIT_TEST_3 1 +#define ENABLE_OMI_UNIT_TEST_4 1 +#endif + +#define TEST_SAVE_RESTORE_SYSTEM_STATE 0 + using namespace HWAS; using namespace TARGETING; @@ -87,6 +103,114 @@ public: HWAS_INF("testParentDeconfigRules: Ended"); } + /* + * @brief Checks if the OMI tests should be run for the current model + */ + bool applicableModel() + { + bool result = false; + TargetHandle_t masterProc = nullptr; + targetService().masterProcChipTargetHandle(masterProc); + + HWAS_ASSERT(masterProc, "applicableModel: Couldn't get master proc"); + + auto model = masterProc->getAttr(); + + if (model == MODEL_AXONE) + { + result = true; + } + + return result; + + } + + void saveSystemState() + { + TargetHandle_t pSys; + targetService().getTopLevelTarget(pSys); + + TargetHandleList pChildList; + + getChildAffinityTargets(pChildList, pSys, CLASS_NA ,TYPE_NA, false); + + for (auto& child : pChildList) + { + // Get the original state of the child. + HwasState l_originalState = child->getAttr(); + + // Store it in a scratch attribute for later. + child->setAttr(l_originalState.functional); + } + } + + void restoreSystemState() + { + TargetHandle_t pSys; + targetService().getTopLevelTarget(pSys); + + TargetHandleList pChildList; + + getChildAffinityTargets(pChildList, pSys, CLASS_NA ,TYPE_NA, false); + + for (auto& child : pChildList) + { + // Get original HwasState from scratch attribute. + uint8_t l_savedState = child->getAttr(); + + // Get current HwasState. + HwasState l_state = child->getAttr(); + + l_state.functional = l_savedState; + + child->setAttr(l_state); + } + } + + void testSaveRestoreState() + { +#if TEST_SAVE_RESTORE_SYSTEM_STATE + // find an ex unit that we can play with + Target * pSys; + targetService().getTopLevelTarget(pSys); + + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); + PredicateHwas predFunctional; + predFunctional.poweredOn(true).present(true).functional(true); + PredicatePostfixExpr checkExpr; + checkExpr.push(&predEx).push(&predFunctional).And(); + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, + TargetService::CHILD, TargetService::ALL, &checkExpr ); + + if (pExList.empty()) + { + TS_FAIL("testSaveRestoreState: empty pExList"); + } + TargetHandle_t l_pTarget = *pExList.begin(); + saveSystemState(); + + // Get current HwasState. + HwasState l_state = l_pTarget->getAttr(); + HwasState l_originalState = l_state; + + // Change it to something else + l_state.functional = !l_state.functional; + + l_pTarget->setAttr(l_state); + + restoreSystemState(); + + HwasState l_restoState = l_pTarget->getAttr(); + + if (l_restoState.functional != l_originalState.functional) + { + TS_FAIL("Original state not restored. original = %d, current = %d", + l_originalState.functional, l_restoState.functional); + } +#endif + } + /** * @brief Test creating and getting a Deconfigure Record for a * EX Target @@ -5802,11 +5926,414 @@ public: } } + /** + * @brief Find an MC target and deconfigure OMIC targets. This should + * deconfig the MC parent. + */ + void testDeconfigureAssocOMI1() + { +#if ENABLE_OMI_UNIT_TEST_1 + // Save the state of the system before we make any changes. + saveSystemState(); + + TS_INFO(INFO_MRK "testDeconfigureAssocOMI1: Started"); + + errlHndl_t l_pErr = NULL; + + do + { + // This test is only relevant to Axone. + if (!applicableModel()) + { + TS_INFO(INFO_MRK"testDeconfigureAssocOMI1: Skipped due to N/A" + " model"); + break; + } + + // find an MC + Target * pSys; + targetService().getTopLevelTarget(pSys); + + PredicateCTM predMC(CLASS_UNIT, TYPE_MC); + PredicateHwas predFunctional; + predFunctional.poweredOn(true).present(true).functional(true); + PredicatePostfixExpr checkExprMC; + checkExprMC.push(&predMC).push(&predFunctional).And(); + + TargetHandleList pMcList; + targetService().getAssociated(pMcList, pSys, + TargetService::CHILD, TargetService::ALL, + &checkExprMC); + + if (pMcList.empty()) + { + TS_FAIL("testDeconfigureAssocOMI1: empty MC list"); + break; + } + TargetHandle_t l_pMc = pMcList[0]; + + // find all OMIC targets + TargetHandleList l_pOmicList; + getChildChiplets(l_pOmicList, l_pMc, TYPE_OMIC); + + if (l_pOmicList.empty()) + { + TS_FAIL("testDeconfigureAssocOMI1: empty OMIC list"); + break; + } + + // deconfigure all but one OMIC + for (auto i = (l_pOmicList.size() - 1); i > 0; --i) + { + TargetHandle_t l_pOmic = l_pOmicList[i]; + + // Deconfigure the OMIC. + l_pErr = theDeconfigGard(). + deconfigureTarget(*l_pOmic, 0xA5); + if (l_pErr) + { + TS_FAIL("testDeconfigureAssocOMI1: Error from " + "deconfigureTarget"); + break; + } + } + + // Check the HWAS_STATE of the MC + HwasState l_state = l_pMc->getAttr(); + if (!l_state.functional) + { + TS_FAIL("testDeconfigureAssocOMI1: MC not functional after " + "deconfiguring all but one OMIC"); + break; + } + + // deconfigure last functional OMIC + TargetHandle_t l_pLastOmic = l_pOmicList[0]; + l_pErr = theDeconfigGard().deconfigureTarget(*l_pLastOmic, 0xA6); + if (l_pErr) + { + TS_FAIL("testDeconfigureAssocOMI1: Error from " + "deconfigureTarget"); + break; + } + + // Check the HWAS_STATE of the MC + l_state = l_pMc->getAttr(); + if (l_state.functional) + { + TS_FAIL("testDeconfigureAssocOMI1: MC functional after " + "deconfiguring all OMICS"); + break; + } + + TS_INFO(INFO_MRK "testDeconfigureAssocOMI1: Success"); + } + while (0); + + if (l_pErr) + { + errlCommit(l_pErr, HWAS_COMP_ID); + } + + // Restore the state of the system prior to the test + restoreSystemState(); + +#endif + } + + + /** + * @brief Find an MC target and deconfigure it. This should deconfig the + * child OMIC targets. + */ + void testDeconfigureAssocOMI2() + { +#if ENABLE_OMI_UNIT_TEST_2 + // Save the state of the system before we make any changes. + saveSystemState(); + + TS_INFO(INFO_MRK "testDeconfigureAssocOMI2: Started"); + + errlHndl_t l_pErr = NULL; + + do + { + // This test is only relevant to Axone. + if (!applicableModel()) + { + TS_INFO(INFO_MRK"testDeconfigureAssocOMI2: Skipped due to N/A" + " model"); + break; + } + + // find an MC + Target * pSys; + targetService().getTopLevelTarget(pSys); + + TargetHandleList pMcList; + + getChildAffinityTargets(pMcList, pSys, CLASS_NA ,TYPE_MC, true); + + if (pMcList.empty()) + { + TS_FAIL("testDeconfigureAssocOMI2: empty MC list"); + break; + } + TargetHandle_t l_pMc = pMcList[0]; + + // find all functional OMIC targets + TargetHandleList l_pOmicList; + getChildChiplets(l_pOmicList, l_pMc, TYPE_OMIC, true); + + if (l_pOmicList.empty()) + { + TS_FAIL("testDeconfigureAssocOMI2: empty OMIC list"); + break; + } + + // Deconfigure the MC target + l_pErr = theDeconfigGard().deconfigureTarget(*l_pMc, 0xA5); + + bool functionalOmic = false; + // Check to see if the OMIC targets were deconfigured. + for (auto l_pOmic : l_pOmicList) + { + HwasState l_state = l_pOmic->getAttr(); + + if (l_state.functional) + { + TS_FAIL("testDeconfigureAssocOMI1: OMIC functional after " + "deconfiguring parent MC"); + functionalOmic = true; + break; + } + } + if (functionalOmic) + { + break; + } + TS_INFO(INFO_MRK "testDeconfigureAssocOMI2: Success"); + } + while (0); + + if (l_pErr) + { + errlCommit(l_pErr, HWAS_COMP_ID); + } + + // Restore the state of the system prior to the test + restoreSystemState(); +#endif + } + + + /** + * @brief Find an OMIC target and deconfigure it. This should deconfig the + * child OMI targets. + */ + void testDeconfigureAssocOMI3() + { +#if ENABLE_OMI_UNIT_TEST_3 + // Save the state of the system before we make any changes. + saveSystemState(); + + TS_INFO(INFO_MRK "testDeconfigureAssocOMI3: Started"); + + errlHndl_t l_pErr = NULL; + + do + { + // This test is only relevant to Axone. + if (!applicableModel()) + { + TS_INFO(INFO_MRK"testDeconfigureAssocOMI3: Skipped due to N/A" + " model"); + break; + } + + Target * pSys; + targetService().getTopLevelTarget(pSys); + + // find an OMIC + TargetHandleList l_pOmicList; + getChildChiplets(l_pOmicList, pSys, TYPE_OMIC, true); + + if (l_pOmicList.empty()) + { + TS_FAIL("testDeconfigureAssocOMI3: empty OMIC list"); + break; + } + + TargetHandle_t l_pOmic = l_pOmicList[0]; + + // find all OMI targets + TargetHandleList l_pOmiList; + + getChildOmiTargetsByState(l_pOmiList, l_pOmic, CLASS_NA, + TYPE_OMI, UTIL_FILTER_FUNCTIONAL); + + if (l_pOmiList.empty()) + { + TS_FAIL("testDeconfigureAssocOMI3: empty OMI list"); + break; + } + + // Deconfigure the OMIC target + l_pErr = theDeconfigGard().deconfigureTarget(*l_pOmic, 0xA5); + + bool foundFunctionalOMI = false; + // Check to see if the OMI targets were deconfigured. + for (auto l_pOmi : l_pOmiList) + { + HwasState l_state = l_pOmi->getAttr(); + + if (l_state.functional) + { + TS_FAIL("testDeconfigureAssocOMI3: OMI functional after " + "deconfiguring parent OMIC"); + foundFunctionalOMI = true; + break; + } + } + + if (!foundFunctionalOMI) + { + TS_INFO(INFO_MRK "testDeconfigureAssocOMI3: Success"); + } + } + while (0); + + if (l_pErr) + { + errlCommit(l_pErr, HWAS_COMP_ID); + } + + // Restore the state of the system prior to the test + restoreSystemState(); +#endif + } + + + /** + * @brief Find an OMIC target and deconfigure OMI targets. This should + * deconfig the OMIC parent. + */ + void testDeconfigureAssocOMI4() + { +#if ENABLE_OMI_UNIT_TEST_4 + // Save the state of the system before we make any changes. + saveSystemState(); + + TS_INFO(INFO_MRK "testDeconfigureAssocOMI4: Started"); + + errlHndl_t l_pErr = NULL; + + do + { + // This test is only relevant to Axone. + if (!applicableModel()) + { + TS_INFO(INFO_MRK"testDeconfigureAssocOMI4: Skipped due to N/A" + " model"); + break; + } + + Target * pSys; + targetService().getTopLevelTarget(pSys); + + // find an OMIC + TargetHandleList l_pOmicList; + getChildChiplets(l_pOmicList, pSys, TYPE_OMIC, true); + + if (l_pOmicList.empty()) + { + TS_FAIL("testDeconfigureAssocOMI4: empty OMIC list"); + break; + } + + TargetHandle_t l_pOmic = l_pOmicList[0]; + + // find all OMI targets + TargetHandleList l_pOmiList; + getChildOmiTargetsByState(l_pOmiList, l_pOmic, CLASS_NA, + TYPE_OMI, UTIL_FILTER_FUNCTIONAL); + + if (l_pOmiList.empty()) + { + TS_FAIL("testDeconfigureAssocOMI4: empty OMI list"); + break; + } + + // deconfigure all but one OMI + for (auto i = (l_pOmiList.size() - 1); i > 0; --i) + { + TargetHandle_t l_pOmi = l_pOmiList[i]; + + // Deconfigure the OMI. + l_pErr = theDeconfigGard(). + deconfigureTarget(*l_pOmi, 0xA5); + if (l_pErr) + { + TS_FAIL("testDeconfigureAssocOMI4: Error from " + "deconfigureTarget"); + break; + } + } + + // Check the HWAS_STATE of the OMIC + HwasState l_state = l_pOmic->getAttr(); + if (!l_state.functional) + { + TS_FAIL("testDeconfigureAssocOMI4: OMIC not functional after " + "deconfiguring all but one OMI"); + break; + } + + // deconfigure last functional OMI + TargetHandle_t l_pLastOmi = l_pOmiList[0]; + l_pErr = theDeconfigGard().deconfigureTarget(*l_pLastOmi, 0xA6); + if (l_pErr) + { + TS_FAIL("testDeconfigureAssocOMI4: Error from " + "deconfigureTarget"); + break; + } + // Check the HWAS_STATE of the OMIC + l_state = l_pOmic->getAttr(); + if (l_state.functional) + { + TS_FAIL("testDeconfigureAssocOMI4: OMIC functional after " + "deconfiguring all OMIs"); + break; + } + + TS_INFO(INFO_MRK "testDeconfigureAssocOMI4: Success"); + } + while (0); + + if (l_pErr) + { + errlCommit(l_pErr, HWAS_COMP_ID); + } + + // Restore the state of the system prior to the test + restoreSystemState(); + +#endif + } + + }; #undef DISABLE_UNIT_TESTS #undef DISABLE_MBA_UNIT_TESTS #undef DISABLE_MEM_UNIT_TESTS #undef DISABLE_EX_UNIT_TESTS +#undef DISABLE_OMI_UNIT_TESTS + +#undef ENABLE_OMI_UNIT_TEST_1 +#undef ENABLE_OMI_UNIT_TEST_2 +#undef ENABLE_OMI_UNIT_TEST_3 +#undef ENABLE_OMI_UNIT_TEST_4 #endif diff --git a/src/usr/targeting/common/xmltohb/attribute_types.xml b/src/usr/targeting/common/xmltohb/attribute_types.xml index 38a634b91..33563a08a 100644 --- a/src/usr/targeting/common/xmltohb/attribute_types.xml +++ b/src/usr/targeting/common/xmltohb/attribute_types.xml @@ -6848,6 +6848,21 @@ + + + uint8_t attribute to be used for storing functional state of a target during + test cases. + + SAVED_STATE_UINT8 + volatile-zeroed + + + + + + + + SBE_COMMIT_ID diff --git a/src/usr/targeting/common/xmltohb/target_types.xml b/src/usr/targeting/common/xmltohb/target_types.xml index 704cbf48c..10ee3b301 100644 --- a/src/usr/targeting/common/xmltohb/target_types.xml +++ b/src/usr/targeting/common/xmltohb/target_types.xml @@ -79,6 +79,9 @@ 0 RESOURCE_IS_CRITICAL + + SAVED_STATE_UINT8 + TYPE -- cgit v1.2.1