diff options
author | Nick Bofferding <bofferdn@us.ibm.com> | 2016-03-15 14:10:01 -0500 |
---|---|---|
committer | William G. Hoffa <wghoffa@us.ibm.com> | 2016-03-29 17:13:00 -0400 |
commit | d69021c4f1acb33cef4692ce85cead2540412862 (patch) | |
tree | d640d2b9ff69055b3c649f5d8b977f133d99d36d /src/usr/testcore | |
parent | 0ceb12be50b8542714a981cbaee2d41244d49507 (diff) | |
download | talos-hostboot-d69021c4f1acb33cef4692ce85cead2540412862.tar.gz talos-hostboot-d69021c4f1acb33cef4692ce85cead2540412862.zip |
Support runtime target translation for Phyp
- Added ordinal IDs to system XML files
- Added new HBRT_HYP_ID attribute to proc, membuf, core targets
- Removed duplicate target type extensions
- Customize HBRT_HYP_ID attributes in istep 21 based on payload type
- Updated runtime translation interfaces for simple, efficient lookup
- Added templated memoizer to speed up simple input/output functions
- Generate ordinal IDs in common attribute parser
- Added various test cases
RTC: 146153
CMVC-Coreq: 989094
Change-Id: Ic60996f3b7c3197191f8939f362c578b54475df4
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/22254
Tested-by: Jenkins Server
Tested-by: FSP CI Jenkins
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: Corey V. Swenson <cswenson@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
Diffstat (limited to 'src/usr/testcore')
-rw-r--r-- | src/usr/testcore/makefile | 5 | ||||
-rw-r--r-- | src/usr/testcore/memoize/makefile | 31 | ||||
-rw-r--r-- | src/usr/testcore/memoize/test_memoize.H | 210 |
3 files changed, 245 insertions, 1 deletions
diff --git a/src/usr/testcore/makefile b/src/usr/testcore/makefile index 328a5bbe7..03def48dd 100644 --- a/src/usr/testcore/makefile +++ b/src/usr/testcore/makefile @@ -5,7 +5,9 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2011,2014 +# Contributors Listed Below - COPYRIGHT 2011,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. @@ -25,6 +27,7 @@ ROOTPATH = ../../.. SUBDIRS += lib.d SUBDIRS += kernel.d SUBDIRS += rtloader.d +SUBDIRS += memoize.d include ${ROOTPATH}/config.mk diff --git a/src/usr/testcore/memoize/makefile b/src/usr/testcore/memoize/makefile new file mode 100644 index 000000000..4f5b804d1 --- /dev/null +++ b/src/usr/testcore/memoize/makefile @@ -0,0 +1,31 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/usr/testcore/memoize/makefile $ +# +# 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 + +ROOTPATH = ../../../.. + +MODULE = testmemoize +TESTS = *.H + +include ${ROOTPATH}/config.mk diff --git a/src/usr/testcore/memoize/test_memoize.H b/src/usr/testcore/memoize/test_memoize.H new file mode 100644 index 000000000..d3d9af1bf --- /dev/null +++ b/src/usr/testcore/memoize/test_memoize.H @@ -0,0 +1,210 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/testcore/memoize/test_memoize.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 */ + +#ifndef __TEST_MEMOIZE_H +#define __TEST_MEMOIZE_H + +/** + * @file test_memoize.H + * @brief Tests memoize utility + */ + +#include <cxxtest/TestSuite.H> + +#include <errl/errlmanager.H> +#include <util/memoize.H> +#include <runtime/runtime_reasoncodes.H> + +int g_accesses = 0; + +errlHndl_t _incrementer(int in, int& out) +{ + errlHndl_t pError = NULL; + + g_accesses++; + + if(in > 2) + { + // A junk error log, this combination never occurs elsewhere + pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + RUNTIME::MOD_CUST_CONF_HBRT_HYP_IDS, + RUNTIME::RT_NO_PROC_TARGET, + 0,0 ); + } + else + { + out = in + 1; + } + + return pError; +} + +errlHndl_t incrementer(int in, int& out) +{ + return Util::Memoize::memoize( + _incrementer,in,out); +} + +class MemoizerTest: public CxxTest::TestSuite +{ + public: + + void testMemoizer(void) + { + TS_TRACE( ENTER_MRK + "testMemoizer> start" ); + + errlHndl_t pError = NULL; + + do { + + int test = 1; + int accesses = g_accesses; + int result = 0; + + // Should get no error + pError = incrementer(test,result); + if(pError) + { + TS_FAIL("testMemoizer> call to memoizer returned error"); + break; + } + + // Should get input + 1 as result + if(result != (test+1)) + { + TS_FAIL("testMemoizer> memoizer did not increment the input"); + break; + } + + // Should register an access + if(g_accesses != (accesses+1)) + { + TS_FAIL("testMemoizer> real function did not dispatch"); + break; + } + + accesses = g_accesses; + test = 1; + result = 0; + // Should be able to repeat same request with no error + pError = incrementer(test,result); + if(pError) + { + TS_FAIL("testMemoizer> call to memoizer returned error"); + break; + } + + // ... and same answer + if(result != (test+1)) + { + TS_FAIL("testMemoizer> memoizer did not increment the input"); + break; + } + + // ... and no additional accesses + if(g_accesses != accesses) + { + TS_FAIL("testMemoizer> real function dispatched unexpectedly"); + break; + } + + accesses = g_accesses; + test = 3; + result = 0; + int origResult = 0; + + // Should get an error as using a bad input value + pError = incrementer(test,result); + if(pError == NULL) + { + TS_FAIL("testMemoizer> call to memoizer did not return error"); + break; + } + + delete pError; + pError = NULL; + + // ... and should register an access + if(g_accesses != (accesses+1)) + { + TS_FAIL("testMemoizer> real function did not dispatch"); + break; + } + + // ... and result should have been left as is + if(result != origResult) + { + TS_FAIL("testMemoizer> memoize changed the output unexpectedly"); + break; + } + + accesses = g_accesses; + test = 3; + result = 0; + origResult = 0; + + // Should be able to make same bad request and get an error + pError = incrementer(test,result); + if(pError == NULL) + { + TS_FAIL("testMemoizer> call to memoizer did not return error"); + break; + } + + delete pError; + pError = NULL; + + // ... and should still register an access (i.e. nothing + // got accidentally cached in error path) + if(g_accesses != (accesses+1)) + { + TS_FAIL("testMemoizer> real function did not dispatch"); + break; + } + + // ... and result should have been left as is + if(result != origResult) + { + TS_FAIL("testMemoizer> memoize changed the output unexpectedly"); + break; + } + + } while(0); + + if(pError) + { + errlCommit(pError,UTIL_COMP_ID); + } + + TS_TRACE( EXIT_MRK + "testMemoizer> finish" ); + } + +}; // End class MemoizerTest + +#endif + |