-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a configuration structure for the test back ends.
- Loading branch information
Showing
44 changed files
with
289 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
backends/p4tools/modules/testgen/lib/test_backend_configuration.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_LIB_TEST_BACKEND_CONFIGURATION_H_ | ||
#define BACKENDS_P4TOOLS_MODULES_TESTGEN_LIB_TEST_BACKEND_CONFIGURATION_H_ | ||
|
||
#include <filesystem> | ||
#include <optional> | ||
|
||
#include "lib/cstring.h" | ||
|
||
namespace P4Tools::P4Testgen { | ||
|
||
/// A file path which may not be set. | ||
using OptionalFilePath = std::optional<std::filesystem::path>; | ||
|
||
/// Configuration parameters for P4Testgen test back ends. | ||
/// These parameters may influence how tests are generated. | ||
struct TestBackendConfiguration { | ||
/// The base name of the test. | ||
cstring testName; | ||
|
||
/// The maximum number of tests to produce. Defaults to one test. | ||
int64_t maxTests = 1; | ||
|
||
/// The base path to be used when writing out tests. | ||
/// May not be set, which means no tests are written to file. | ||
OptionalFilePath fileBasePath; | ||
|
||
/// The initial seed used to generate tests. If it is not set, no seed was used. | ||
std::optional<unsigned int> seed; | ||
}; | ||
|
||
} // namespace P4Tools::P4Testgen | ||
|
||
#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_LIB_TEST_BACKEND_CONFIGURATION_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
#include "backends/p4tools/modules/testgen/lib/test_framework.h" | ||
|
||
#include <optional> | ||
#include <utility> | ||
|
||
namespace P4Tools::P4Testgen { | ||
|
||
TestFramework::TestFramework(std::filesystem::path basePath, | ||
std::optional<unsigned int> seed = std::nullopt) | ||
: basePath(std::move(basePath)), seed(seed) {} | ||
TestFramework::TestFramework(const TestBackendConfiguration &testBackendConfiguration) | ||
: testBackendConfiguration(testBackendConfiguration) {} | ||
|
||
const TestBackendConfiguration &TestFramework::getTestBackendConfiguration() const { | ||
return testBackendConfiguration.get(); | ||
} | ||
} // namespace P4Tools::P4Testgen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.