diff options
author | Brian Horton <brianh@linux.ibm.com> | 2013-04-30 09:33:17 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-05-17 09:59:11 -0500 |
commit | 4f753ed80d5caf3646fcb2e9bead2938d9ca7ade (patch) | |
tree | 11e8a681533f3e6743e6890a8f8db687dc8c85bf /src/usr/targeting/common/test | |
parent | 4927c80d6604832db0d9b2a030ed44682fabb947 (diff) | |
download | talos-hostboot-4f753ed80d5caf3646fcb2e9bead2938d9ca7ade.tar.gz talos-hostboot-4f753ed80d5caf3646fcb2e9bead2938d9ca7ade.zip |
add support for ChangeSinceLastChecked bits
replace hwas changedSinceLastIpl bit to a bit for different services
(ie, GARD, mem diag, psi diag, etc) and a subscription mask; this will
be used by hcdb code - when a target changes, the mask will be copied
into the bits field, and then services will clear their bits when they
process the change.
also update and create new hwas predicate to handle new attributes, as
well as targeting utilities to set and clear the bits.
Change-Id: Ie4a29500d07d7722f77ae2e89459e79a8b1e535b
RTC: 63434
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/4343
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/targeting/common/test')
-rw-r--r-- | src/usr/targeting/common/test/testcommontargeting.H | 132 |
1 files changed, 120 insertions, 12 deletions
diff --git a/src/usr/targeting/common/test/testcommontargeting.H b/src/usr/targeting/common/test/testcommontargeting.H index d2420c21d..2bb649c12 100644 --- a/src/usr/targeting/common/test/testcommontargeting.H +++ b/src/usr/targeting/common/test/testcommontargeting.H @@ -567,8 +567,7 @@ class CommonTargetingTestSuite: public CxxTest::TestSuite for(size_t i=0; i<32; ++i) { ATTR_HWAS_STATE_type sweepHwasState - = { static_cast<uint8_t>(i&16), - static_cast<uint8_t>(i&8), + = { static_cast<uint8_t>(i&8), static_cast<uint8_t>(i&4), static_cast<uint8_t>(i&2), static_cast<uint8_t>(i&1) }; @@ -624,29 +623,28 @@ class CommonTargetingTestSuite: public CxxTest::TestSuite } // Test: Given a predicate looking for target whose HWAS state - // exactly matches all 5 configurable HWAS states, filter should + // exactly matches all configurable HWAS states, filter should // return true hwasPredicate.reset().poweredOn(true).present(true).functional(false); - hwasPredicate.changedSinceLastIpl(true).dumpFunctional(false); + hwasPredicate.dumpFunctional(false); - ATTR_HWAS_STATE_type allFiveHwasState = - { 0x0,true,true,false,true,false}; - l_pTopLevel->setAttr<ATTR_HWAS_STATE>(allFiveHwasState); + ATTR_HWAS_STATE_type allHwasState = {0, true,true,false,false}; + l_pTopLevel->setAttr<ATTR_HWAS_STATE>(allHwasState); if(!hwasPredicate(l_pTopLevel)) { - TARG_TS_FAIL("Expected 5 setting HWAS predicate to match the " + TARG_TS_FAIL("Expected setting HWAS predicate to match the " "target's similarly configured HWAS state"); } // Test: Given a predicate looking for target whose HWAS state - // exactly matches all 4 of 5 configurable HWAS states, filter + // exactly matches all but 1 configurable HWAS states, filter // should return false - allFiveHwasState.dumpfunctional = true; - l_pTopLevel->setAttr<ATTR_HWAS_STATE>(allFiveHwasState); + allHwasState.dumpfunctional = true; + l_pTopLevel->setAttr<ATTR_HWAS_STATE>(allHwasState); if(hwasPredicate(l_pTopLevel)) { TARG_TS_FAIL("Expected HWAS predicate not to match the target's " - "4/5 matching HWAS state configuration"); + "all-but-1 matching HWAS state configuration"); } // Restore state. @@ -657,6 +655,116 @@ class CommonTargetingTestSuite: public CxxTest::TestSuite TARG_TS_TRACE(EXIT_MRK "testPredicateHwas" ); } + void testPredicateHwasChanged() + { + TARG_TS_TRACE(ENTER_MRK "testPredicateHwasChanged" ); + + do { + + using namespace TARGETING; + TargetService& l_targetService = targetService(); + + // Get master proc chip to work with + Target* l_pTarget = NULL; + (void) l_targetService.masterProcChipTargetHandle(l_pTarget); + if (l_pTarget == NULL) + { + TARG_TS_FAIL("MasterProcChipTarget handle was NULL"); + break; + } + + PredicateHwasChanged hwasChangedPredicate; + + ATTR_HWAS_STATE_CHANGED_FLAG_type savedHwasChangedState = + l_pTarget->getAttr<ATTR_HWAS_STATE_CHANGED_FLAG>(); + + // Test: Given a target with any HWAS state, default HWAS predicate + // should return a match + for(size_t i=0; i<32; ++i) + { + ATTR_HWAS_STATE_CHANGED_FLAG_type sweepState + = { static_cast<uint8_t>(i&1) }; + l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG>(sweepState); + + if(!hwasChangedPredicate(l_pTarget)) + { + TARG_TS_FAIL("Expected default HWAS predicate to match the " + "target's HWAS state, using i = %d",i); + } + } + + // Test: Given a target with cleared HWAS GARD bit, predicate + // looking for GARD bit should return false + hwasChangedPredicate.reset().changedBit(HWAS_CHANGED_BIT_GARD, true); + ATTR_HWAS_STATE_CHANGED_FLAG_type noGardHwasChangedBit = 0; + l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG>(noGardHwasChangedBit); + if(hwasChangedPredicate(l_pTarget)) + { + TARG_TS_FAIL("Expected HWAS predicate not to match the " + "target's cleared HWAS GARD bit"); + } + + // Test: Having previously not matched a target, resetting the HWAS + // predicate should match the target again + hwasChangedPredicate.reset(); + if(!hwasChangedPredicate(l_pTarget)) + { + TARG_TS_FAIL("Expected HWAS reset predicate to match the " + "target's HWAS state"); + } + + // Test: Given a target with set HWAS GARD bit, predicate + // looking for GARD bit should return true + hwasChangedPredicate.reset().changedBit(HWAS_CHANGED_BIT_GARD, true); + //ATTR_HWAS_STATE_CHANGED_FLAG_type functionalHwasChangedState = + //HWAS_CHANGED_BIT_GARD; + l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG>(HWAS_CHANGED_BIT_GARD); + if(!hwasChangedPredicate(l_pTarget)) + { + TARG_TS_FAIL("Expected HWAS GARD bit predicate to match the " + "target's GARD bit HWAS state"); + } + + // Test: Given a target with cleared HWAS GARD bit, predicate + // looking for cleared GARD bit should return true + hwasChangedPredicate.reset().changedBit(HWAS_CHANGED_BIT_GARD, false); + l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG>(0); + if(!hwasChangedPredicate(l_pTarget)) + { + TARG_TS_FAIL("Expected HWAS cleared GARD bit predicate to match " + "the target's cleared GARD bit HWAS state"); + } + + // Test: Given a target with all cleared HWAS bits, predicate + // looking for all false should return true + hwasChangedPredicate.reset().allChangesApplied(false); + l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG>(0); + if(!hwasChangedPredicate(l_pTarget)) + { + TARG_TS_FAIL("Expected HWAS all cleared predicate to match the " + "target's all cleared HWAS state"); + } + + // Test: Given a target with all set HWAS bits, predicate + // looking for all set should return true + hwasChangedPredicate.reset().allChangesApplied(true); + l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG> + (l_pTarget->getAttr<ATTR_HWAS_STATE_CHANGED_SUBSCRIPTION_MASK>()); + if(!hwasChangedPredicate(l_pTarget)) + { + TARG_TS_FAIL("Expected HWAS all set predicate to match the " + "target's all set HWAS state"); + } + + // Restore state. + l_pTarget->setAttr<ATTR_HWAS_STATE_CHANGED_FLAG> + (savedHwasChangedState); + + } while(0); + + TARG_TS_TRACE(EXIT_MRK "testPredicateHwasChanged" ); + } + void testPredicateCtm() { TARG_TS_TRACE(ENTER_MRK "testPredicateCtm" ); |