Skip to content

Commit

Permalink
Rename --with-output-packet to --output-packet-only. (p4lang#4314)
Browse files Browse the repository at this point in the history
  • Loading branch information
fruffy-g authored Jan 8, 2024
1 parent d7dfee1 commit a8c3202
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions backends/p4tools/modules/testgen/lib/test_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ bool TestBackEnd::run(const FinalState &state) {
const auto *programTraces = state.getTraces();
const auto &testgenOptions = TestgenOptions::get();

// Don't increase the test count if --with-output-packet is enabled and we don't
// Don't increase the test count if --output-packet-only is enabled and we don't
// produce a test with an output packet.
if (testgenOptions.withOutputPacket) {
if (testgenOptions.outputPacketOnly) {
auto outputPacketSize = executionState->getPacketBufferSize();
bool packetIsDropped = executionState->getProperty<bool>("drop");
if (outputPacketSize <= 0 || packetIsDropped) {
Expand Down
28 changes: 14 additions & 14 deletions backends/p4tools/modules/testgen/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ TestgenOptions::TestgenOptions()
selectedBranches = arg;
// These options are mutually exclusive.
if (trackBranches) {
std::cerr << "--input-branches and --track-branches are mutually exclusive. Choose "
"one or the other."
<< std::endl;
exit(1);
::error(
"--input-branches and --track-branches are mutually exclusive. Choose "
"one or the other.");
return false;
}
return true;
},
Expand All @@ -196,25 +196,25 @@ TestgenOptions::TestgenOptions()
trackBranches = true;
// These options are mutually exclusive.
if (!selectedBranches.empty()) {
std::cerr << "--input-branches and --track-branches are mutually exclusive. Choose "
"one or the other."
<< std::endl;
exit(1);
::error(
"--input-branches and --track-branches are mutually exclusive. Choose "
"one or the other.");
return false;
}
return true;
},
"[EXPERIMENTAL] Track the branches that are chosen in the symbolic executor. This can be "
"used for deterministic replay.");

registerOption(
"--with-output-packet", nullptr,
"--output-packet-only", nullptr,
[this](const char *) {
withOutputPacket = true;
outputPacketOnly = true;
if (!selectedBranches.empty()) {
std::cerr << "--input-branches cannot guarantee --with-output-packet."
" Aborting."
<< std::endl;
exit(1);
::error(
"--input-branches cannot guarantee --output-packet-only."
" Aborting.");
return false;
}
return true;
},
Expand Down
2 changes: 1 addition & 1 deletion backends/p4tools/modules/testgen/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class TestgenOptions : public AbstractP4cToolOptions {
std::vector<std::pair<int, int>> permittedPortRanges;

/// Enforces the test generation of tests with mandatory output packet.
bool withOutputPacket = false;
bool outputPacketOnly = false;

/// Add conditions defined in assert/assume to the path conditions.
/// Only tests which satisfy these conditions can be generated. This is active by default.
Expand Down

0 comments on commit a8c3202

Please sign in to comment.