diff options
author | Ilya Smirnov <ismirno@us.ibm.com> | 2018-11-12 08:51:33 -0600 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2019-03-01 15:20:41 -0600 |
commit | ed35e3da7c2606f6fe0930725892deae85df33b7 (patch) | |
tree | cb63a99beed07dcac836b2ce574ca07a27ce58bf /src/usr/secureboot/smf/test/testsmfutils.H | |
parent | 8ee01af225a0ac2a6de48624dfd56a3095fb9920 (diff) | |
download | talos-hostboot-ed35e3da7c2606f6fe0930725892deae85df33b7.tar.gz talos-hostboot-ed35e3da7c2606f6fe0930725892deae85df33b7.zip |
Unit Tests For SMF Secure Mem Distribution
This change introduces the unit tests (and helper functions)
to test the SMF memory distribution algorithm.
Change-Id: I0084f869d582e96354f06ec76c3de416c9838701
RTC: 192411
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/68679
Reviewed-by: Nicholas E. Bofferding <bofferdn@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: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/secureboot/smf/test/testsmfutils.H')
-rw-r--r-- | src/usr/secureboot/smf/test/testsmfutils.H | 74 |
1 files changed, 41 insertions, 33 deletions
diff --git a/src/usr/secureboot/smf/test/testsmfutils.H b/src/usr/secureboot/smf/test/testsmfutils.H index 0e61c9785..d8ad2fb8a 100644 --- a/src/usr/secureboot/smf/test/testsmfutils.H +++ b/src/usr/secureboot/smf/test/testsmfutils.H @@ -39,8 +39,41 @@ class SmfUtilsTestSuite : public CxxTest::TestSuite { +private: + bool cv_isSmfLoaded; + public: + SmfUtilsTestSuite() : cv_isSmfLoaded(false) + { + errlHndl_t l_errl = nullptr; + l_errl = VFS::module_load("libsmf.so"); + if(l_errl) + { + TS_FAIL("SmfUtilsTestSuite(): could not load libsmf.so"); + errlCommit(l_errl, CXXTEST_COMP_ID); + cv_isSmfLoaded = false; + } + else + { + cv_isSmfLoaded = true; + } + } + + ~SmfUtilsTestSuite() + { + if(cv_isSmfLoaded) + { + errlHndl_t l_errl = nullptr; + l_errl = VFS::module_unload("libsmf.so"); + if(l_errl) + { + TS_FAIL("~SmfUtilsTestSuite(): could not unload libsmf.so"); + errlCommit(l_errl, CXXTEST_COMP_ID); + } + } + } + /** * @brief Test isSmfEnabled helper function */ @@ -49,19 +82,16 @@ public: TS_INFO(ENTER_MRK "testIsSmfEnabled"); do { + if(!cv_isSmfLoaded) + { + break; + } + TARGETING::Target* l_sys = nullptr; TARGETING::targetService().getTopLevelTarget(l_sys); assert(l_sys, "The top level target is nullptr!"); l_sys->setAttr<TARGETING::ATTR_SMF_ENABLED>(true); - errlHndl_t l_errl = VFS::module_load("libsmf.so"); - if(l_errl) - { - TS_FAIL("Could not load libsmf.so"); - errlCommit(l_errl, CXXTEST_COMP_ID); - break; - } - bool l_smfEnabled = SECUREBOOT::SMF::isSmfEnabled(); if(l_smfEnabled != true) { @@ -75,13 +105,6 @@ public: TS_FAIL("testIsSmfEnabled: expected SMF to be disabled, but it's enabled"); } - l_errl = VFS::module_unload("libsmf.so"); - if(l_errl) - { - TS_FAIL("Could not unload libsmf.so"); - errlCommit(l_errl, CXXTEST_COMP_ID); - break; - } } while (0); TS_INFO(EXIT_MRK "testIsSmfEnabled"); @@ -93,20 +116,15 @@ public: void testCheckRiskLevelForSmf() const { TS_INFO(ENTER_MRK "testCheckRiskLevelForSmf"); - bool l_libsmf_loaded = false; errlHndl_t l_errl = nullptr; do { - TARGETING::Target* l_masterProc = nullptr; - - l_errl = VFS::module_load("libsmf.so"); - if(l_errl) + if(!cv_isSmfLoaded) { - TS_FAIL("Could not load libsmf.so"); - errlCommit(l_errl, CXXTEST_COMP_ID); break; } - l_libsmf_loaded = true; + + TARGETING::Target* l_masterProc = nullptr; l_errl = TARGETING::targetService() .queryMasterProcChipTargetHandle(l_masterProc); @@ -159,16 +177,6 @@ public: } } while(0); - if(l_libsmf_loaded) - { - l_errl = VFS::module_unload("libsmf.so"); - if(l_errl) - { - TS_FAIL("Could not unload libsmf.so"); - errlCommit(l_errl, CXXTEST_COMP_ID); - } - } - TS_INFO(EXIT_MRK "testCheckRiskLevelForSmf"); } }; |