P4C
The P4 Compiler
Loading...
Searching...
No Matches
bmv2/test_backend/metadata.h
1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_METADATA_H_
2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_METADATA_H_
3
4#include <cstddef>
5#include <filesystem>
6#include <fstream>
7#include <optional>
8#include <string>
9
10#include <inja/inja.hpp>
11
12#include "lib/cstring.h"
13
14#include "backends/p4tools/modules/testgen/lib/test_spec.h"
15#include "backends/p4tools/modules/testgen/targets/bmv2/test_backend/common.h"
16
18
21 public:
22 explicit Metadata(const TestBackendConfiguration &testBackendConfiguration);
23
25 void writeTestToFile(const TestSpec *spec, cstring selectedBranches, size_t testId,
26 float currentCoverage) override;
27
28 private:
30 std::ofstream metadataFile;
31
34 void emitPreamble(const std::string &preamble);
35
41 void emitTestcase(const TestSpec *testSpec, cstring selectedBranches, size_t testId,
42 const std::string &testCase, float currentCoverage);
43
47 static void computeTraceData(const TestSpec *testSpec, inja::json &dataJson);
48
50 static std::string getTestCaseTemplate();
51};
52
53} // namespace P4::P4Tools::P4Testgen::Bmv2
54
55#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_METADATA_H_ */
Bmv2TestFramework provides common utility functions for BMv2-style test frameworks.
Definition common.h:17
Extracts information from the @testSpec to emit a Metadata test case.
Definition bmv2/test_backend/metadata.h:20
void writeTestToFile(const TestSpec *spec, cstring selectedBranches, size_t testId, float currentCoverage) override
Produce a Metadata test.
Definition bmv2/test_backend/metadata.cpp:106
Definition lib/test_spec.h:296
Definition cstring.h:85
Inja.
Definition targets/bmv2/cmd_stepper.cpp:33
Definition test_backend_configuration.h:16