Skip to content

Commit

Permalink
Do not unload modules loaded for unit tests
Browse files Browse the repository at this point in the history
For some of the unit tests we must load in .so modules that were
unloaded during the boot. Modules must get loaded and unloaded during
the boot, especially before we expand from cache containment to over
come size limitations. We were seeing issues were test case A and
B both relied on a module and attempted to load it when the test
case was instantiated then tried to unload the module when the test
case was completed. This was causing issues if two tests were using
the same loaded module and one test finished early and unloaded it.
Test cases are run on simics after memory is expanded so there is
no reason unload the extra modules we load in so we will leave them
loaded.

Change-Id: Ia41d38da11400f54ee2e59e497b9610ac24f1629
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/82099
Reviewed-by: Matt Derksen <mderkse1@us.ibm.com>
Reviewed-by: Glenn Miles <milesg@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
crgeddes authored and dcrowell77 committed Aug 13, 2019
1 parent 3c930cf commit c98af33
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 136 deletions.
18 changes: 2 additions & 16 deletions src/usr/expaccess/test/expscomtest.H
Expand Up @@ -109,9 +109,7 @@ private:
return fapi2::getScom(i_target,i_address,o_data);
}

// use this to keep track of if we need to unload any
// modules loaded by this testcase
bool mss_module_loaded;
// This is used for tests that need to not run operations at the same time
HB_MUTEX_SERIALIZE_TEST_LOCK_ATTR iv_serializeTestMutex;

public:
Expand Down Expand Up @@ -807,14 +805,12 @@ public:
*/
expscomTest() : CxxTest::TestSuite()
{
mss_module_loaded = false;

// All modules are loaded by runtime,
// so testcase loading of modules is not required
#ifndef __HOSTBOOT_RUNTIME
errlHndl_t err = nullptr;

err = exptest::loadModule(mss_module_loaded, exptest::MSS_LIBRARY_NAME);
err = exptest::loadModule(exptest::MSS_LIBRARY_NAME);
if(err)
{
TS_FAIL("expscomTest() - Constuctor: failed to load MSS module");
Expand All @@ -830,16 +826,6 @@ public:
*/
~expscomTest()
{
errlHndl_t err = nullptr;
if (mss_module_loaded)
{
err = exptest::unloadModule(exptest::MSS_LIBRARY_NAME);
if(err)
{
TS_FAIL("~expscomTest() - Destructor: failed to unload MSS module");
errlCommit( err, CXXTEST_COMP_ID );
}
}
};

};
Expand Down
23 changes: 1 addition & 22 deletions src/usr/expaccess/test/exptest_utils.C
Expand Up @@ -28,10 +28,9 @@

namespace exptest
{
errlHndl_t loadModule(bool & o_module_loaded, const char * i_modName)
errlHndl_t loadModule(const char * i_modName)
{
errlHndl_t err = NULL;
o_module_loaded = false;

// VFS functions only compilable in non-runtime environment
#ifndef __HOSTBOOT_RUNTIME
Expand All @@ -44,33 +43,13 @@ namespace exptest
}
else
{
o_module_loaded = true;
FAPI_INF("loadModule: %s loaded", i_modName);
}
}
#endif
return err;
}

errlHndl_t unloadModule(const char * i_modName)
{
errlHndl_t err = NULL;

// VFS function only compilable in non-runtime environment
#ifndef __HOSTBOOT_RUNTIME
err = VFS::module_unload(i_modName);
if(err)
{
TS_FAIL("unloadModule() - %s unload failed", i_modName );
}
else
{
FAPI_INF("unloadModule: %s unloaded", i_modName);
}
#endif
return err;
}

TARGETING::HB_MUTEX_SERIALIZE_TEST_LOCK_ATTR getTestMutex(void)
{
TARGETING::HB_MUTEX_SERIALIZE_TEST_LOCK_ATTR pMutex = nullptr;
Expand Down
11 changes: 1 addition & 10 deletions src/usr/expaccess/test/exptest_utils.H
Expand Up @@ -37,19 +37,10 @@ const char MSS_LIBRARY_NAME[17] = "libisteps_mss.so";

/**
* @brief Generic function to load a module
* @param o_module_loaded - returns true if module is loaded by this function
* @param i_modName - module name to load
* @return error handle if module_load call fails
*/
errlHndl_t loadModule(bool & o_module_loaded, const char * i_modName);

/**
* @brief Generic function to unload a module
* @param i_modName - module name to load
* @return error handle if module_unload call fails
*
*/
errlHndl_t unloadModule(const char * i_modName);
errlHndl_t loadModule(const char * i_modName);

/**
* @brief Get the mutex pointer for syncronizing tests
Expand Down
18 changes: 1 addition & 17 deletions src/usr/expaccess/test/ocmbcommtest.H
Expand Up @@ -232,14 +232,12 @@ class OCMBCommTest: public CxxTest::TestSuite
*/
OCMBCommTest() : CxxTest::TestSuite()
{
mss_module_loaded = false;

// All modules are loaded by runtime,
// so testcase loading of modules is not required
#ifndef __HOSTBOOT_RUNTIME
errlHndl_t err = nullptr;

err = exptest::loadModule(mss_module_loaded, exptest::MSS_LIBRARY_NAME);
err = exptest::loadModule(exptest::MSS_LIBRARY_NAME);
if(err)
{
TS_FAIL("OCMBCommTest() - Constuctor: failed to load MSS module");
Expand All @@ -254,23 +252,9 @@ class OCMBCommTest: public CxxTest::TestSuite
*/
~OCMBCommTest()
{
errlHndl_t err = nullptr;
if (mss_module_loaded)
{
err = exptest::unloadModule(exptest::MSS_LIBRARY_NAME);
if(err)
{
TS_FAIL("~OCMBCommTest() - Destructor: failed to unload MSS module");
errlCommit( err, TARG_COMP_ID );
}
}
};

private:
// use this to keep track of if we need to unload any
// modules loaded by this testcase
bool mss_module_loaded;

// This is used for tests that need to not run operations at the same time
TARGETING::HB_MUTEX_SERIALIZE_TEST_LOCK_ATTR iv_serializeTestMutex;

Expand Down
16 changes: 1 addition & 15 deletions src/usr/fapi2/test/fapi2MmioAccessTest.H
Expand Up @@ -254,13 +254,11 @@ void test_fapi2MmioAccess()
*/
Fapi2MmioAccessTest() : CxxTest::TestSuite()
{
mss_module_loaded = false;

// All modules are loaded by runtime,
// so testcase loading of modules is not required
#ifndef __HOSTBOOT_RUNTIME
errlHndl_t err = nullptr;
err = exptest::loadModule(mss_module_loaded, exptest::MSS_LIBRARY_NAME);
err = exptest::loadModule(exptest::MSS_LIBRARY_NAME);
if(err)
{
TS_FAIL("Fapi2MmioAccessTest() - Constuctor: failed to load MSS module");
Expand All @@ -275,22 +273,10 @@ Fapi2MmioAccessTest() : CxxTest::TestSuite()
*/
~Fapi2MmioAccessTest()
{
errlHndl_t err = nullptr;
if (mss_module_loaded)
{
err = exptest::unloadModule(exptest::MSS_LIBRARY_NAME);
if(err)
{
TS_FAIL("~Fapi2MmioAccessTest() - Destructor: failed to unload MSS module");
errlCommit( err, TARG_COMP_ID );
}
}
}


private:
// keep track if this test loaded mss_module
bool mss_module_loaded;
// This is used for tests that need to not run operations at the same time
TARGETING::HB_MUTEX_SERIALIZE_TEST_LOCK_ATTR iv_serializeTestMutex;

Expand Down
59 changes: 3 additions & 56 deletions src/usr/isteps/expupd/test/expupdatetest.H
Expand Up @@ -51,14 +51,12 @@ const char EXPUPD_LIBRARY_NAME[] = "libexpupd.so";

/**
* @brief Generic function to load a module
* @param o_module_loaded - returns true if module is loaded by this function
* @param i_modName - module name to load
* @return error handle if module_load call fails
*/
errlHndl_t loadModule(bool & o_module_loaded, const char * i_modName)
errlHndl_t loadModule(const char * i_modName)
{
errlHndl_t err = nullptr;
o_module_loaded = false;

// VFS functions only compilable in non-runtime environment
#ifndef __HOSTBOOT_RUNTIME
Expand All @@ -71,37 +69,13 @@ errlHndl_t loadModule(bool & o_module_loaded, const char * i_modName)
}
else
{
o_module_loaded = true;
TS_TRACE("loadModule: %s loaded", i_modName);
}
}
#endif
return err;
}

/**
* @brief Generic function to unload a module
* @param i_modName - module name to load
* @return error handle if module_unload call fails
*/
errlHndl_t unloadModule(const char * i_modName)
{
errlHndl_t err = nullptr;

// VFS function only compilable in non-runtime environment
#ifndef __HOSTBOOT_RUNTIME
err = VFS::module_unload(i_modName);
if(err)
{
TS_FAIL("unloadExplorerModule() - %s unload failed", i_modName );
}
else
{
TS_TRACE("unloadModule: %s unloaded", i_modName);
}
#endif
return err;
}

class ExpUpdateTest: public CxxTest::TestSuite
{
Expand Down Expand Up @@ -167,21 +141,18 @@ class ExpUpdateTest: public CxxTest::TestSuite
*/
ExpUpdateTest() : CxxTest::TestSuite()
{
mss_module_loaded = false;
expupd_module_loaded = false;

// All modules are loaded by runtime,
// so testcase loading of modules is not required
#ifndef __HOSTBOOT_RUNTIME
errlHndl_t err = nullptr;

err = loadModule(mss_module_loaded, MSS_LIBRARY_NAME);
err = loadModule(MSS_LIBRARY_NAME);
if(err)
{
TS_FAIL("ExpUpdateTest() - Constuctor: failed to load MSS module");
errlCommit( err, CXXTEST_COMP_ID );
}
err = loadModule(expupd_module_loaded, EXPUPD_LIBRARY_NAME);
err = loadModule(EXPUPD_LIBRARY_NAME);
if(err)
{
TS_FAIL("ExpUpdateTest() - Constuctor: failed to load EXPUPD module");
Expand All @@ -196,33 +167,9 @@ class ExpUpdateTest: public CxxTest::TestSuite
*/
~ExpUpdateTest()
{
errlHndl_t err = nullptr;
if (mss_module_loaded)
{
err = unloadModule(MSS_LIBRARY_NAME);
if(err)
{
TS_FAIL("~ExpUpdateTest() - Destructor: failed to unload MSS module");
errlCommit( err, CXXTEST_COMP_ID );
}
}
if (expupd_module_loaded)
{
err = unloadModule(EXPUPD_LIBRARY_NAME);
if(err)
{
TS_FAIL("~ExpUpdateTest() - Destructor: failed to unload EXPUPD module");
errlCommit( err, CXXTEST_COMP_ID );
}
}

};

private:
// use this to keep track of if we need to unload any
// modules loaded by this testcase
bool mss_module_loaded;
bool expupd_module_loaded;
};

#endif

0 comments on commit c98af33

Please sign in to comment.