From e8fdc1c11a1ee3c9406b75ebb45b619371e60182 Mon Sep 17 00:00:00 2001 From: crgeddes Date: Tue, 16 Feb 2016 15:14:03 -0600 Subject: Add getOtherEnd to fapi2::Target RTC:129517 Change-Id: I7270b194b609daf8e547313cf73a640e4adc48aa Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/21873 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell Reviewed-by: Thi N. Tran Reviewed-by: Richard J. Knight Reviewed-by: William G. Hoffa --- src/usr/fapi2/test/fapi2GetOtherEnd.C | 215 ++++++++++++++++++++++++++++++++++ src/usr/fapi2/test/fapi2Test.H | 18 +-- 2 files changed, 225 insertions(+), 8 deletions(-) create mode 100644 src/usr/fapi2/test/fapi2GetOtherEnd.C (limited to 'src/usr/fapi2') diff --git a/src/usr/fapi2/test/fapi2GetOtherEnd.C b/src/usr/fapi2/test/fapi2GetOtherEnd.C new file mode 100644 index 000000000..193e13b31 --- /dev/null +++ b/src/usr/fapi2/test/fapi2GetOtherEnd.C @@ -0,0 +1,215 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/fapi2/test/fapi2GetOtherEnd.C $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace fapi2 +{ + + +//****************************************************************************** +// fapi2GetOtherEnd +//****************************************************************************** +errlHndl_t fapi2GetOtherEnd() +{ + int numTests = 0; + int numFails = 0; + errlHndl_t l_errl = NULL; + + do + { + // Create a vector of TARGETING::Target pointers + TARGETING::TargetHandleList chipListNonFunct; + + // Get a list of all of the xbus chips present + TARGETING::getAllChiplets(chipListNonFunct, + TARGETING::TYPE_XBUS, false); + TARGETING::Target * l_peerTarget; + fapi2::Target fapi2_xbusTargetPeer; + for(uint32_t i = 0; i < chipListNonFunct.size(); i++) + { + chipListNonFunct[i]-> + tryGetAttr(l_peerTarget); + const fapi2::Target + fapi2_xbusTargetPeerPlatform(l_peerTarget); + const fapi2::Target + fapi2_xbusTarget(chipListNonFunct[i]); + if(l_peerTarget != NULL) + { + numTests++; + if(fapi2_xbusTarget.getOtherEnd(fapi2_xbusTargetPeer,TARGET_STATE_PRESENT) == FAPI2_RC_SUCCESS) + { + if(fapi2_xbusTargetPeerPlatform != fapi2_xbusTargetPeer) + { + TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned the incorrect target! expected %x, instead got %x ", TARGETING::get_huid(l_peerTarget), TARGETING::get_huid(static_cast(fapi2_xbusTargetPeer))); + numFails++; + break; + } + } + else + { + TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned failed to return a target although it should have returned %x", TARGETING::get_huid(l_peerTarget)); + numFails++; + break; + } + } + else + { + FAPI_ERR("fapiGetOtherEnd:: WARNING ! Target with HUID: %x has an unreachable peer target", chipListNonFunct[i]); + } + } + + + for(uint32_t i = 0; i < chipListNonFunct.size(); i++) + { + chipListNonFunct[i]-> + tryGetAttr(l_peerTarget); + const fapi2::Target + fapi2_xbusTargetPeerPlatform(l_peerTarget); + const fapi2::Target + fapi2_xbusTarget(chipListNonFunct[i]); + if(l_peerTarget != NULL) + { + numTests++; + fapi2_xbusTargetPeer = fapi2_xbusTarget.getOtherEnd(TARGET_STATE_PRESENT); + if(fapi2_xbusTargetPeer) + { + if(fapi2_xbusTargetPeerPlatform != fapi2_xbusTargetPeer) + { + TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned the incorrect target! expected %x, instead got %x ", TARGETING::get_huid(l_peerTarget), TARGETING::get_huid(static_cast(fapi2_xbusTargetPeer))); + numFails++; + break; + } + } + else + { + TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned failed to return a target although it should have returned %x", TARGETING::get_huid(l_peerTarget)); + numFails++; + break; + } + } + else + { + FAPI_ERR("fapiGetOtherEnd:: WARNING ! Target with HUID: %x has an unreachable peer target", chipListNonFunct[i]); + } + } + + // Create a vector of TARGETING::Target pointers + TARGETING::TargetHandleList chipListFunct; + + // Get a list of all of the xbus chips that are functional + TARGETING::getAllChiplets(chipListFunct, TARGETING::TYPE_XBUS, true); + + //NOTE: This Part of the test will fail if a certain target A's + // PEER_TARGET attr doesn't point to target B that + // has a PEER_TARGET that points back to target A + // So basically: + // A.PEER_TARGET MUST EQUAL B + // B.PEER_TARGET MUST EQUAL A + + FAPI_ERR("list of functional targets is size %d " , chipListFunct.size()); + for(uint32_t i = 0; i < chipListFunct.size(); i++) + { + chipListFunct[i]->tryGetAttr(l_peerTarget); + const fapi2::Target + fapi2_xbusTargetPeerPlatform(l_peerTarget); + const fapi2::Target + fapi2_xbusTarget(chipListFunct[i]); + + if(l_peerTarget != NULL) + { + numTests++; + if(fapi2_xbusTarget.getOtherEnd(fapi2_xbusTargetPeer,TARGET_STATE_FUNCTIONAL) == FAPI2_RC_SUCCESS) + { + if(fapi2_xbusTargetPeerPlatform != fapi2_xbusTargetPeer) + { + TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned the incorrect target! expected %x, instead got %x ", TARGETING::get_huid(l_peerTarget), TARGETING::get_huid(static_cast(fapi2_xbusTargetPeer))); + numFails++; + break; + } + } + else + { + TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned failed to return a target although it should have returned %x", TARGETING::get_huid(l_peerTarget)); + numFails++; + break; + } + } + else + { + FAPI_ERR("fapiGetOtherEnd:: WARNING ! Target with HUID: %x has an unreachable peer target", TARGETING::get_huid(chipListFunct[i])); + } + } + + for(uint32_t i = 0; i < chipListFunct.size(); i++) + { + chipListFunct[i]->tryGetAttr(l_peerTarget); + const fapi2::Target + fapi2_xbusTargetPeerPlatform(l_peerTarget); + const fapi2::Target + fapi2_xbusTarget(chipListFunct[i]); + + if(l_peerTarget != NULL) + { + numTests++; + fapi2_xbusTargetPeer = fapi2_xbusTarget.getOtherEnd(TARGET_STATE_FUNCTIONAL); + if(fapi2_xbusTargetPeer) + { + if(fapi2_xbusTargetPeerPlatform != fapi2_xbusTargetPeer) + { + TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned the incorrect target! expected %x, instead got %x ", TARGETING::get_huid(l_peerTarget), TARGETING::get_huid(static_cast(fapi2_xbusTargetPeer))); + numFails++; + break; + } + } + else + { + TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned failed to return a target although it should have returned %x", TARGETING::get_huid(l_peerTarget)); + numFails++; + break; + } + } + else + { + FAPI_ERR("fapiGetOtherEnd:: WARNING ! Target with HUID: %x has an unreachable peer target", TARGETING::get_huid(chipListFunct[i])); + } + } + + FAPI_INF("fapi2TargetTest:: Test Complete. %d/%d fails", numFails, numTests); + + }while(0); + + return l_errl; +} + +} \ No newline at end of file diff --git a/src/usr/fapi2/test/fapi2Test.H b/src/usr/fapi2/test/fapi2Test.H index 366921dbb..00a9bac46 100644 --- a/src/usr/fapi2/test/fapi2Test.H +++ b/src/usr/fapi2/test/fapi2Test.H @@ -47,6 +47,7 @@ #include "fapi2GetParentTest.C" #include "fapi2HwpTest.C" #include "fapi2GetChildrenTest.C" +#include "fapi2GetOtherEnd.C" using namespace fapi2; @@ -63,21 +64,22 @@ void test_fapi2Test(void) { FAPI_INF(">>>>>>test_fapi2Test starting..."); - FAPI_INF(">>test_fapi2HwpTest starting..."); + FAPI_INF(">>fapi2HwpTest starting..."); fapi2HwpTest(); - FAPI_INF("<>test_fapi2GetChildrenTest starting..."); + FAPI_INF(">>fapi2GetChildren starting..."); fapi2GetChildrenTest(); - FAPI_INF("<>fapi2TargetTest::testFapi2GetParent starting..."); + FAPI_INF(">>fapi2GetParent starting..."); fapi2GetParentTest(); - FAPI_INF("<>fapi2GetOtherEnd starting..."); + fapi2GetOtherEnd(); + FAPI_INF(">>fapi2GetOtherEnd exiting..."); } - }; #endif \ No newline at end of file -- cgit v1.2.3