/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* $Source: src/usr/hwas/test/hwas1test.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 __TESTTARGETING_H #define __TESTTARGETING_H /** * @file testtargeting.H * * @brief Unit tests for HWAS */ //****************************************************************************** // Includes //****************************************************************************** // STD #include #include // CXXTEST #include #include #include #include #include #include #include #include #include class HWAS1test: public CxxTest::TestSuite { public: /** * @brief Write to all the attributes and then read them back. */ void testHWASReadWrite() { using namespace TARGETING; TARGETING::HwasState l_orgHwasState, l_hwasState; TARGETING::TargetIterator l_pTarget; TS_TRACE( "testHWASReadWrite entry" ); // write a pattern to all HWAS attributes and then read them back for( l_pTarget = TARGETING::targetService().begin(); l_pTarget != TARGETING::targetService().end(); ++l_pTarget ) { // save original state l_orgHwasState = l_pTarget->getAttr(); // modify state l_hwasState = l_pTarget->getAttr(); l_hwasState.deconfiguredByEid = 0x12345678; l_hwasState.poweredOn = true; l_hwasState.present = true; l_hwasState.functional = true; // Now write the modified value back to Targeting. l_pTarget->setAttr( l_hwasState ); // fetch and test new values if ( l_pTarget->getAttr().deconfiguredByEid != 0x12345678 ) { TS_FAIL( " deconfiguredByEid = 0x%x, should be 0x12345678", l_pTarget->getAttr(). deconfiguredByEid ); } if ( l_pTarget->getAttr().poweredOn != true ) { TS_FAIL( "poweredOn = 0x%x, should be true", l_pTarget->getAttr().poweredOn ); } if ( l_pTarget->getAttr().present != true ) { TS_FAIL( " present = 0x%x should be true", l_pTarget->getAttr().present ); } if ( l_pTarget->getAttr().functional != true ) { TS_FAIL( " functional = 0x%x, should be true", l_pTarget->getAttr().functional ); } // // Now write the original value back. // l_pTarget->setAttr( l_orgHwasState ); // check that it got written back correctly if ( l_pTarget->getAttr().poweredOn != l_orgHwasState.poweredOn ) { TS_FAIL( "poweredOn = 0x%x, not restored", l_pTarget->getAttr().poweredOn ); } if ( l_pTarget->getAttr().present != l_orgHwasState.present ) { TS_FAIL( " present = 0x%x, not restored", l_pTarget->getAttr().present ); } if ( l_pTarget->getAttr().functional != l_orgHwasState.functional ) { TS_FAIL( " functional = 0x%x, not restored", l_pTarget->getAttr().functional ); } } TS_TRACE( "testHWASReadWrite exit" ); } /** * @brief test platReadIDEC */ void testHWASplatReadIDEC() { using namespace TARGETING; TS_TRACE( "testHWASplatReadIDEC entry" ); // call platReadIDEC with target that doesn't have an ID/EC errlHndl_t l_errl; Target* pSys; targetService().getTopLevelTarget(pSys); l_errl = HWAS::platReadIDEC(pSys); if (l_errl) { // error log is expected case, delete it delete l_errl; } else { TS_FAIL("testHWASplatReadIDEC>" "No error from platReadIDEC(pSys)."); } TS_TRACE( "testHWASplatReadIDEC exit" ); } /** * @brief test platReadPartialGood */ void testHWASplatReadPartialGood() { using namespace TARGETING; TS_TRACE( "testHWASplatReadPartialGood entry" ); // call platReadPartialGood with target that isn't in the VPD errlHndl_t l_errl; Target* pSys; targetService().getTopLevelTarget(pSys); uint8_t pgData[64]; l_errl = HWAS::platReadPartialGood(pSys, pgData); if (l_errl) { // error log is expected case, delete it delete l_errl; } else { TS_FAIL("testHWASplatReadPartialGood>" "No error from platReadPartialGood(pSys)."); } TS_TRACE( "testHWASplatReadPartialGood exit" ); } }; #endif //