Build chip data from new JSON format
The chip data XML format has been deprecated and the new JSON format
will be used going forward.
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: I2f44ae7bb921c9ab38c2664ab5cc2a9d6e2fd66a
diff --git a/test/simulator/simulator.cpp b/test/simulator/simulator.cpp
index bca2b99..408d14a 100644
--- a/test/simulator/simulator.cpp
+++ b/test/simulator/simulator.cpp
@@ -13,10 +13,10 @@
const std::map<SimulatorData::SimChipType, const char*>
SimulatorData::cv_chipPath = {
{SAMPLE, "../test/simulator/sample_data/sample.cdb"},
- {EXPLORER_11, "xml/chip_data_explorer_11.cdb"},
- {EXPLORER_20, "xml/chip_data_explorer_20.cdb"},
- {P10_10, "xml/chip_data_p10_10.cdb"},
- {P10_20, "xml/chip_data_p10_20.cdb"},
+ {EXPLORER_11, "chip_data/chip_data_explorer_11.cdb"},
+ {EXPLORER_20, "chip_data/chip_data_explorer_20.cdb"},
+ {P10_10, "chip_data/chip_data_p10_10.cdb"},
+ {P10_20, "chip_data/chip_data_p10_20.cdb"},
};
//------------------------------------------------------------------------------
@@ -73,6 +73,35 @@
//------------------------------------------------------------------------------
+const char* __attn(AttentionType_t i_type)
+{
+ const char* str = "";
+ switch (i_type)
+ {
+ case ATTN_TYPE_CHIP_CS:
+ str = "CHIP_CS";
+ break;
+ case ATTN_TYPE_UNIT_CS:
+ str = "UNIT_CS";
+ break;
+ case ATTN_TYPE_RECOVERABLE:
+ str = "RECOVERABLE";
+ break;
+ case ATTN_TYPE_SP_ATTN:
+ str = "SP_ATTN";
+ break;
+ case ATTN_TYPE_HOST_ATTN:
+ str = "HOST_ATTN";
+ break;
+ default:
+ HEI_ERR("Unsupported attention type: %u", i_type);
+ assert(0);
+ }
+ return str;
+}
+
+//------------------------------------------------------------------------------
+
void SimulatorData::endIteration()
{
// Start by calling libhei::isolate().
@@ -95,23 +124,44 @@
// Get the list of signatures found in isolation.
std::vector<Signature> givenSigList = isoData.getSignatureList();
- // Verify the expected list and given list are the same.
- ASSERT_EQ(iv_expSigList.size(), givenSigList.size());
-
- std::sort(iv_expSigList.begin(), iv_expSigList.end());
- std::sort(givenSigList.begin(), givenSigList.end());
-
- /* TODO: Currently used for debug. Eventually, we want this written to file.
- for (const auto& s : givenSigList)
+ // Print out the expected signature list and verify matches with given list.
+ HEI_INF("Signature summary:")
+ bool mismatch = false;
+ for (const auto& e : iv_expSigList)
{
- HEI_INF("Signature: %s 0x%04x %u %u %u",
- (const char*)s.getChip().getChip(), s.getId(), s.getInstance(),
- s.getBit(), s.getAttnType());
- }
- */
+ auto gItr = std::find(givenSigList.begin(), givenSigList.end(), e);
+ if (givenSigList.end() != gItr)
+ {
+ HEI_INF(" Match: %s 0x%04x %2u %2u %s",
+ (const char*)e.getChip().getChip(), e.getId(),
+ e.getInstance(), e.getBit(), __attn(e.getAttnType()));
- ASSERT_TRUE(std::equal(givenSigList.begin(), givenSigList.end(),
- iv_expSigList.begin()));
+ // Remove from given signature list so we can determine if there are
+ // any leftovers at the end.
+ givenSigList.erase(gItr);
+ }
+ else
+ {
+ HEI_INF(" No match: %s 0x%04x %2u %2u %s",
+ (const char*)e.getChip().getChip(), e.getId(),
+ e.getInstance(), e.getBit(), __attn(e.getAttnType()));
+
+ mismatch = true;
+ }
+ }
+
+ // Print out any leftover signatures from the given list.
+ for (const auto& g : givenSigList)
+ {
+ HEI_INF(" Unexpected: %s 0x%04x %2u %2u %s",
+ (const char*)g.getChip().getChip(), g.getId(), g.getInstance(),
+ g.getBit(), __attn(g.getAttnType()));
+
+ mismatch = true;
+ }
+
+ // Final check for mismatches.
+ ASSERT_FALSE(mismatch);
// The iteration is complete so we can flush the data.
flushIterationData();