P4C
The P4 Compiler
Loading...
Searching...
No Matches
greedy_node_cov.h
1/*
2 * SPDX-FileCopyrightText: 2023 The P4 Language Consortium
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_SYMBOLIC_EXECUTOR_GREEDY_NODE_COV_H_
8#define BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_SYMBOLIC_EXECUTOR_GREEDY_NODE_COV_H_
9
10#include <cstdint>
11#include <optional>
12#include <vector>
13
14#include "ir/solver.h"
15#include "midend/coverage.h"
16
17#include "backends/p4tools/modules/testgen/core/program_info.h"
18#include "backends/p4tools/modules/testgen/core/symbolic_executor/symbolic_executor.h"
19
20namespace P4::P4Tools::P4Testgen {
21
30class GreedyNodeSelection : public SymbolicExecutor {
31 public:
35 void runImpl(const Callback &callBack, ExecutionStateReference state) override;
36
39
40 private:
44 uint64_t stepsWithoutTest = 0;
45
47 static const uint64_t MAX_STEPS_WITHOUT_TEST = 1000;
48
56 std::vector<Branch> potentialBranches;
57
59 // Each element on this vector represents a set of alternative choices that could have been
67 std::vector<Branch> unexploredBranches;
68
73 static std::optional<SymbolicExecutor::Branch> popPotentialBranch(
74 const P4::Coverage::CoverageSet &coverednodes,
75 std::vector<SymbolicExecutor::Branch> &candidateBranches);
76
83 [[nodiscard]] std::optional<ExecutionStateReference> pickSuccessor(StepResult successors);
84};
85
86} // namespace P4::P4Tools::P4Testgen
87
88#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_SYMBOLIC_EXECUTOR_GREEDY_NODE_COV_H_ */
Provides a higher-level interface for an SMT solver.
Definition solver.h:30
void runImpl(const Callback &callBack, ExecutionStateReference state) override
Definition greedy_node_cov.cpp:85
GreedyNodeSelection(AbstractSolver &solver, const ProgramInfo &programInfo)
Constructor for this strategy, considering inheritance.
Definition greedy_node_cov.cpp:25
Stores target-specific information about a P4 program.
Definition core/program_info.h:27
const ProgramInfo & programInfo
Target-specific information about the P4 program.
Definition symbolic_executor.h:68
std::function< bool(const FinalState &)> Callback
Definition symbolic_executor.h:42
std::set< const IR::Node *, SourceIdCmp > CoverageSet
Definition coverage.h:47
Definition phv/solver/action_constraint_solver.cpp:33