forked from nils.hoelscher/RTSA-lab01-CacheAnalysis
More Unit Tests
This commit is contained in:
parent
801831a2b5
commit
9dca6c2f67
|
@ -76,7 +76,7 @@ TEST(UnitTest, MustJoinDifferentStates) {
|
||||||
|
|
||||||
void fillSetHighNumbers(AbstractState &In, unsigned int Set) {
|
void fillSetHighNumbers(AbstractState &In, unsigned int Set) {
|
||||||
for (int I = 0; I < 4; I++) {
|
for (int I = 0; I < 4; I++) {
|
||||||
In.Sets[Set].Associativity[I].Blocks.push_front(10+I);
|
In.Sets[Set].Associativity[I].Blocks.push_front(10 + I);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,3 +99,76 @@ TEST(UnitTest, MustJoinDisjunctStates) {
|
||||||
EXPECT_TRUE(AC.Nodes[0].Sets[0].Associativity[Age].Blocks.empty());
|
EXPECT_TRUE(AC.Nodes[0].Sets[0].Associativity[Age].Blocks.empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(UnitTest, MustJoinDisjunctStatesAllSets) {
|
||||||
|
AbstractCache AC;
|
||||||
|
AC.addEmptyNode(0);
|
||||||
|
AC.addEmptyNode(1);
|
||||||
|
for (int I = 0; I < 16; I++) {
|
||||||
|
fillSetHighNumbers(AC.Nodes[0], I);
|
||||||
|
fillSet(AC.Nodes[1], I);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "==Before:==\n";
|
||||||
|
AC.Nodes[0].dump();
|
||||||
|
AC.Nodes[1].dump();
|
||||||
|
|
||||||
|
AC.Nodes[0].mustJoin(AC.Nodes[1]);
|
||||||
|
std::cout << "\n==After:==\n";
|
||||||
|
AC.Nodes[0].dump();
|
||||||
|
for (auto Set : AC.Nodes[0].Sets) {
|
||||||
|
for (auto B : Set.second.Associativity) {
|
||||||
|
EXPECT_TRUE(B.second.Blocks.empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(UnitTest, MustJoinDifferentStatesAllSets) {
|
||||||
|
AbstractCache AC;
|
||||||
|
AC.addEmptyNode(0);
|
||||||
|
AC.addEmptyNode(1);
|
||||||
|
for (int I = 0; I < 16; I++) {
|
||||||
|
if (I % 2)
|
||||||
|
counterFillSet(AC.Nodes[0], I);
|
||||||
|
fillSet(AC.Nodes[1], I);
|
||||||
|
}
|
||||||
|
std::cout << "==Before:==\n";
|
||||||
|
AC.Nodes[0].dump();
|
||||||
|
AC.Nodes[1].dump();
|
||||||
|
|
||||||
|
AC.Nodes[0].mustJoin(AC.Nodes[1]);
|
||||||
|
|
||||||
|
AC.Nodes[1].mustJoin(AC.Nodes[0]);
|
||||||
|
std::cout << "\n==After:==\n";
|
||||||
|
AC.Nodes[1].dump();
|
||||||
|
for (auto Set : AC.Nodes[1].Sets) {
|
||||||
|
for (auto B : Set.second.Associativity) {
|
||||||
|
uint SetNr = Set.first;
|
||||||
|
uint Age = B.first;
|
||||||
|
if (SetNr % 2) {
|
||||||
|
switch (Age) {
|
||||||
|
case 0:
|
||||||
|
EXPECT_TRUE(B.second.Blocks.empty());
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
EXPECT_EQ(B.second.Blocks.front(), 1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
EXPECT_EQ(B.second.Blocks.front(), 2);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
// this test is not very exact the Set 0 with age 3 should contain
|
||||||
|
// (0,3) in arbitrary order
|
||||||
|
EXPECT_EQ(B.second.Blocks.size(), 2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// should never be reached!
|
||||||
|
EXPECT_TRUE(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
EXPECT_TRUE(B.second.Blocks.empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EXPECT_TRUE(AC.Nodes[1] == AC.Nodes[0]);
|
||||||
|
}
|
Reference in New Issue