Ensure simulator does not re-initialize same chip type
Change-Id: I4bf3dd45ca30a977dd629acf8e4654c5385fac30
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/test/simulator/sample_test_case.cpp b/test/simulator/sample_test_case.cpp
index 7cf0c26..662720b 100644
--- a/test/simulator/sample_test_case.cpp
+++ b/test/simulator/sample_test_case.cpp
@@ -3,6 +3,7 @@
START_TEST_CASE(SampleTestSet1)
CHIP(proc0, SAMPLE)
+CHIP(proc1, SAMPLE)
START_ITERATION
diff --git a/test/simulator/simulator.cpp b/test/simulator/simulator.cpp
index 236bfc6..3f21eef 100644
--- a/test/simulator/simulator.cpp
+++ b/test/simulator/simulator.cpp
@@ -8,7 +8,7 @@
//------------------------------------------------------------------------------
// Paths are relative from the build/ directory
-const std::map<SimulatorData::ChipType, const char*>
+const std::map<SimulatorData::SimChipType, const char*>
SimulatorData::cv_chipPath = {
{SAMPLE, "../test/simulator/sample_data/sample.cdb"},
};
@@ -18,14 +18,25 @@
void SimulatorData::addChip(const Chip& i_chip)
{
// First check if this entry already exists.
- auto itr1 = std::find(iv_chipList.begin(), iv_chipList.end(), i_chip);
- ASSERT_EQ(iv_chipList.end(), itr1);
+ auto chip_itr = std::find(iv_chipList.begin(), iv_chipList.end(), i_chip);
+ ASSERT_EQ(iv_chipList.end(), chip_itr);
// Add the new entry.
iv_chipList.push_back(i_chip);
+ // Check if this chip type has been initialized.
+ ChipType_t chipType = i_chip.getType();
+ auto type_itr = std::find(iv_typeList.begin(), iv_typeList.end(), chipType);
+ if (iv_typeList.end() != type_itr)
+ {
+ return; // No need to continue.
+ }
+
+ // Add the new entry.
+ iv_typeList.push_back(chipType);
+
// Look for the file path
- auto itr2 = cv_chipPath.find(static_cast<ChipType>(i_chip.getType()));
+ auto itr2 = cv_chipPath.find(static_cast<SimChipType>(chipType));
ASSERT_NE(cv_chipPath.end(), itr2);
const char* path = itr2->second;
diff --git a/test/simulator/simulator.hpp b/test/simulator/simulator.hpp
index e5526d8..7d25160 100644
--- a/test/simulator/simulator.hpp
+++ b/test/simulator/simulator.hpp
@@ -37,18 +37,21 @@
public:
/** The list of supported chip types for the simulator. */
- enum ChipType
+ enum SimChipType
{
SAMPLE = 0xdeadbeef,
};
private:
/** The Chip Data file paths for each support chip type. */
- static const std::map<ChipType, const char*> cv_chipPath;
+ static const std::map<SimChipType, const char*> cv_chipPath;
/** The list of configured chips used throughout a test case. */
std::vector<Chip> iv_chipList;
+ /** The list of configured chip types used throughout a test case. */
+ std::vector<ChipType_t> iv_typeList;
+
/** The contents of all the SCOM registers used for an iteration of
* isolation. */
std::map<Chip, std::map<uint32_t, uint64_t>> iv_scomRegData;