Skip to content

Commit

Permalink
Simplify matcher to guard against randomness.
Browse files Browse the repository at this point in the history
  • Loading branch information
fruffy committed Feb 13, 2024
1 parent fe926bd commit b68543f
Showing 1 changed file with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,9 @@ V1Switch(parse(), verifyChecksum(), ingress(), egress(), computeChecksum(), depa
ASSERT_TRUE(testListOpt.has_value());
auto testList = testListOpt.value();
ASSERT_EQ(testList.size(), 1);
const auto *test = testList[0];
const auto *protobufIrTest = test->to<P4Tools::P4Testgen::Bmv2::ProtobufIrTest>();
ASSERT_TRUE(protobufIrTest != nullptr);
EXPECT_THAT(protobufIrTest->getFormattedTest(), ::testing::HasSubstr(R"(input_packet {
packet: "\xDE\xAD\xDE\xAD\xDE\xAD\xBE\xEF\xBE\xEF\xBE\xEF\xF0\x0D"
port: 0
})"));
const auto *protobufIrTest =
testList[0]->checkedTo<P4Tools::P4Testgen::Bmv2::ProtobufIrTest>();
EXPECT_THAT(protobufIrTest->getFormattedTest(), ::testing::HasSubstr(R"(input_packet)"));
}
/// Now try running again with the test back end set to Protobuf. The result should be the same.
testgenOptions.testBackend = "PROTOBUF";
Expand All @@ -91,12 +87,7 @@ V1Switch(parse(), verifyChecksum(), ingress(), egress(), computeChecksum(), depa
ASSERT_TRUE(testListOpt.has_value());
auto testList = testListOpt.value();
ASSERT_EQ(testList.size(), 1);
auto &test = testList[0];
const auto *protobufTest = test->to<P4Tools::P4Testgen::Bmv2::ProtobufTest>();
ASSERT_TRUE(protobufTest != nullptr);
EXPECT_THAT(protobufTest->getFormattedTest(), ::testing::HasSubstr(R"(input_packet {
packet: "\xDE\xAD\xDE\xAD\xDE\xAD\xBE\xEF\xBE\xEF\xBE\xEF\xF0\x0D"
port: 0
})"));
const auto *protobufTest = testList[0]->checkedTo<P4Tools::P4Testgen::Bmv2::ProtobufTest>();
EXPECT_THAT(protobufTest->getFormattedTest(), ::testing::HasSubstr(R"(input_packet)"));
}
} // namespace Test

0 comments on commit b68543f

Please sign in to comment.