Skip to content

Commit

Permalink
Cxxtest for fapi_i2c support
Browse files Browse the repository at this point in the history
Test framework for fapi_i2c testing

Change-Id: I2f901ad393d03ce498e7b1c30ce1c4ef25bee037
RTC:197029
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/65952
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: Corey V. Swenson <cswenson@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
mderkse1 authored and dcrowell77 committed Oct 3, 2018
1 parent 1ad25a8 commit 1c97a15
Show file tree
Hide file tree
Showing 4 changed files with 501 additions and 1 deletion.
174 changes: 174 additions & 0 deletions src/usr/fapi2/test/fapi2I2cAccessTest.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/fapi2/test/fapi2I2cAccessTest.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2018 */
/* [+] 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_I2CACCESSTEST_H
#define __FAPI2_I2CACCESSTEST_H

/**
* @file src/usr/fapi2/test/fapi2I2cAccessTest.H
*
* @brief Test various types of i2c access with FAPI2 Macros
*/

#include <cxxtest/TestSuite.H>
#include <errl/errlmanager.H>
#include <errl/errlentry.H>
#include <fapi2.H>
#include <fapi2TestUtils.H>
#include <p9_i2ctests.H>
#include <plat_hwp_invoker.H>

using namespace fapi2;

class Fapi2I2cAccessTest : public CxxTest::TestSuite
{
public:
//******************************************************************************
// test_fapi2I2cIllegalAccess
//******************************************************************************
void test_fapi2I2cIllegalAccess()
{
errlHndl_t l_errl = nullptr;
int numTests = 0;
int numFails = 0;

// Create a vector of TARGETING::Target pointers
TARGETING::TargetHandleList l_procTargetList;

// Get a list of all of the proc chips
TARGETING::getAllChips(l_procTargetList, TARGETING::TYPE_PROC, true);


for (auto & l_proc: l_procTargetList)
{
Target<fapi2::TARGET_TYPE_PROC_CHIP> fapi2_procTarget( l_proc );

numTests++;
FAPI_INVOKE_HWP(l_errl, p9_i2ctest_geti2c_fail, fapi2_procTarget);
if(l_errl != nullptr)
{
delete l_errl; // delete expected error log
l_errl = nullptr;
}
else
{
TS_FAIL("No error from p9_i2ctest_geti2c_fail !!");
numFails++;
}

numTests++;
FAPI_INVOKE_HWP(l_errl, p9_i2ctest_puti2c_fail, fapi2_procTarget);
if(l_errl != nullptr)
{
delete l_errl; // delete expected error log
l_errl = nullptr;
}
else
{
TS_FAIL("No error from p9_i2ctest_puti2c_fail !!");
numFails++;
}
}

FAPI_INF("fapi2I2cAccessTest Test Complete. %d/%d fails", numFails, numTests);

}


//******************************************************************************
// test_fapi2I2cAccess
//******************************************************************************
void test_fapi2I2cAccess()
{
int numTests = 0;
int numFails = 0;

errlHndl_t l_errl = nullptr;

// 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_OCMB_CHIP, true);

for (auto & l_ocmb: l_chipList)
{
Target<fapi2::TARGET_TYPE_OCMB_CHIP> l_fapi2_target( l_ocmb );

numTests++;
FAPI_INVOKE_HWP(l_errl, p9_i2ctest_geti2c_pass, l_fapi2_target);
if(l_errl)
{
TS_FAIL("Error from p9_i2ctest_geti2c_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
l_errl = nullptr;
}

numTests++;
FAPI_INVOKE_HWP(l_errl, p9_i2ctest_puti2c_pass, l_fapi2_target);
if(l_errl)
{
TS_FAIL("Error from p9_i2ctest_puti2c_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
l_errl = nullptr;
}

numTests++;
FAPI_INVOKE_HWP(l_errl, p9_i2ctest_double_read_pass, l_fapi2_target);
if(l_errl)
{
TS_FAIL("Error from p9_i2ctest_double_read_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
l_errl = nullptr;
}

numTests++;
FAPI_INVOKE_HWP(l_errl, p9_i2ctest_write_read_pass, l_fapi2_target);
if(l_errl)
{
TS_FAIL("Error from p9_i2ctest_write_read_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
l_errl = nullptr;
}
}

FAPI_INF("fapi2I2cAccessTest Test Complete. %d/%d fails", numFails, numTests);
}


};

#endif // End __FAPI2_I2CACCESSTEST_H
22 changes: 21 additions & 1 deletion src/usr/fapi2/test/fapi2Test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,27 @@ OBJS += fapi2TestUtils.o
OBJS += getVpdTest.o
OBJS += p9_pm_get_poundv_bucket.o

TESTS += ${shell ls ${ROOTPATH}/src/usr/fapi2/test/*Test.H | sort | xargs}
ifeq (${HOSTBOOT_RUNTIME},1)
################################################################################
## Remove non-runtime tests (grep -v testname.H)
TESTS += ${shell ls ${ROOTPATH}/src/usr/fapi2/test/*Test.H | \
grep -v fapi2I2cAccessTest.H | \
sort | xargs}

################################################################################

else

################################################################################
## All hostboot IPL time tests
TESTS += ${shell ls ${ROOTPATH}/src/usr/fapi2/test/*Test.H | \
sort | xargs}
OBJS += p9_i2ctests.o

################################################################################
endif

TESTS += ${shell ls src/usr/fapi2/test/*TestCxx.H | sort | xargs)}


VPATH += ${ROOTPATH}/src/import/chips/p9/procedures/hwp/pm/

0 comments on commit 1c97a15

Please sign in to comment.