/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* $Source: src/usr/hwas/test/hwasGardTest.H $ */ /* */ /* IBM CONFIDENTIAL */ /* */ /* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ /* Object Code Only (OCO) source materials */ /* Licensed Internal Code Source Materials */ /* IBM HostBoot Licensed Internal Code */ /* */ /* The source code for this program is not published or otherwise */ /* divested of its trade secrets, irrespective of what has been */ /* deposited with the U.S. Copyright Office. */ /* */ /* Origin: 30 */ /* */ /* IBM_PROLOG_END_TAG */ #ifndef _HWASGARDTEST_H #define _HWASGARDTEST_H /** * @file hwasGardTest.H * * @brief Unit tests for HWAS Deconfigure and GARD functionality */ //****************************************************************************** // Includes //****************************************************************************** // CXXTEST #include #include #include #include #include using namespace HWAS; using namespace TARGETING; class HwasGardTest: public CxxTest::TestSuite { public: /** * @brief Test creating and getting a Deconfigure Record for a * specific Target */ void testDeconfigure2() { TS_TRACE(INFO_MRK "testDeconfigure2: Started"); errlHndl_t l_pErr = NULL; DeconfigGard::DeconfigureRecords_t l_records; do { // confirm that there aren't any deconfigure records - if so exit l_pErr = theDeconfigGard(). _getDeconfigureRecords(NULL, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testDeconfigure2: Error from _getDeconfigureRecords"); break; } if (l_records.size() > 0) { TS_TRACE("testDeconfigure2: Existing records (%d); exiting", l_records.size()); break; } // find a core that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; checkExpr.push(&predCore).push(&predFunctional).And(); TargetHandleList pCoreList; targetService().getAssociated( pCoreList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); if (pCoreList.empty()) { TS_FAIL("testDeconfigure3a: empty pCoreList"); break; } TargetHandle_t l_pTarget = *pCoreList.begin(); // create a deconfigure record theDeconfigGard(). registerDeferredDeconfigure(*l_pTarget, 0x12); // Get that Deconfigure Record for the target l_pErr = theDeconfigGard(). _getDeconfigureRecords(l_pTarget, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testDeconfigure2: Error from _getDeconfigureRecords"); break; } if (l_records.size() > 1) { TS_FAIL("testDeconfigure2: %d records for target", l_records.size()); break; } TS_TRACE(INFO_MRK "testDeconfigure2: Success. %d record", l_records.size()); // now delete it. theDeconfigGard()._clearDeconfigureRecords(l_pTarget); // confirm that there aren't any deconfigure records - if so exit l_pErr = theDeconfigGard(). _getDeconfigureRecords(NULL, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testDeconfigure2: Error from _getDeconfigureRecords"); break; } if (l_records.size() > 0) { TS_TRACE("testDeconfigure2: Existing records (%d); exiting", l_records.size()); break; } } while (0); } /** * @brief Test Deconfiguring a Target directly */ void testDeconfigure3() { TS_TRACE(INFO_MRK "testDeconfigure3: Started"); #if 1 // these tests deconfigure and gard targets. and even tho they // restore their state after the tests, since the cxxtests are // all run in parallel, during the time that a target is non- // functional due to this test, another test may be running that // might be adversly affected. // tests are left in the code so that a developer can enable them // to test these specific functions - just keep in mind that there // could be side effects in other cxxtests. TS_TRACE( " - SKIPPING -- other tests could be adversly affected"); #else errlHndl_t l_pErr = NULL; do { // find a core that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; checkExpr.push(&predCore).push(&predFunctional).And(); TargetHandleList pCoreList; targetService().getAssociated( pCoreList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); if (pCoreList.empty()) { TS_FAIL("testDeconfigure3: empty pCoreList"); break; } TargetHandle_t l_pTarget = *pCoreList.begin(); // Get the original HWAS_STATE of the target HwasState l_origState = l_pTarget->getAttr(); // Deconfigure the target. l_pErr = theDeconfigGard(). deconfigureTarget(*l_pTarget, 0x12); if (l_pErr) { TS_FAIL("testDeconfigure3: Error from deconfigureTarget"); break; } // Get the new HWAS_STATE of the target HwasState l_state = l_pTarget->getAttr(); if (l_state.functional) { TS_FAIL("testDeconfigure3: target functional after deconfigure"); break; } // Reset the HWAS_STATE of the target l_pTarget->setAttr(l_origState); TS_TRACE(INFO_MRK "testDeconfigure3: Success"); } while (0); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); } #endif } /** * @brief Test Deconfiguring a Target multiple times directly */ void testDeconfigure4() { TS_TRACE(INFO_MRK "testDeconfigure4: Started"); #if 1 // these tests deconfigure and gard targets. and even tho they // restore their state after the tests, since the cxxtests are // all run in parallel, during the time that a target is non- // functional due to this test, another test may be running that // might be adversly affected. // tests are left in the code so that a developer can enable them // to test these specific functions - just keep in mind that there // could be side effects in other cxxtests. TS_TRACE( " - SKIPPING -- other tests could be adversly affected"); #else errlHndl_t l_pErr = NULL; do { // find a core that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; checkExpr.push(&predCore).push(&predFunctional).And(); TargetHandleList pCoreList; targetService().getAssociated( pCoreList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); if (pCoreList.empty()) { TS_FAIL("testDeconfigure4: empty pCoreList"); break; } TargetHandle_t l_pTarget = *pCoreList.begin(); // Get the current HWAS_STATE of the target HwasState l_origState = l_pTarget->getAttr(); // Deconfigure the target. l_pErr = theDeconfigGard(). deconfigureTarget(*l_pTarget, 0xA); if (l_pErr) { TS_FAIL("testDeconfigure4: Error from deconfigureTarget"); break; } // Deconfigure the target again l_pErr = theDeconfigGard(). deconfigureTarget(*l_pTarget, 0xB); if (l_pErr) { TS_FAIL("testDeconfigure4: Error from 2nd deconfigureTarget"); break; } // Get the new HWAS_STATE of the target HwasState l_state = l_pTarget->getAttr(); if (l_state.functional) { TS_FAIL("testDeconfigure4: target functional after deconfigure"); break; } // Reset the HWAS_STATE of the target l_pTarget->setAttr(l_origState); TS_TRACE(INFO_MRK "testDeconfigure4: Success"); } while (0); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); } #endif } /** * @brief Test Deconfiguring a Target via deferred */ void testDefDeconfig1() { TS_TRACE(INFO_MRK "testDefDeconfig1: Started"); #if 1 // these tests deconfigure and gard targets. and even tho they // restore their state after the tests, since the cxxtests are // all run in parallel, during the time that a target is non- // functional due to this test, another test may be running that // might be adversly affected. // tests are left in the code so that a developer can enable them // to test these specific functions - just keep in mind that there // could be side effects in other cxxtests. TS_TRACE( " - SKIPPING -- other tests could be adversly affected"); #else errlHndl_t l_pErr = NULL; DeconfigGard::DeconfigureRecords_t l_records; do { // find a core that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; checkExpr.push(&predCore).push(&predFunctional).And(); TargetHandleList pCoreList; targetService().getAssociated( pCoreList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); if (pCoreList.empty()) { TS_FAIL("testDefDeconfig1: empty pCoreList"); break; } TargetHandle_t l_pTarget = *pCoreList.begin(); // Get any existing Deconfigure Record for the target l_pErr = theDeconfigGard(). _getDeconfigureRecords(l_pTarget, l_records); if (l_pErr) { TS_FAIL("testDefDeconfig1: Error from _getDeconfigureRecords"); break; } if (l_records.size() != 0) { TS_TRACE(INFO_MRK "testDefDeconfig1: target has existing Deconfigure Record, skipping test"); break; } // Get the original HWAS_STATE of the target HwasState l_origState = l_pTarget->getAttr(); // create a deconfigure record theDeconfigGard(). registerDeferredDeconfigure(*l_pTarget, 0x12); // call function to process deferred deconfigure records bool l_processed = processDeferredDeconfig(); if (!l_processed) { TS_FAIL("testDefDeconfig1: processDeferredDeconfig found no work"); break; } // Get the new HWAS_STATE of the target HwasState l_state = l_pTarget->getAttr(); if (l_state.functional) { TS_FAIL("testDefDeconfig1: target functional after deconfigure"); // intentionally continue } // Try to get the Deconfigure Record for the target l_pErr = theDeconfigGard(). _getDeconfigureRecords(l_pTarget, l_records); if (l_pErr) { TS_FAIL("testDefDeconfig1: Error from _getDeconfigureRecords (2)"); break; } if (l_records.size() != 0) { TS_FAIL("testDefDeconfig1: %d records for target, expected 0", l_records.size()); break; } // Reset the HWAS_STATE of the target l_pTarget->setAttr(l_origState); TS_TRACE(INFO_MRK "testDefDeconfig1: Success"); } while (0); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); } #endif } /** * @brief Test getting all GARD Records */ void testGard1() { TS_TRACE(INFO_MRK "testGard1: Started"); errlHndl_t l_pErr = NULL; DeconfigGard::GardRecords_t l_records; l_pErr = theDeconfigGard().getGardRecords( DeconfigGard::GET_ALL_GARD_RECORDS, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testGard1: Error from getGardRecords"); } else { TS_TRACE(INFO_MRK "testGard1: Success. %d records", l_records.size()); } } /** * @brief Test getting GARD Records with a bad record ID). */ void testGard2() { TS_TRACE(INFO_MRK "testGard2: Started"); errlHndl_t l_pErr = NULL; DeconfigGard::GardRecords_t l_records; l_pErr = theDeconfigGard().getGardRecords(0x12345678, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testGard2: Error from getGardRecords"); } else { if (l_records.size()) { TS_FAIL("testGard2: %d records found for bad ID", l_records.size()); } else { TS_TRACE(INFO_MRK "testGard2: Success"); } } } /** * @brief Test getting GARD Records for a specific target */ void testGard3() { TS_TRACE(INFO_MRK "testGard3: Started"); errlHndl_t l_pErr = NULL; DeconfigGard::GardRecords_t l_records; do { // find a core that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; checkExpr.push(&predCore).push(&predFunctional).And(); TargetHandleList pCoreList; targetService().getAssociated( pCoreList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); if (pCoreList.empty()) { TS_FAIL("testGard3: empty pCoreList"); break; } TargetHandle_t l_pTarget = *pCoreList.begin(); EntityPath l_id = l_pTarget->getAttr(); // Get all GARD Records for the Target l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testGard3: Error from getGardRecords"); } else { TS_TRACE(INFO_MRK "testGard3: Success. %d records", l_records.size()); } } while (0); } /** * @brief Test creating a GARD Record, getting the GARD Record and * clearing the GARD Record */ void testGard4() { TS_TRACE(INFO_MRK "testGard4: Started"); #if 1 // these tests deconfigure and gard targets. and even tho they // restore their state after the tests, since the cxxtests are // all run in parallel, during the time that a target is non- // functional due to this test, another test may be running that // might be adversly affected. // tests are left in the code so that a developer can enable them // to test these specific functions - just keep in mind that there // could be side effects in other cxxtests. TS_TRACE( " - SKIPPING -- other tests could be adversly affected"); #else errlHndl_t l_pErr = NULL; DeconfigGard::GardRecords_t l_records; do { // find a core that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; checkExpr.push(&predCore).push(&predFunctional).And(); TargetHandleList pCoreList; targetService().getAssociated( pCoreList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); if (pCoreList.empty()) { TS_FAIL("testGard4: empty pCoreList"); break; } TargetHandle_t l_pTarget = *pCoreList.begin(); EntityPath l_id = l_pTarget->getAttr(); // Get any existing GARD Records for the target l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard4: Error from getGardRecords"); break; } if (l_records.size() != 0) { TS_TRACE(INFO_MRK "testGard4: target has %d existing Gard Records, skipping test", l_records.size()); break; } // Create a GARD Record for the target. l_pErr = theDeconfigGard(). createGardRecord(*l_pTarget, 0x12, GARD_Predictive); if (l_pErr) { TS_FAIL("testGard4: Error from createGardRecord"); break; } // Get the GARD Records for the target l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard4: Error from getGardRecords (2)"); break; } if (l_records.size() != 1) { TS_FAIL("testGard4: %d records for target, expected 1", l_records.size()); break; } if (l_records[0].iv_errorType != GARD_Predictive) { TS_FAIL("testGard4: Record errorType %d, expected predictive", l_records[0].iv_errorType); break; } // Clear the GARD Records for the target l_pErr = theDeconfigGard().clearGardRecords(l_id); if (l_pErr) { TS_FAIL("testGard4: Error from clearGardRecords"); break; } // Get the GARD Records for the target l_records.clear(); l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard4: Error from getGardRecords (3)"); break; } if (l_records.size() != 0) { TS_FAIL("testGard4: %d records for target, expected 0", l_records.size()); break; } TS_TRACE(INFO_MRK "testGard4: Success"); } while (0); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); } #endif } /** * @brief Test creating a GARD Record for a Target multiple times */ void testGard5() { TS_TRACE(INFO_MRK "testGard5: Started"); #if 1 // these tests deconfigure and gard targets. and even tho they // restore their state after the tests, since the cxxtests are // all run in parallel, during the time that a target is non- // functional due to this test, another test may be running that // might be adversly affected. // tests are left in the code so that a developer can enable them // to test these specific functions - just keep in mind that there // could be side effects in other cxxtests. TS_TRACE( " - SKIPPING -- other tests could be adversly affected"); #else errlHndl_t l_pErr = NULL; DeconfigGard::GardRecords_t l_records; do { // find a core that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; checkExpr.push(&predCore).push(&predFunctional).And(); TargetHandleList pCoreList; targetService().getAssociated( pCoreList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); if (pCoreList.empty()) { TS_FAIL("testGard5: empty pCoreList"); break; } TargetHandle_t l_pTarget = *pCoreList.begin(); EntityPath l_id = l_pTarget->getAttr(); // Get any existing GARD Records for the target l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard5: Error from getGardRecords"); break; } if (l_records.size() != 0) { TS_TRACE(INFO_MRK "testGard5: target has %d existing Gard Records, skipping test", l_records.size()); break; } // Create a GARD Record for the target. l_pErr = theDeconfigGard(). createGardRecord(*l_pTarget, 0x23, GARD_Predictive); if (l_pErr) { TS_FAIL("testGard5: Error from createGardRecord"); break; } // Create another GARD Record for the target l_pErr = theDeconfigGard(). createGardRecord(*l_pTarget, 0x45, GARD_Fatal); if (l_pErr) { TS_FAIL("testGard5: Error from createGardRecord (2)"); break; } // Get the GARD Records for the target l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard5: Error from getGardRecords (2)"); break; } if (l_records.size() != 2) { TS_FAIL("testGard5: %d records for target, expected 2", l_records.size()); break; } // Clear the GARD Records for the target l_pErr = theDeconfigGard().clearGardRecords(l_id); if (l_pErr) { TS_FAIL("testGard5: Error from clearGardRecords"); break; } // Get the GARD Records for the target l_records.clear(); l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard5: Error from getGardRecords (3)"); break; } if (l_records.size() != 0) { TS_FAIL("testGard5: %d records for target, expected 0", l_records.size()); break; } TS_TRACE(INFO_MRK "testGard5: Success"); } while (0); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); } #endif } /** * @brief Test getting and clearing GARD Records by recordID */ void testGard6() { TS_TRACE(INFO_MRK "testGard6: Started"); #if 1 // these tests deconfigure and gard targets. and even tho they // restore their state after the tests, since the cxxtests are // all run in parallel, during the time that a target is non- // functional due to this test, another test may be running that // might be adversly affected. // tests are left in the code so that a developer can enable them // to test these specific functions - just keep in mind that there // could be side effects in other cxxtests. TS_TRACE( " - SKIPPING -- other tests could be adversly affected"); #else errlHndl_t l_pErr = NULL; DeconfigGard::GardRecords_t l_records; do { // find a core that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; checkExpr.push(&predCore).push(&predFunctional).And(); TargetHandleList pCoreList; targetService().getAssociated( pCoreList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); if (pCoreList.empty()) { TS_FAIL("testGard6: empty pCoreList"); break; } TargetHandle_t l_pTarget = *pCoreList.begin(); EntityPath l_id = l_pTarget->getAttr(); // Get any existing GARD Records for the target l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard6: Error from getGardRecords"); break; } if (l_records.size() != 0) { TS_TRACE(INFO_MRK "testGard6: target has %d existing Gard Records, skipping test", l_records.size()); break; } // Create a GARD Record for the target. Production code will pass a // valid PLID l_pErr = theDeconfigGard(). createGardRecord(*l_pTarget, 0, GARD_Predictive); if (l_pErr) { TS_FAIL("testGard6: Error from createGardRecord"); break; } // Create another GARD Record for the target l_pErr = theDeconfigGard(). createGardRecord(*l_pTarget, 0, GARD_Fatal); if (l_pErr) { TS_FAIL("testGard6: Error from createGardRecord (2)"); break; } // Get the GARD Records for the target l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard6: Error from getGardRecords (2)"); break; } if (l_records.size() != 2) { TS_FAIL("testGard6: %d records for target, expected 2", l_records.size()); break; } // Get the first GARD Record for the target by Record ID uint32_t l_recordID = l_records[0].iv_recordId; l_records.clear(); l_pErr = theDeconfigGard(). getGardRecords(l_recordID, l_records); if (l_pErr) { TS_FAIL("testGard6: Error from getGardRecords (3)"); break; } if (l_records.size() != 1) { TS_FAIL("testGard6: %d records for target, expected 1", l_records.size()); break; } // Clear the first GARD Record for the target by Record ID l_pErr = theDeconfigGard().clearGardRecords(l_recordID); if (l_pErr) { TS_FAIL("testGard6: Error from clearGardRecords"); break; } // Get the GARD Records for the target l_records.clear(); l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard6: Error from getGardRecords (4)"); break; } if (l_records.size() != 1) { TS_FAIL("testGard6: %d records for target, expected 1 (2)", l_records.size()); break; } // Clear the GARD Records for the target l_pErr = theDeconfigGard().clearGardRecords(l_id); if (l_pErr) { TS_FAIL("testGard6: Error from clearGardRecords"); break; } TS_TRACE(INFO_MRK "testGard6: Success"); } while (0); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); } #endif } /** * @brief Test getting and clearing all GARD Records */ void testGard7() { TS_TRACE(INFO_MRK "testGard7: Started"); #if 1 // these tests deconfigure and gard targets. and even tho they // restore their state after the tests, since the cxxtests are // all run in parallel, during the time that a target is non- // functional due to this test, another test may be running that // might be adversly affected. // tests are left in the code so that a developer can enable them // to test these specific functions - just keep in mind that there // could be side effects in other cxxtests. TS_TRACE( " - SKIPPING -- other tests could be adversly affected"); #else errlHndl_t l_pErr = NULL; DeconfigGard::GardRecords_t l_records; do { // find a core that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; checkExpr.push(&predCore).push(&predFunctional).And(); TargetHandleList pCoreList; targetService().getAssociated( pCoreList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); if (pCoreList.empty()) { TS_FAIL("testGard7: empty pCoreList"); break; } TargetHandle_t l_pTarget = *pCoreList.begin(); // Get all existing GARD Records l_pErr = theDeconfigGard().getGardRecords( DeconfigGard::GET_ALL_GARD_RECORDS, l_records); if (l_pErr) { TS_FAIL("testGard7: Error from getGardRecords"); break; } if (l_records.size() != 0) { TS_TRACE(INFO_MRK "testGard7: %d existing Gard Records, skipping test", l_records.size()); break; } // Create a GARD Record for the target. Production code will pass a // valid PLID l_pErr = theDeconfigGard(). createGardRecord(*l_pTarget, 0, GARD_Predictive); if (l_pErr) { TS_FAIL("testGard7: Error from createGardRecord"); break; } // Create another GARD Record for the target l_pErr = theDeconfigGard(). createGardRecord(*l_pTarget, 0, GARD_Fatal); if (l_pErr) { TS_FAIL("testGard7: Error from createGardRecord (2)"); break; } // Clear all GARD Records l_pErr = theDeconfigGard(). clearGardRecords(DeconfigGard::CLEAR_ALL_GARD_RECORDS); if (l_pErr) { TS_FAIL("testGard7: Error from clearGardRecords"); break; } // Get the GARD Records l_records.clear(); l_pErr = theDeconfigGard().getGardRecords( DeconfigGard::GET_ALL_GARD_RECORDS, l_records); if (l_pErr) { TS_FAIL("testGard7: Error from getGardRecords (2)"); break; } if (l_records.size() != 0) { TS_FAIL("testGard7: %d records for target, expected 0", l_records.size()); break; } TS_TRACE(INFO_MRK "testGard7: Success"); } while (0); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); } #endif } /** * @brief Test create GARD record, call collect GARD to confirm targets * are deconfigured, set changed bit ala HCDB, reprocess GARD to * confirm GARD record is deleted. */ void testGard8() { TS_TRACE(INFO_MRK "testGard8: Started"); #if 1 // these tests deconfigure and gard targets. and even tho they // restore their state after the tests, since the cxxtests are // all run in parallel, during the time that a target is non- // functional due to this test, another test may be running that // might be adversly affected. // tests are left in the code so that a developer can enable them // to test these specific functions - just keep in mind that there // could be side effects in other cxxtests. TS_TRACE( " - SKIPPING -- other tests could be adversly affected"); #else errlHndl_t l_pErr = NULL; DeconfigGard::GardRecords_t l_records; do { l_pErr = theDeconfigGard().getGardRecords( DeconfigGard::GET_ALL_GARD_RECORDS, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testGard8: Error from getGardRecords"); break; } if (l_records.size() > 0) { TS_FAIL("testGard8: already GARD records here. %d records", l_records.size()); break; } // find a core that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; checkExpr.push(&predCore).push(&predFunctional).And(); TargetHandleList pCoreList; targetService().getAssociated( pCoreList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); if (pCoreList.empty()) { TS_FAIL("testGard8: empty pCoreList"); break; } TargetHandle_t l_target = *pCoreList.begin(); // create GARD record, call 'doGard' step and confirm target is // deconfigured l_pErr = theDeconfigGard(). createGardRecord( *l_target, 0x12, GARD_Fatal); if (l_pErr) { TS_FAIL("testGard8: Error from createGardRecord"); break; } l_pErr = theDeconfigGard().getGardRecords( DeconfigGard::GET_ALL_GARD_RECORDS, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testGard8: Error from getGardRecords"); break; } if (l_records.size() != 1) { TS_FAIL("testGard8: should be 1 record; instead %d records", l_records.size()); break; } l_pErr = collectGard(); if (l_pErr) { TS_FAIL("testGard8: Error from collectGard"); break; } HwasState l_state = l_target->getAttr(); if (l_state.functional) { TS_FAIL("testGard8: target still functional"); break; } // reset functional state l_state.functional = true; l_target->setAttr(l_state); // emulate HCDB - target changed, call collectGard and confirm // GARD record is gone and target is functional update_hwas_changed_mask(l_target); l_pErr = collectGard(); if (l_pErr) { TS_FAIL("testGard8: Error from collectGard2"); break; } l_pErr = theDeconfigGard().getGardRecords( DeconfigGard::GET_ALL_GARD_RECORDS, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testGard8: Error from getGardRecords"); break; } if (l_records.size() != 0) { TS_FAIL("testGard8: should be 0 records; instead %d records", l_records.size()); break; } l_state = l_target->getAttr(); if (!l_state.functional) { TS_FAIL("testGard8: target NOT functional"); break; } TS_TRACE(INFO_MRK "testGard8: Success"); } while (0); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); } #endif } /** * @brief Test CDM modes to restrict createing GARD records */ void testGard9() { TS_TRACE(INFO_MRK "testGard9: Started"); #if 1 // these tests deconfigure and gard targets. and even tho they // restore their state after the tests, since the cxxtests are // all run in parallel, during the time that a target is non- // functional due to this test, another test may be running that // might be adversly affected. // tests are left in the code so that a developer can enable them // to test these specific functions - just keep in mind that there // could be side effects in other cxxtests. TS_TRACE( " - SKIPPING -- other tests could be adversly affected"); #else errlHndl_t l_pErr = NULL; DeconfigGard::GardRecords_t l_records; do { // find a core that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; checkExpr.push(&predCore).push(&predFunctional).And(); TargetHandleList pCoreList; targetService().getAssociated( pCoreList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); if (pCoreList.empty()) { TS_FAIL("testGard9: empty pCoreList"); break; } TargetHandle_t l_pTarget = *pCoreList.begin(); EntityPath l_id = l_pTarget->getAttr(); // Get any existing GARD Records for the target l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard9: Error from getGardRecords"); break; } if (l_records.size() != 0) { TS_TRACE(INFO_MRK "testGard9: target has %d existing Gard Records, skipping test", l_records.size()); break; } // set Manufacturing policy to disabled, // test that gard record is not created ATTR_CDM_POLICIES_type l_policies = pSys->getAttr(); l_policies = CDM_POLICIES_MANUFACTURING_DISABLED; pSys->setAttr(l_policies); // (try to) Create a GARD Record for the target. l_pErr = theDeconfigGard(). createGardRecord(*l_pTarget, 0x12, GARD_Fatal); if (l_pErr) { TS_FAIL("testGard9: Error from createGardRecord"); break; } // Get the GARD Records for the target - shouldn't be any l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard9: Error from getGardRecords (2)"); break; } if (l_records.size() != 0) { TS_FAIL("testGard9: %d records for target, expected 0", l_records.size()); break; } // set Predictive policy to disabled // test that gard record isn't created l_policies = CDM_POLICIES_PREDICTIVE_DISABLED; pSys->setAttr(l_policies); // (try to) Create a GARD Record for the target. l_pErr = theDeconfigGard(). createGardRecord(*l_pTarget, 0x12, GARD_Predictive); if (l_pErr) { TS_FAIL("testGard9: Error from createGardRecord"); break; } // Get the GARD Records for the target - shouldn't be any l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard9: Error from getGardRecords (2)"); break; } if (l_records.size() != 0) { TS_FAIL("testGard9: %d records for target, expected 0", l_records.size()); break; } // set Functional policy to disabled // test that gard record isn't created l_policies = CDM_POLICIES_FUNCTIONAL_DISABLED; pSys->setAttr(l_policies); // (try to) Create a GARD Record for the target. l_pErr = theDeconfigGard(). createGardRecord(*l_pTarget, 0x12, GARD_Func); if (l_pErr) { TS_FAIL("testGard9: Error from createGardRecord"); break; } // Get the GARD Records for the target - shouldn't be any l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); if (l_pErr) { TS_FAIL("testGard9: Error from getGardRecords (2)"); break; } if (l_records.size() != 0) { TS_FAIL("testGard9: %d records for target, expected 0", l_records.size()); break; } // restore l_policies = 0; pSys->setAttr(l_policies); TS_TRACE(INFO_MRK "testGard9: Success"); } while (0); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); } #endif } /** * @brief Test CDM modes to restrict processing GARD records */ void testGard10() { TS_TRACE(INFO_MRK "testGard10: Started"); #if 1 // these tests deconfigure and gard targets. and even tho they // restore their state after the tests, since the cxxtests are // all run in parallel, during the time that a target is non- // functional due to this test, another test may be running that // might be adversly affected. // tests are left in the code so that a developer can enable them // to test these specific functions - just keep in mind that there // could be side effects in other cxxtests. TS_TRACE( " - SKIPPING -- other tests could be adversly affected"); #else errlHndl_t l_pErr = NULL; DeconfigGard::GardRecords_t l_records; do { l_pErr = theDeconfigGard().getGardRecords( DeconfigGard::GET_ALL_GARD_RECORDS, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testGard10: Error from getGardRecords"); break; } if (l_records.size() > 0) { TS_FAIL("testGard10: already GARD records here. %d records", l_records.size()); break; } // find a core that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; checkExpr.push(&predCore).push(&predFunctional).And(); TargetHandleList pCoreList; targetService().getAssociated( pCoreList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); if (pCoreList.empty()) { TS_FAIL("testGard10: empty pCoreList"); break; } TargetHandle_t l_target = *pCoreList.begin(); // create GARD record, set Policy, call 'doGard' step and confirm // target is NOT deconfigured l_pErr = theDeconfigGard(). createGardRecord( *l_target, 0x12, GARD_Predictive); if (l_pErr) { TS_FAIL("testGard10: Error from createGardRecord"); break; } l_pErr = theDeconfigGard().getGardRecords( DeconfigGard::GET_ALL_GARD_RECORDS, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testGard10: Error from getGardRecords"); break; } if (l_records.size() != 1) { TS_FAIL("testGard10: should be 1 record; instead %d records", l_records.size()); break; } // set Manufacturing policy to disabled, // test that gard record is not created ATTR_CDM_POLICIES_type l_policies = pSys->getAttr(); l_policies = CDM_POLICIES_MANUFACTURING_DISABLED; pSys->setAttr(l_policies); l_pErr = collectGard(); if (l_pErr) { TS_FAIL("testGard10: Error from collectGard"); break; } HwasState l_state = l_target->getAttr(); if (!l_state.functional) { TS_FAIL("testGard10: target NOT functional"); break; } // set Predictive policy to disabled, // test that gard record is not created l_policies = CDM_POLICIES_PREDICTIVE_DISABLED; pSys->setAttr(l_policies); l_pErr = collectGard(); if (l_pErr) { TS_FAIL("testGard10: Error from collectGard"); break; } l_state = l_target->getAttr(); if (!l_state.functional) { TS_FAIL("testGard10: target NOT functional"); break; } // Clear all GARD Records l_pErr = theDeconfigGard(). clearGardRecords(DeconfigGard::CLEAR_ALL_GARD_RECORDS); l_pErr = theDeconfigGard().getGardRecords( DeconfigGard::GET_ALL_GARD_RECORDS, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testGard10: Error from getGardRecords"); break; } if (l_records.size() != 0) { TS_FAIL("testGard10: should be 0 records; instead %d records", l_records.size()); break; } // create GARD record, set Policy, call 'doGard' step and confirm // target is NOT deconfigured l_pErr = theDeconfigGard(). createGardRecord( *l_target, 0x12, GARD_Func); if (l_pErr) { TS_FAIL("testGard10: Error from createGardRecord"); break; } l_pErr = theDeconfigGard().getGardRecords( DeconfigGard::GET_ALL_GARD_RECORDS, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); TS_FAIL("testGard10: Error from getGardRecords"); break; } if (l_records.size() != 1) { TS_FAIL("testGard10: should be 1 records; instead %d records", l_records.size()); break; } // set Functional policy to disabled, // test that gard record is not created l_policies = CDM_POLICIES_FUNCTIONAL_DISABLED; pSys->setAttr(l_policies); l_pErr = collectGard(); if (l_pErr) { TS_FAIL("testGard10: Error from collectGard"); break; } l_state = l_target->getAttr(); if (!l_state.functional) { TS_FAIL("testGard10: target NOT functional"); break; } // Clear all GARD Records l_pErr = theDeconfigGard(). clearGardRecords(DeconfigGard::CLEAR_ALL_GARD_RECORDS); // restore l_policies = 0; pSys->setAttr(l_policies); TS_TRACE(INFO_MRK "testGard10: Success"); } while (0); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); } #endif } }; #endif