summaryrefslogtreecommitdiffstats
path: root/src/usr/fapi2
diff options
context:
space:
mode:
authorcrgeddes <crgeddes@us.ibm.com>2016-03-30 20:59:51 -0500
committerStephen Cprek <smcprek@us.ibm.com>2016-04-21 13:51:41 -0500
commit75fc7001ace168ef7c687d3b938d58c9e5adf48f (patch)
tree9ccb0814f8b30245523ffc108da66181f1add71d /src/usr/fapi2
parent43b31e59ca4f20d8172c8daff89eb0f648d14238 (diff)
downloadtalos-hostboot-75fc7001ace168ef7c687d3b938d58c9e5adf48f.tar.gz
talos-hostboot-75fc7001ace168ef7c687d3b938d58c9e5adf48f.zip
Fix format of fapi2 test cases
Refactoring some tests now so it follows what the other cases are doing. Note: I am pulling in some code from an abandoned commit in for toString test so it looks like new code is being added but really things are just moving around Change-Id: I7706c304f3ef3369e56516ac81f88dc91d059bf2 RTC:150514 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/22692 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/fapi2')
-rw-r--r--src/usr/fapi2/test/fapi2BasicTryTest.H193
-rw-r--r--src/usr/fapi2/test/fapi2GetChildrenTest.H (renamed from src/usr/fapi2/test/fapi2GetChildrenTest.C)20
-rw-r--r--src/usr/fapi2/test/fapi2GetOtherEndTest.H (renamed from src/usr/fapi2/test/fapi2GetOtherEnd.C)15
-rw-r--r--src/usr/fapi2/test/fapi2GetParentTest.H (renamed from src/usr/fapi2/test/fapi2GetParentTest.C)33
-rw-r--r--src/usr/fapi2/test/fapi2HwAccessTest.H168
-rw-r--r--src/usr/fapi2/test/fapi2HwpTest.H (renamed from src/usr/fapi2/test/fapi2HwpTest.C)82
-rw-r--r--src/usr/fapi2/test/fapi2TestUtils.H20
-rw-r--r--src/usr/fapi2/test/fapi2ToStringTest.H (renamed from src/usr/fapi2/test/fapi2Test.H)99
-rw-r--r--src/usr/fapi2/test/makefile7
-rw-r--r--src/usr/fapi2/test/p9_basicTry.C185
10 files changed, 469 insertions, 353 deletions
diff --git a/src/usr/fapi2/test/fapi2BasicTryTest.H b/src/usr/fapi2/test/fapi2BasicTryTest.H
new file mode 100644
index 000000000..1c73f833e
--- /dev/null
+++ b/src/usr/fapi2/test/fapi2BasicTryTest.H
@@ -0,0 +1,193 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/test/fapi2BasicTryTest.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 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 <fapi2.H>
+// #include <plat_attribute_service.H>
+
+//--------------------------------------------------------------------------
+/// @file p9_basicTry.C
+///
+/// @brief This does tests of the FAPI try and FAPI assert MACROs without
+/// needing full ReturnCode support.
+//--------------------------------------------------------------------------
+
+namespace fapi2
+{
+
+class Fapi2BasicTryTest : public CxxTest::TestSuite
+{
+ private:
+
+ // This is the basic function that allows us to set a return code
+ // that we can use for FAPI_TRY macro testing.
+ uint32_t p9_forceTestUsingRc( uint32_t i_rc )
+ {
+ FAPI_INF("p9_forceTestUsingRc with RC = %d", i_rc );
+
+ return(i_rc);
+ }
+
+
+ // Force a bad RC and see if FAPI_TRY will do the goto exit
+ fapi2::ReturnCode p9_fapi_tryFailure( )
+ {
+
+ FAPI_INF("Go for BAD TEST ");
+ FAPI_TRY( p9_forceTestUsingRc(0xFF) );
+
+ // Should never get here since we failed routine above
+ // Hence, I want to fail testcase if we do
+ FAPI_ERR("Completed BAD TEST --Should never get here");
+ fapi2::current_err = 0xDEAD;
+ return fapi2::current_err;
+
+ fapi_try_exit:
+ // We failed as expected
+ FAPI_INF( "Had RC %d but will exit cleanly",
+ (uint64_t)(fapi2::current_err) );
+ fapi2::current_err = 0;
+
+ return fapi2::current_err;
+ }
+
+
+ // Force the FAPI_ASSERT to fail and verify it will goto exit
+ fapi2::ReturnCode p9_fapi_assertFailure( )
+ {
+
+
+ uint32_t l_var1 = 5, l_var2 = 25;
+ FAPI_INF("Running ASSERT test that will fail");
+ FAPI_ASSERT( l_var1 == l_var2,
+ fapi2::FAPI2_SAMPLE(),
+ "Verify ASSERT that WILL ASSERT" );
+
+ // Shouldn't get here so fail if we do
+ FAPI_ERR("Completed BAD TEST with ASSERT -- Should never get here");
+ fapi2::current_err = 0xABAD;
+ return fapi2::current_err;
+
+ fapi_try_exit:
+ // We detected the fail which is expected
+ FAPI_INF( "FAILURE as expected though: %d",
+ (uint64_t)(fapi2::current_err) );
+ fapi2::current_err = 0;
+
+ return fapi2::current_err;
+ }
+
+ // FAPI_TRY with good RC so we should run thru all code.
+ // If it doesn't work, we should have non-zero RC which
+ // forces testcase failure.
+ fapi2::ReturnCode p9_fapi_trySuccess( )
+ {
+ fapi2::current_err = 0xFFFF;
+
+ FAPI_INF("Go for GOOD TEST ");
+ FAPI_TRY( p9_forceTestUsingRc(0) );
+ FAPI_INF("Completed GOOD TEST with CURRENT_ERROR: %d",
+ (uint64_t)(fapi2::current_err) );
+ fapi2::current_err = 0;
+
+ fapi_try_exit:
+ FAPI_INF("Exiting with %d", (uint64_t)(fapi2::current_err) );
+
+ return fapi2::current_err;
+ }
+
+
+ // FAPI_ASSERT should succeed and run thru all code.
+ // If it doesn't work, we should have non-zero RC which
+ // forces testcase failure.
+ fapi2::ReturnCode p9_fapi_assertSuccess( )
+ {
+ fapi2::current_err = 0xFFFF;
+
+ uint32_t l_var1 = 5, l_var2 = 5;
+ FAPI_ASSERT( l_var1 == l_var2,
+ fapi2::FAPI2_SAMPLE(),
+ "Verify ASSERT that doesn't assert" );
+ FAPI_INF("Completed GOOD TEST with ASSERT");
+ fapi2::current_err = 0;
+
+
+ fapi_try_exit:
+ FAPI_INF("SUCCESS Exiting with %d", (uint64_t)(fapi2::current_err) );
+
+ return fapi2::current_err;
+ }
+
+ public:
+ //******************************************************************************
+ // test_fapi2basicTry
+ //******************************************************************************
+
+ void test_fapi2basicTry()
+ {
+ int numTests = 0;
+ int numFails = 0;
+ fapi2::ReturnCode l_rc;
+
+
+ FAPI_INF("fapi2basicTry starting ... ");
+
+ numTests++;
+ l_rc = p9_fapi_tryFailure();
+ if ( true == (bool)l_rc )
+ {
+ numFails++;
+ TS_FAIL(" p9_fapi_tryFailure returned error");
+ }
+
+ numTests++;
+ l_rc = p9_fapi_assertFailure();
+ if ( true == (bool)l_rc )
+ {
+ numFails++;
+ TS_FAIL(" p9_fapi_assertFailure returned error");
+ }
+
+ numTests++;
+ l_rc = p9_fapi_trySuccess();
+ if ( true == (bool)l_rc )
+ {
+ numFails++;
+ TS_FAIL(" p9_fapi_trySuccess returned error");
+ }
+
+ numTests++;
+ l_rc = p9_fapi_assertSuccess();
+ if ( true == (bool)l_rc )
+ {
+ numFails++;
+ TS_FAIL(" p9_fapi_assertSuccess returned error");
+ }
+
+ FAPI_INF("fapi2basicTry:: Test Complete. %d/%d fails", numFails, numTests);
+
+ } // end main testcase driver
+
+}; // end class
+
+} // end namespace fapi2
diff --git a/src/usr/fapi2/test/fapi2GetChildrenTest.C b/src/usr/fapi2/test/fapi2GetChildrenTest.H
index cd394f3ef..855028cb5 100644
--- a/src/usr/fapi2/test/fapi2GetChildrenTest.C
+++ b/src/usr/fapi2/test/fapi2GetChildrenTest.H
@@ -1,7 +1,7 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
-/* $Source: src/usr/fapi2/test/fapi2GetChildrenTest.C $ */
+/* $Source: src/usr/fapi2/test/fapi2GetChildrenTest.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
@@ -31,16 +31,17 @@
#include <cxxtest/TestSuite.H>
#include <functional>
-using namespace fapi2;
-namespace fapi2
-{
+#include <error_scope.H>
+class Fapi2GetChildrenTest : public CxxTest::TestSuite
+{
+public:
//******************************************************************************
-// fapi2GetParentTest
+// test_fapi2GetParent
//******************************************************************************
-errlHndl_t fapi2GetChildrenTest()
+void test_fapi2GetChildren()
{
int numTests = 0;
int numFails = 0;
@@ -139,7 +140,7 @@ errlHndl_t fapi2GetChildrenTest()
// l_childMCAs = fapi2_mcbistTarget.getChildren<fapi2::TARGET_TYPE_MCA>(TARGET_STATE_PRESENT);
// l_targetHuid = TARGETING::get_huid(targeting_targets[MY_MCBIST]) ;
// l_actualSize = l_childMCAs.size();
-//
+//
// //Set expected size to be the number of MCAs per MCBIST
// l_expectedSize = 2;
// numTests++;
@@ -431,11 +432,10 @@ errlHndl_t fapi2GetChildrenTest()
errlCommit(l_err,HWPF_COMP_ID);
TS_FAIL("fapi2TargetTest Fail, for HUID: %d , expected %d children , found %d ", l_targetHuid,l_expectedSize,l_actualSize );
}
- FAPI_INF("fapi2TargetTest:: Test Complete. %d/%d fails", numFails , numTests);
- return l_err;
+ FAPI_INF("fapi2GetChildrenTest:: Test Complete. %d/%d fails", numFails , numTests);
}
-}
+};
diff --git a/src/usr/fapi2/test/fapi2GetOtherEnd.C b/src/usr/fapi2/test/fapi2GetOtherEndTest.H
index 193e13b31..652bda331 100644
--- a/src/usr/fapi2/test/fapi2GetOtherEnd.C
+++ b/src/usr/fapi2/test/fapi2GetOtherEndTest.H
@@ -1,7 +1,7 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
-/* $Source: src/usr/fapi2/test/fapi2GetOtherEnd.C $ */
+/* $Source: src/usr/fapi2/test/fapi2GetOtherEndTest.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
@@ -36,15 +36,17 @@
namespace fapi2
{
+class Fapi2GetOtherEndTest : public CxxTest::TestSuite
+{
+public:
//******************************************************************************
-// fapi2GetOtherEnd
+// test_fapi2GetOtherEnd
//******************************************************************************
-errlHndl_t fapi2GetOtherEnd()
+void test_fapi2GetOtherEnd()
{
int numTests = 0;
int numFails = 0;
- errlHndl_t l_errl = NULL;
do
{
@@ -205,11 +207,12 @@ errlHndl_t fapi2GetOtherEnd()
}
}
- FAPI_INF("fapi2TargetTest:: Test Complete. %d/%d fails", numFails, numTests);
+ FAPI_INF("fapi2GetOtherEndTest:: 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/fapi2GetParentTest.C b/src/usr/fapi2/test/fapi2GetParentTest.H
index d17968b52..332768c6e 100644
--- a/src/usr/fapi2/test/fapi2GetParentTest.C
+++ b/src/usr/fapi2/test/fapi2GetParentTest.H
@@ -1,7 +1,7 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
-/* $Source: src/usr/fapi2/test/fapi2GetParentTest.C $ */
+/* $Source: src/usr/fapi2/test/fapi2GetParentTest.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
@@ -23,6 +23,7 @@
/* */
/* IBM_PROLOG_END_TAG */
+#include <cxxtest/TestSuite.H>
#include <errl/errlmanager.H>
#include <errl/errlentry.H>
#include <fapi2.H>
@@ -31,33 +32,14 @@
using namespace fapi2;
-namespace fapi2
+class Fapi2GetParentTest : public CxxTest::TestSuite
{
-
-/**
- * @brief Helper to get the parent pervasive of the given target
- *
- * @tparam K Input target's FAPI2 type
- * @tparam V Platform target handle type
- *
- * @param[in] i_pTarget Targeting target
- *
- * @return Platform target handle giving the pervasive of the input target
- * @retval NULL No parent found
- * @retval !NULL Parent found, equal to the retval
- */
-template< TargetType K, typename V = plat_target_handle_t >
-inline V getPervasiveParent(V i_pTarget)
-{
- Target<K,V> fapi2_target(i_pTarget);
- return static_cast<V>(
- fapi2_target.template getParent<TARGET_TYPE_PERV>());
-}
+public:
//******************************************************************************
// fapi2GetParentTest
//******************************************************************************
-errlHndl_t fapi2GetParentTest()
+void test_fapi2GetParent()
{
int numTests = 0;
int numFails = 0;
@@ -1079,11 +1061,10 @@ errlHndl_t fapi2GetParentTest()
}
}while(0);
- FAPI_INF("fapi2TargetTest:: Test Complete. %d/%d fails", numTests, numFails);
- return l_err;
+ FAPI_INF("fapi2GetParentTest:: Test Complete. %d/%d fails", numFails, numTests);
}
-}
+};
diff --git a/src/usr/fapi2/test/fapi2HwAccessTest.H b/src/usr/fapi2/test/fapi2HwAccessTest.H
new file mode 100644
index 000000000..626992fc3
--- /dev/null
+++ b/src/usr/fapi2/test/fapi2HwAccessTest.H
@@ -0,0 +1,168 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/test/fapi2HwAccessTest.H $ */
+/* */
+/* 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 */
+
+
+#ifndef __FAPI2_HWACCESSTEST_H
+#define __FAPI2_HWACCESSTEST_H
+
+/**
+ * @file src/usr/fapi2/test/fapi2HwAccessTest.H
+ *
+ * @brief Test various types of HW access with FAPI2 Macros
+ */
+
+
+
+
+#include <cxxtest/TestSuite.H>
+#include <errl/errlmanager.H>
+#include <errl/errlentry.H>
+#include <fapi2.H>
+#include <hwpf_fapi2_reasoncodes.H>
+#include <fapi2TestUtils.H>
+#include <p9_hwtests.H>
+
+
+
+using namespace fapi2;
+
+
+class Fapi2HwAccessTest : public CxxTest::TestSuite
+{
+public:
+//******************************************************************************
+// test_fapi2HwAccess
+//******************************************************************************
+void test_fapi2HwAccess()
+{
+ int numTests = 0;
+ int numFails = 0;
+ errlHndl_t l_errl = NULL;
+ do
+ {
+ // Create a vector of TARGETING::Target pointers
+ TARGETING::TargetHandleList l_chipList;
+
+ // Get a list of all of the proc chips
+ TARGETING::getAllChips(l_chipList, TARGETING::TYPE_PROC, false);
+
+ TARGETING::Target * l_nimbusProc = NULL;
+
+ //Take the first NIMBUS proc and use it
+ for(uint32_t i = 0; i < l_chipList.size(); i++)
+ {
+ if(TARGETING::MODEL_NIMBUS ==
+ l_chipList[i]->getAttr<TARGETING::ATTR_MODEL>())
+ {
+ l_nimbusProc = l_chipList[i];
+ break;
+ }
+ }
+
+ numTests++;
+ if(l_nimbusProc == NULL)
+ {
+ // Send an errorlog because we cannot find any NIMBUS procs.
+ TS_FAIL("FAPI2_GETPARENT:: could not find Nimbus proc, skipping tests");
+ numFails++;
+ break;
+ }
+
+ Target<fapi2::TARGET_TYPE_PROC_CHIP> fapi2_procTarget(
+ l_nimbusProc);
+
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_scomtest_getscom_fail, fapi2_procTarget);
+ if(l_errl != NULL)
+ {
+ delete l_errl; // delete expected error log
+ }
+ else
+ {
+ TS_FAIL("No error from p9_scomtest_getscom_fail !!");
+ numFails++;
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_scomtest_putscom_fail, fapi2_procTarget);
+ if(l_errl != NULL)
+ {
+ delete l_errl; // delete expected error log
+ }
+ else
+ {
+ TS_FAIL("No error from p9_scomtest_putscom_fail !!");
+ numFails++;
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_cfamtest_putcfam_fail, fapi2_procTarget);
+ if(l_errl != NULL)
+ {
+ delete l_errl; // delete expected error log
+ }
+ else
+ {
+ TS_FAIL("No error from p9_cfamtest_putcfam_fail !!");
+ numFails++;
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_cfamtest_getcfam_fail, fapi2_procTarget);
+ if(l_errl != NULL)
+ {
+ delete l_errl; // delete expected error log
+ }
+ else
+ {
+ TS_FAIL("No error from p9_cfamtest_getcfam_fail !!");
+ numFails++;
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_scomtest_getscom_pass, fapi2_procTarget);
+ if(l_errl)
+ {
+ TS_FAIL("Error from p9_scomtest_getscom_pass !!");
+ numFails++;
+ errlCommit(l_errl,FAPI2_COMP_ID);
+ delete l_errl; // delete unexpected error log so we dont get
+ // a false negative on the next case
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_scomtest_putscom_pass, fapi2_procTarget);
+ if(l_errl)
+ {
+ TS_FAIL("Error from p9_scomtest_putscom_pass !!");
+ numFails++;
+ errlCommit(l_errl,FAPI2_COMP_ID);
+ delete l_errl; // delete unexpected error log so we dont get
+ // a false negative on the next case (future?)
+ }
+ }while(0);
+
+ FAPI_INF("fapi2HwAccessTest Test Complete. %d/%d fails", numFails , numTests);
+
+}
+
+};
+
+#endif // End __FAPI2_HWACCESSTEST_H \ No newline at end of file
diff --git a/src/usr/fapi2/test/fapi2HwpTest.C b/src/usr/fapi2/test/fapi2HwpTest.H
index 35ce9bdc5..7d74f27c2 100644
--- a/src/usr/fapi2/test/fapi2HwpTest.C
+++ b/src/usr/fapi2/test/fapi2HwpTest.H
@@ -1,7 +1,7 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
-/* $Source: src/usr/fapi2/test/fapi2HwpTest.C $ */
+/* $Source: src/usr/fapi2/test/fapi2HwpTest.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
@@ -28,16 +28,21 @@
#include <fapi2.H>
#include <hwpf_fapi2_reasoncodes.H>
#include <fapi2TestUtils.H>
-#include <p9_hwtests.H>
+#include <p9_sample_procedure.H>
+#include <plat_hwp_invoker.H>
-namespace fapi2
-{
+using namespace fapi2;
+
+
+class Fapi2HwpTest : public CxxTest::TestSuite
+{
+public:
//******************************************************************************
-// fapi2HwpTest
+// test_fapi2Hwp
//******************************************************************************
-errlHndl_t fapi2HwpTest()
+void test_fapi2Hwp()
{
int numTests = 0;
int numFails = 0;
@@ -151,66 +156,6 @@ errlHndl_t fapi2HwpTest()
TS_FAIL("Error occured in p9_sample_procedure_proc !!");
}
numTests++;
- FAPI_INVOKE_HWP(l_errl, p9_scomtest_getscom_fail, fapi2_procTarget);
- if(l_errl != NULL)
- {
- delete l_errl; // delete expected error log
- }
- else
- {
- TS_FAIL("No error from p9_scomtest_getscom_fail !!");
- numFails++;
- }
- numTests++;
- FAPI_INVOKE_HWP(l_errl, p9_scomtest_putscom_fail, fapi2_procTarget);
- if(l_errl != NULL)
- {
- delete l_errl; // delete expected error log
- }
- else
- {
- TS_FAIL("No error from p9_scomtest_putscom_fail !!");
- numFails++;
- }
- numTests++;
- FAPI_INVOKE_HWP(l_errl, p9_cfamtest_putcfam_fail, fapi2_procTarget);
- if(l_errl != NULL)
- {
- delete l_errl; // delete expected error log
- }
- else
- {
- TS_FAIL("No error from p9_cfamtest_putcfam_fail !!");
- numFails++;
- }
- numTests++;
- FAPI_INVOKE_HWP(l_errl, p9_cfamtest_getcfam_fail, fapi2_procTarget);
- if(l_errl != NULL)
- {
- delete l_errl; // delete expected error log
- }
- else
- {
- TS_FAIL("No error from p9_cfamtest_getcfam_fail !!");
- numFails++;
- }
- numTests++;
- FAPI_INVOKE_HWP(l_errl, p9_scomtest_getscom_pass, fapi2_procTarget);
- if(l_errl)
- {
- TS_FAIL("Error from p9_scomtest_getscom_pass !!");
- numFails++;
- }
- numTests++;
- FAPI_INVOKE_HWP(l_errl, p9_scomtest_putscom_pass, fapi2_procTarget);
- if(l_errl)
- {
- TS_FAIL("Error from p9_scomtest_putscom_pass !!");
- numFails++;
- }
-
-
- numTests++;
FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_eq, fapi2_eqTarget, scratchWriteValue);
if(l_errl != NULL)
{
@@ -331,8 +276,7 @@ errlHndl_t fapi2HwpTest()
TS_FAIL("Error occured in p9_sample_procedure_capp !!");
}
}while(0);
- FAPI_INF("test_sampleHWPs:: Test Complete. %d/%d fails", numFails,numTests);
- return l_errl;
+ FAPI_INF("test_fapiHWP:: Test Complete. %d/%d fails", numFails,numTests);
}
-}
+};
diff --git a/src/usr/fapi2/test/fapi2TestUtils.H b/src/usr/fapi2/test/fapi2TestUtils.H
index 2fafc296b..c2f6d2649 100644
--- a/src/usr/fapi2/test/fapi2TestUtils.H
+++ b/src/usr/fapi2/test/fapi2TestUtils.H
@@ -118,6 +118,26 @@ enum PERVASIVE_RANGE {
void generateTargets(TARGETING::Target* i_pMasterProcChip,
TARGETING::Target* o_targetList[]);
+/**
+* @brief Helper to get the parent pervasive of the given target
+*
+* @tparam K Input target's FAPI2 type
+* @tparam V Platform target handle type
+*
+* @param[in] i_pTarget Targeting target
+*
+* @return Platform target handle giving the pervasive of the input target
+* @retval NULL No parent found
+* @retval !NULL Parent found, equal to the retval
+ */
+template< TargetType K, typename V = plat_target_handle_t >
+inline V getPervasiveParent(V i_pTarget)
+{
+ Target<K,V> fapi2_target(i_pTarget);
+ return static_cast<V>(
+ fapi2_target.template getParent<TARGET_TYPE_PERV>());
+}
+
} // End namespace fapi2
#endif
diff --git a/src/usr/fapi2/test/fapi2Test.H b/src/usr/fapi2/test/fapi2ToStringTest.H
index 1d2897bc9..b6824a06d 100644
--- a/src/usr/fapi2/test/fapi2Test.H
+++ b/src/usr/fapi2/test/fapi2ToStringTest.H
@@ -1,7 +1,7 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
-/* $Source: src/usr/fapi2/test/fapi2Test.H $ */
+/* $Source: src/usr/fapi2/test/fapi2ToStringTest.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
@@ -22,75 +22,62 @@
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
-#ifndef __FAPI2TEST_H__
-#define __FAPI2TEST_H__
-/**
- * @file fapi2Test.H
- *
- * @brief Test case for FAPI2 code
-*/
-
-#include <cxxtest/TestSuite.H>
-#include <errl/errlmanager.H>
-#include <errl/errlentry.H>
-#include <targeting/common/targetservice.H>
#include <fapi2.H>
-#include <p9_sample_procedure.H>
-#include <hwp_executor.H>
-#include <plat_hwp_invoker.H>
-#include <pnor/pnorif.H>
-#include <targeting/common/utilFilter.H>
-#include <fapi2TestUtils.H>
-#include <hwpf_fapi2_reasoncodes.H>
-#include "fapi2GetParentTest.C"
-#include "fapi2HwpTest.C"
-#include "fapi2GetChildrenTest.C"
-#include "fapi2GetOtherEnd.C"
-#include "p9_basicTry.C"
using namespace fapi2;
-class fapi2Test: public CxxTest::TestSuite
+
+class Fapi2ToStringTest : public CxxTest::TestSuite
{
public:
-
-/**
-* @brief Test some basic HWPs that hit all targets
-* that runs through the FAPI2 macros
-*
-*/
-void test_fapi2Test(void)
+//******************************************************************************
+// test_fapi2ToString
+//******************************************************************************
+void test_fapi2ToString()
{
- FAPI_INF(">>>>>>test_fapi2Test starting...");
-
- FAPI_INF(">>fapi2HwpTest starting...");
- fapi2HwpTest();
- FAPI_INF("<<fapi2HwpTest exiting...");
-
- FAPI_INF(">>fapi2GetChildren starting...");
- fapi2GetChildrenTest();
- FAPI_INF("<<fapi2GetChildren exiting...");
-
- FAPI_INF(">>fapi2GetParent starting...");
- fapi2GetParentTest();
- FAPI_INF("<<fapi2GetParent exiting...");
+ int numTests = 0;
+ int numFails = 0;
+ do
+ {
+ TARGETING::Target* l_pMasterProcChip = NULL;
+ TARGETING::targetService().masterProcChipTargetHandle(l_pMasterProcChip);
- //@TODO-Restore with RTC:151090
- FAPI_INF(">>fapi2GetOtherEnd skipping!!!...");
- //FAPI_INF(">>fapi2GetOtherEnd starting...");
- //fapi2GetOtherEnd();
- //FAPI_INF(">>fapi2GetOtherEnd exiting...");
+ assert(l_pMasterProcChip != NULL);
+ fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>
+ fapi2_procTarget(l_pMasterProcChip);
- FAPI_INF(">>test fapi2basicTry starting...");
- fapi2basicTry();
- FAPI_INF(">>test fapi2basicTry exiting...");
+ TARGETING::ATTR_FAPI_NAME_type tmpScomStr = {0};
+ fapi2::toString(fapi2_procTarget, tmpScomStr, sizeof(tmpScomStr));
+ numTests++;
+ if (tmpScomStr[0] == '\0')
+ {
+ numFails++;
+ TS_FAIL("toString failed to return data for processor chip !!");
+ }
+ else
+ {
+ numTests++;
+ if (strcmp(tmpScomStr, "pu:k0:n0:s0:p00"))
+ {
+ numFails++;
+ TS_FAIL("toString returned wrong processor chip string!!");
+ }
- FAPI_INF("<<<<<<test_fapi2Test exiting...");
+ char smallName[5];
+ fapi2::toString(fapi2_procTarget, smallName, sizeof(smallName));
+ numTests++;
+ if (memcmp(smallName, tmpScomStr, sizeof(smallName)-1))
+ {
+ numFails++;
+ TS_FAIL("toString failed to fill in 5 character processor chip!!");
+ }
+ }
+ } while(0);
+ FAPI_INF("test_fapi2ToString Test Complete. %d/%d fails", numFails , numTests);
}
};
-#endif
diff --git a/src/usr/fapi2/test/makefile b/src/usr/fapi2/test/makefile
index ad5bf730f..990f82e31 100644
--- a/src/usr/fapi2/test/makefile
+++ b/src/usr/fapi2/test/makefile
@@ -42,7 +42,12 @@ OBJS += p9_sample_procedure.o
OBJS += p9_hwtests.o
OBJS += fapi2TestUtils.o
-TESTS += fapi2Test.H
+TESTS += fapi2HwpTest.H
+TESTS += fapi2HwAccessTest.H
+TESTS += fapi2GetParentTest.H
+TESTS += fapi2GetChildrenTest.H
+TESTS += fapi2BasicTryTest.H
+TESTS += fapi2GetOtherEndTest.H
include ${ROOTPATH}/config.mk
diff --git a/src/usr/fapi2/test/p9_basicTry.C b/src/usr/fapi2/test/p9_basicTry.C
deleted file mode 100644
index f95fe4a59..000000000
--- a/src/usr/fapi2/test/p9_basicTry.C
+++ /dev/null
@@ -1,185 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: src/usr/fapi2/test/p9_basicTry.C $ */
-/* */
-/* OpenPOWER HostBoot Project */
-/* */
-/* Contributors Listed Below - COPYRIGHT 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 <fapi2.H>
-// #include <plat_attribute_service.H>
-
-//--------------------------------------------------------------------------
-/// @file p9_basicTry.C
-///
-/// @brief This does tests of the FAPI try and FAPI assert MACROs without
-/// needing full ReturnCode support.
-//--------------------------------------------------------------------------
-
-namespace fapi2
-{
-
-// This is the basic function that allows us to set a return code
-// that we can use for FAPI_TRY macro testing.
-uint32_t p9_forceTestUsingRc( uint32_t i_rc )
-{
- FAPI_INF("p9_forceTestUsingRc with RC = %d", i_rc );
-
- return(i_rc);
-}
-
-
-// Force a bad RC and see if FAPI_TRY will do the goto exit
-fapi2::ReturnCode p9_fapi_tryFailure( )
-{
-
- FAPI_INF("Go for BAD TEST ");
- FAPI_TRY( p9_forceTestUsingRc(0xFF) );
-
- // Should never get here since we failed routine above
- // Hence, I want to fail testcase if we do
- FAPI_ERR("Completed BAD TEST --Should never get here");
- fapi2::current_err = 0xDEAD;
- return fapi2::current_err;
-
-fapi_try_exit:
- // We failed as expected
- FAPI_INF( "Had RC %d but will exit cleanly",
- (uint64_t)(fapi2::current_err) );
- fapi2::current_err = 0;
-
- return fapi2::current_err;
-}
-
-
-// Force the FAPI_ASSERT to fail and verify it will goto exit
-fapi2::ReturnCode p9_fapi_assertFailure( )
-{
-
-
- uint32_t l_var1 = 5, l_var2 = 25;
- FAPI_INF("Running ASSERT test that will fail");
- FAPI_ASSERT( l_var1 == l_var2,
- fapi2::FAPI2_SAMPLE(),
- "Verify ASSERT that WILL ASSERT" );
-
- // Shouldn't get here so fail if we do
- FAPI_ERR("Completed BAD TEST with ASSERT -- Should never get here");
- fapi2::current_err = 0xABAD;
- return fapi2::current_err;
-
-fapi_try_exit:
- // We detected the fail which is expected
- FAPI_INF( "FAILURE as expected though: %d",
- (uint64_t)(fapi2::current_err) );
- fapi2::current_err = 0;
-
- return fapi2::current_err;
-}
-
-// FAPI_TRY with good RC so we should run thru all code.
-// If it doesn't work, we should have non-zero RC which
-// forces testcase failure.
-fapi2::ReturnCode p9_fapi_trySuccess( )
-{
- fapi2::current_err = 0xFFFF;
-
- FAPI_INF("Go for GOOD TEST ");
- FAPI_TRY( p9_forceTestUsingRc(0) );
- FAPI_INF("Completed GOOD TEST with CURRENT_ERROR: %d",
- (uint64_t)(fapi2::current_err) );
- fapi2::current_err = 0;
-
-fapi_try_exit:
- FAPI_INF("Exiting with %d", (uint64_t)(fapi2::current_err) );
-
- return fapi2::current_err;
-}
-
-
-// FAPI_ASSERT should succeed and run thru all code.
-// If it doesn't work, we should have non-zero RC which
-// forces testcase failure.
-fapi2::ReturnCode p9_fapi_assertSuccess( )
-{
- fapi2::current_err = 0xFFFF;
-
- uint32_t l_var1 = 5, l_var2 = 5;
- FAPI_ASSERT( l_var1 == l_var2,
- fapi2::FAPI2_SAMPLE(),
- "Verify ASSERT that doesn't assert" );
- FAPI_INF("Completed GOOD TEST with ASSERT");
- fapi2::current_err = 0;
-
-
-fapi_try_exit:
- FAPI_INF("SUCCESS Exiting with %d", (uint64_t)(fapi2::current_err) );
-
- return fapi2::current_err;
-}
-
-
-
-void fapi2basicTry()
-{
- int numTests = 0;
- int numFails = 0;
- fapi2::ReturnCode l_rc;
-
-
- FAPI_INF("fapi2basicTry starting ... ");
-
- numTests++;
- l_rc = p9_fapi_tryFailure();
- if ( true == (bool)l_rc )
- {
- numFails++;
- TS_FAIL(" p9_fapi_tryFailure returned error");
- }
-
- numTests++;
- l_rc = p9_fapi_assertFailure();
- if ( true == (bool)l_rc )
- {
- numFails++;
- TS_FAIL(" p9_fapi_assertFailure returned error");
- }
-
- numTests++;
- l_rc = p9_fapi_trySuccess();
- if ( true == (bool)l_rc )
- {
- numFails++;
- TS_FAIL(" p9_fapi_trySuccess returned error");
- }
-
- numTests++;
- l_rc = p9_fapi_assertSuccess();
- if ( true == (bool)l_rc )
- {
- numFails++;
- TS_FAIL(" p9_fapi_assertSuccess returned error");
- }
-
- FAPI_INF("fapi2basicTry:: Test Complete. %d/%d fails", numFails, numTests);
-
- return;
-} // end main testcase driver
-
-} // end namespace fapi2
OpenPOWER on IntegriCloud