summaryrefslogtreecommitdiffstats
path: root/src/usr/htmgt/test
diff options
context:
space:
mode:
authorChris Cain <cjcain@us.ibm.com>2014-09-29 11:18:13 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2014-11-18 09:59:50 -0600
commit58fb1308bfdf6cd8546cf3187a8d9f7831ade552 (patch)
tree1e4d86a8d82a093c7fe431858e6fa483e5c229dc /src/usr/htmgt/test
parent36282dfad11d98c0d71ff8c0714b4fdf975c1163 (diff)
downloadtalos-hostboot-58fb1308bfdf6cd8546cf3187a8d9f7831ade552.tar.gz
talos-hostboot-58fb1308bfdf6cd8546cf3187a8d9f7831ade552.zip
HTMGT Base Communication
Change-Id: Ie1d9401128d6cfe21a6be1be1760c3ddb0059148 RTC: 115442 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/13863 Tested-by: Jenkins Server Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/htmgt/test')
-rw-r--r--src/usr/htmgt/test/htmgt_occcmd_test.H335
-rw-r--r--src/usr/htmgt/test/htmgt_test.H225
-rw-r--r--src/usr/htmgt/test/makefile1
3 files changed, 561 insertions, 0 deletions
diff --git a/src/usr/htmgt/test/htmgt_occcmd_test.H b/src/usr/htmgt/test/htmgt_occcmd_test.H
new file mode 100644
index 000000000..eb92fac32
--- /dev/null
+++ b/src/usr/htmgt/test/htmgt_occcmd_test.H
@@ -0,0 +1,335 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/htmgt/test/htmgt_occcmd_test.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] 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 __HTMGT_OCCCMD_TEST_H
+#define __HTMGT_OCCCMD_TEST_H
+
+#include <cxxtest/TestSuite.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <vfs/vfs.H>
+
+#include <htmgt/htmgt.H>
+
+#include <targeting/common/targetservice.H>
+#include <targeting/common/attributes.H>
+#include <targeting/common/commontargeting.H>
+#include <targeting/common/utilFilter.H>
+#include <targeting/common/util.H>
+
+#include <htmgt_activate.H>
+#include <htmgt_occcmd.H>
+
+
+using namespace TARGETING;
+
+
+class htmgtOccCmdTest: public CxxTest::TestSuite
+{
+ public:
+
+ // TODO RTC 118875
+ void test_occcmd_poll(void)
+ {
+ errlHndl_t l_err = NULL;
+ bool locallyLoaded = false;
+ TS_TRACE("entered test_occcmd_poll");
+
+ if(!VFS::module_is_loaded("libhtmgt.so"))
+ {
+ l_err = VFS::module_load("libhtmgt.so");
+ if( l_err )
+ {
+ TS_FAIL("Could not load libhtmgt.so module");
+ errlCommit(l_err,HTMGT_COMP_ID);
+ }
+ else
+ {
+ locallyLoaded = true;
+ }
+ }
+
+ HTMGT::occMgr::instance().buildOccs();
+ if (HTMGT::occMgr::instance().getNumOccs() > 0)
+ {
+ HTMGT::Occ *l_occ =
+ HTMGT::occMgr::instance().getMasterOcc();
+
+ // create 1 byte buffer for poll command data
+ const uint8_t l_cmdData[1] = { 0x10 /*version*/ };
+
+ // Normal Poll with default response
+ HTMGT::OccCmd l_cmd(l_occ, HTMGT::OCC_CMD_POLL,
+ sizeof(l_cmdData), l_cmdData);
+ l_err = l_cmd.sendOccCmd();
+ if (l_err != NULL)
+ {
+ // Poll failed
+ ERRORLOG::errlCommit(l_err, HTMGT_COMP_ID);
+ TS_FAIL("occcmd_poll: Poll command failed" );
+ }
+ else
+ {
+ // Poll succeeded
+ uint8_t * l_poll_rsp = NULL;
+ uint32_t l_poll_rsp_size =
+ l_cmd.getResponseData(l_poll_rsp);
+ TS_TRACE("test_occcmd_poll: length=%d, status=0x%02X",
+ l_poll_rsp_size, l_cmd.getRspStatus());
+ }
+
+
+ // Timeout waiting for OCC to respond to Poll cmd
+ HTMGT::G_debug_data = 0x01;
+ HTMGT::OccCmd l_pollTimeout(l_occ, HTMGT::OCC_CMD_POLL,
+ sizeof(l_cmdData), l_cmdData);
+ l_err = l_pollTimeout.sendOccCmd();
+ if (l_err != NULL)
+ {
+ // Poll failed
+ if (0x2635 == l_err->reasonCode())
+ {
+ TS_TRACE("occcmd_poll: Poll timeout as expected");
+ }
+ else
+ {
+ TS_FAIL("occcmd_poll: Did not fail with 0x2635");
+ }
+ ERRORLOG::errlCommit(l_err, HTMGT_COMP_ID);
+ }
+ else
+ {
+ // Poll succeeded
+ uint8_t * l_poll_rsp = NULL;
+ uint32_t l_poll_rsp_size =
+ l_pollTimeout.getResponseData(l_poll_rsp);
+ TS_TRACE("test_occcmd_poll: length=%d, status=0x%02X",
+ l_poll_rsp_size,
+ l_pollTimeout.getRspStatus());
+ TS_FAIL("occcmd_poll: Poll should have failed due to"
+ " timeout waiting for response");
+ }
+ HTMGT::G_debug_data = 0x00;
+
+
+ // Normal Poll with default response
+ HTMGT::OccCmd l_cmd2(l_occ, HTMGT::OCC_CMD_POLL,
+ sizeof(l_cmdData), l_cmdData);
+ l_err = l_cmd2.sendOccCmd();
+ if (l_err != NULL)
+ {
+ // Poll failed
+ ERRORLOG::errlCommit(l_err, HTMGT_COMP_ID);
+ TS_FAIL("occcmd_poll: Poll 2 command failed" );
+ }
+ else
+ {
+ // Poll succeeded
+ uint8_t * l_poll_rsp = NULL;
+ uint32_t l_poll_rsp_size =
+ l_cmd2.getResponseData(l_poll_rsp);
+ TS_TRACE("test_occcmd_poll: length=%d, status=0x%02X",
+ l_poll_rsp_size, l_cmd2.getRspStatus());
+ }
+
+
+ // Timeout waiting for OCC to receive next command
+ HTMGT::G_debug_data = 0x02;
+ HTMGT::OccCmd l_pollTimeout2(l_occ, HTMGT::OCC_CMD_POLL,
+ sizeof(l_cmdData), l_cmdData);
+ l_err = l_pollTimeout2.sendOccCmd();
+ if (l_err != NULL)
+ {
+ // Poll failed
+ if (0x2635 == l_err->reasonCode())
+ {
+ TS_TRACE("occcmd_poll: Poll timeout as expected");
+ }
+ else
+ {
+ TS_FAIL("occcmd_poll: Did not fail with 0x2635");
+ }
+ ERRORLOG::errlCommit(l_err, HTMGT_COMP_ID);
+ }
+ else
+ {
+ // Poll succeeded
+ uint8_t * l_poll_rsp = NULL;
+ uint32_t l_poll_rsp_size =
+ l_pollTimeout2.getResponseData(l_poll_rsp);
+ TS_TRACE("test_occcmd_poll: length=%d, status=0x%02X",
+ l_poll_rsp_size,
+ l_pollTimeout2.getRspStatus());
+ TS_FAIL("occcmd_poll: Poll should have failed due to"
+ " timeout waiting"
+ " to receive cmd");
+ }
+ HTMGT::G_debug_data = 0x00;
+
+
+ // Normal Poll with default response
+ HTMGT::OccCmd l_cmd3(l_occ, HTMGT::OCC_CMD_POLL,
+ sizeof(l_cmdData), l_cmdData);
+ l_err = l_cmd3.sendOccCmd();
+ if (l_err != NULL)
+ {
+ // Poll failed
+ ERRORLOG::errlCommit(l_err, HTMGT_COMP_ID);
+ TS_FAIL("occcmd_poll: Poll 3 command failed" );
+ }
+ else
+ {
+ // Poll succeeded
+ uint8_t * l_poll_rsp = NULL;
+ uint32_t l_poll_rsp_size =
+ l_cmd3.getResponseData(l_poll_rsp);
+ TS_TRACE("test_occcmd_poll: length=%d, status=0x%02X",
+ l_poll_rsp_size, l_cmd3.getRspStatus());
+ }
+
+
+ // Bad checkum in OCC response
+ HTMGT::G_debug_data = 0x03;
+ HTMGT::OccCmd l_pollChecsum(l_occ, HTMGT::OCC_CMD_POLL,
+ sizeof(l_cmdData), l_cmdData);
+ l_err = l_pollChecsum.sendOccCmd();
+ if (l_err != NULL)
+ {
+ // Poll failed
+ if (0x2619 == l_err->reasonCode())
+ {
+ TS_TRACE("occcmd_poll: Checksum fail as expected");
+ }
+ else
+ {
+ TS_FAIL("occcmd_poll: Did not fail with 0x2619");
+ }
+ ERRORLOG::errlCommit(l_err, HTMGT_COMP_ID);
+ }
+ else
+ {
+ // Poll succeeded
+ uint8_t * l_poll_rsp = NULL;
+ uint32_t l_poll_rsp_size =
+ l_pollChecsum.getResponseData(l_poll_rsp);
+ TS_TRACE("test_occcmd_poll: length=%d, status=0x%02X",
+ l_poll_rsp_size, l_pollChecsum.getRspStatus());
+ TS_FAIL("occcmd_poll: Poll should have failed with a"
+ " checksum failure" );
+ }
+ HTMGT::G_debug_data = 0x00;
+
+
+ // Normal Poll with default response
+ HTMGT::OccCmd l_cmd4(l_occ, HTMGT::OCC_CMD_POLL,
+ sizeof(l_cmdData), l_cmdData);
+ l_err = l_cmd4.sendOccCmd();
+ if (l_err != NULL)
+ {
+ // Poll failed
+ ERRORLOG::errlCommit(l_err, HTMGT_COMP_ID);
+ TS_FAIL("occcmd_poll: Poll 4 command failed" );
+ }
+ else
+ {
+ // Poll succeeded
+ uint8_t * l_poll_rsp = NULL;
+ uint32_t l_poll_rsp_size =
+ l_cmd4.getResponseData(l_poll_rsp);
+ TS_TRACE("test_occcmd_poll: length=%d, status=0x%02X",
+ l_poll_rsp_size, l_cmd4.getRspStatus());
+ }
+
+
+ // OCC exception
+ HTMGT::G_debug_data = 0xE0;
+ HTMGT::OccCmd l_exception(l_occ, HTMGT::OCC_CMD_POLL,
+ sizeof(l_cmdData), l_cmdData);
+ l_err = l_exception.sendOccCmd();
+ if (l_err != NULL)
+ {
+ // Poll failed
+ if (0x2619 == l_err->reasonCode())
+ {
+ TS_TRACE("occcmd_poll: Checksum fail as expected");
+ }
+ else
+ {
+ TS_FAIL("occcmd_poll: Did not fail with 0x2619");
+ }
+ TS_TRACE("occcmd_poll: Check for 2AE0 exception logs");
+ ERRORLOG::errlCommit(l_err, HTMGT_COMP_ID);
+ }
+ else
+ {
+ // Poll succeeded
+ uint8_t * l_poll_rsp = NULL;
+ uint32_t l_poll_rsp_size =
+ l_exception.getResponseData(l_poll_rsp);
+ TS_TRACE("test_occcmd_poll: length=%d, status=0x%02X",
+ l_poll_rsp_size, l_exception.getRspStatus());
+ TS_FAIL("occcmd_poll: Poll should have failed with an"
+ " OCC exception" );
+ }
+ HTMGT::G_debug_data = 0x00;
+
+
+ // Normal Poll with default response
+ HTMGT::OccCmd l_cmd5(l_occ, HTMGT::OCC_CMD_POLL,
+ sizeof(l_cmdData), l_cmdData);
+ l_err = l_cmd5.sendOccCmd();
+ if (l_err != NULL)
+ {
+ // Poll failed
+ ERRORLOG::errlCommit(l_err, HTMGT_COMP_ID);
+ TS_FAIL("occcmd_poll: Poll 5 command failed" );
+ }
+ else
+ {
+ // Poll succeeded
+ uint8_t * l_poll_rsp = NULL;
+ uint32_t l_poll_rsp_size =
+ l_cmd5.getResponseData(l_poll_rsp);
+ TS_TRACE("test_occcmd_poll: length=%d, status=0x%02X",
+ l_poll_rsp_size, l_cmd5.getRspStatus());
+ }
+
+ }
+ else
+ {
+ TS_FAIL("occcmd_poll: Could not find any OCCs" );
+ }
+
+ if (locallyLoaded)
+ {
+ VFS::module_unload("libhtmgt.so");
+ }
+
+ TS_TRACE("exiting test_occcmd_poll");
+ }
+
+};
+
+#endif
diff --git a/src/usr/htmgt/test/htmgt_test.H b/src/usr/htmgt/test/htmgt_test.H
new file mode 100644
index 000000000..4cf7264c2
--- /dev/null
+++ b/src/usr/htmgt/test/htmgt_test.H
@@ -0,0 +1,225 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/htmgt/test/htmgt_test.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] 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 __HTMGTTEST_H
+#define __HTMGTTEST_H
+
+#include <cxxtest/TestSuite.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <vfs/vfs.H>
+
+#include <htmgt/htmgt.H>
+#include <htmgt_activate.H>
+
+#include <targeting/common/targetservice.H>
+#include <targeting/common/attributes.H>
+#include <targeting/common/commontargeting.H>
+#include <targeting/common/utilFilter.H>
+#include <targeting/common/util.H>
+
+
+using namespace TARGETING;
+
+
+class htmgtTest: public CxxTest::TestSuite
+{
+ public:
+
+ // Check for HTMGT library
+ bool verifyModuleLoaded(const char *i_modname)
+ {
+ bool loadedLocally = false;
+
+ if(!VFS::module_is_loaded(i_modname))
+ {
+ errlHndl_t l_err = VFS::module_load(i_modname);
+ if( l_err )
+ {
+ TS_FAIL("Could not load %s module", i_modname);
+ errlCommit(l_err,HTMGT_COMP_ID);
+ }
+ else
+ {
+ loadedLocally = true;
+ }
+ }
+
+ return loadedLocally;
+ }
+
+
+ // Get a target for the first OCC
+ TARGETING::TargetHandle_t getFirstOccTarget()
+ {
+ TARGETING::TargetHandle_t o_occTarget = NULL;
+
+ // Get all functional processors
+ TARGETING::TargetHandleList pProcs;
+ TARGETING::getChipResources(pProcs,
+ TARGETING::TYPE_PROC,
+ TARGETING::UTIL_FILTER_FUNCTIONAL);
+ if (pProcs.size() > 0)
+ {
+ const uint8_t instance =
+ pProcs[0]->getAttr<TARGETING::ATTR_POSITION>();
+ TS_TRACE("buildOccs: PROC%d is functional", instance);
+
+ // Get functional OCC (one per proc)
+ TARGETING::TargetHandleList pOccs;
+ getChildChiplets(pOccs, pProcs[0], TARGETING::TYPE_OCC);
+ if (pOccs.size() > 0)
+ {
+ // Use first OCC target
+ TS_TRACE("getFirstOccTarget: Found OCC%d", instance);
+ o_occTarget = pOccs[0];
+ }
+ }
+ if (NULL == o_occTarget)
+ {
+ TS_FAIL("getFirstOccTarget: did not find functional OCC");
+ }
+
+ return o_occTarget;
+ }
+
+
+ void test_occdataattr(void)
+ {
+ TS_TRACE("entered test_occdataattr");
+
+ uint8_t occControlData[256];
+ TargetHandleList procChips;
+ getAllChips(procChips, TYPE_PROC, true);
+ uint32_t index = 0;
+ for (TargetHandleList::iterator itr = procChips.begin();
+ itr != procChips.end();
+ ++itr)
+ {
+ const uint32_t *wordPtr = (uint32_t*)occControlData;
+ itr[index]->tryGetAttr<ATTR_OCC_CONTROL_DATA>(occControlData);
+ TS_TRACE("test_occdataattr[%d]: 0x%08X ...",
+ index++, *wordPtr);
+ // TODO RTC 109066
+ }
+
+ TS_TRACE("exiting test_occdataattr");
+ }
+
+
+ void test_occloadstartfail(void)
+ {
+ TS_TRACE("entered test_occloadstartfail");
+ const bool locallyLoaded = verifyModuleLoaded("libhtmgt.so");
+
+ TARGETING::TargetHandle_t failedOcc = getFirstOccTarget();
+ HTMGT::processOccStartStatus(false, failedOcc);
+ if (HTMGT::occMgr::instance().getNumOccs() != 0)
+ {
+ TS_FAIL("occloadstartfail: No OCCs should be available");
+ }
+
+ if (locallyLoaded)
+ {
+ VFS::module_unload("libhtmgt.so");
+ }
+
+ TS_TRACE("exiting test_occloadstartfail");
+ }
+
+
+ void test_occloadstartsuccess(void)
+ {
+ TS_TRACE("entered test_occloadstartsuccess");
+ const bool locallyLoaded = verifyModuleLoaded("libhtmgt.so");
+
+ HTMGT::processOccStartStatus(true);
+ if (HTMGT::occMgr::instance().getNumOccs() == 0)
+ {
+ TS_FAIL("occloadstartsuccess: No OCCs are available");
+ }
+
+ if (locallyLoaded)
+ {
+ VFS::module_unload("libhtmgt.so");
+ }
+
+ TS_TRACE("exiting test_occloadstartsuccess");
+ }
+
+
+ void test_processoccerror(void)
+ {
+ TS_TRACE("entered test_processoccerror");
+ const bool locallyLoaded = verifyModuleLoaded("libhtmgt.so");
+
+ TARGETING::TargetHandle_t occTarget = getFirstOccTarget();
+ HTMGT::occMgr::instance().buildOccs();
+ if (HTMGT::occMgr::instance().getNumOccs() > 0)
+ {
+ HTMGT::processOccError(occTarget);
+ // TODO RTC 109224
+ }
+ else
+ {
+ TS_FAIL("processoccerror: Couldnt find a functional OCC");
+ }
+
+ if (locallyLoaded)
+ {
+ VFS::module_unload("libhtmgt.so");
+ }
+
+ TS_TRACE("exiting test_processoccerror");
+ }
+
+ void test_processoccreset(void)
+ {
+ TS_TRACE("entered test_processoccreset");
+ const bool locallyLoaded = verifyModuleLoaded("libhtmgt.so");
+
+ TARGETING::TargetHandle_t occTarget = getFirstOccTarget();
+ HTMGT::occMgr::instance().buildOccs();
+ if (HTMGT::occMgr::instance().getNumOccs() > 0)
+ {
+ HTMGT::processOccReset(occTarget);
+ // TODO RTC 115296
+ }
+ else
+ {
+ TS_FAIL("processoccreset: Couldnt find a functional OCC");
+ }
+
+ if (locallyLoaded)
+ {
+ VFS::module_unload("libhtmgt.so");
+ }
+
+ TS_TRACE("exiting test_processoccreset");
+ }
+
+};
+
+#endif
diff --git a/src/usr/htmgt/test/makefile b/src/usr/htmgt/test/makefile
index a80ff55e2..cd03f5636 100644
--- a/src/usr/htmgt/test/makefile
+++ b/src/usr/htmgt/test/makefile
@@ -31,6 +31,7 @@ EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/plat
EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/hwp
EXTRAINCDIR += ${ROOTPATH}/src/usr/hwpf/hwp/include
EXTRAINCDIR += ${ROOTPATH}/src/usr/hwpf/hwp/mc_config/mss_eff_config
+EXTRAINCDIR += ${ROOTPATH}/src/usr/htmgt
MODULE = testhtmgt
TESTS = *.H
OpenPOWER on IntegriCloud