P4C
The P4 Compiler
Loading...
Searching...
No Matches
bmv2/test_backend/metadata.h
1/*
2 * SPDX-FileCopyrightText: 2023 Google LLC
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_METADATA_H_
8#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_METADATA_H_
9
10#include <cstddef>
11#include <filesystem>
12#include <fstream>
13#include <optional>
14#include <string>
15
16#include <inja/inja.hpp>
17
18#include "lib/cstring.h"
19
20#include "backends/p4tools/modules/testgen/lib/test_spec.h"
21#include "backends/p4tools/modules/testgen/targets/bmv2/test_backend/common.h"
22
24
26class Metadata : public Bmv2TestFramework {
27 public:
28 explicit Metadata(const TestBackendConfiguration &testBackendConfiguration);
29
31 void writeTestToFile(const TestSpec *spec, cstring selectedBranches, size_t testId,
32 float currentCoverage) override;
33
34 private:
36 std::ofstream metadataFile;
37
40 void emitPreamble(const std::string &preamble);
41
47 void emitTestcase(const TestSpec *testSpec, cstring selectedBranches, size_t testId,
48 const std::string &testCase, float currentCoverage);
49
53 static void computeTraceData(const TestSpec *testSpec, inja::json &dataJson);
54
56 static std::string getTestCaseTemplate();
57};
58
59} // namespace P4::P4Tools::P4Testgen::Bmv2
60
61#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_METADATA_H_ */
void writeTestToFile(const TestSpec *spec, cstring selectedBranches, size_t testId, float currentCoverage) override
Produce a Metadata test.
Definition bmv2/test_backend/metadata.cpp:110
Definition lib/test_spec.h:303
Definition cstring.h:85
Inja.
Definition targets/bmv2/cmd_stepper.cpp:37
Definition test_backend_configuration.h:22