MCPcopy Create free account
hub / github.com/Samsung/UTopia / prepareFuzzInputs

Method prepareFuzzInputs

lib/generation/Fuzzer.cpp:17–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15Fuzzer::Fuzzer(const Unittest &UT) : Name(UT.getID()), UT(&UT) {}
16
17void Fuzzer::prepareFuzzInputs(const InputAnalysisReport &InputReport) {
18
19 assert(UT && "Unexpected Program State");
20
21 auto &APICalls = UT->getAPICalls();
22 if (APICalls.size() == 0) {
23 ProjectStatus = NOT_FUZZABLE_NO_INPUT;
24 return;
25 }
26
27 // Get Def IDs that are used in a UT.
28 std::set<unsigned> DefIDs;
29 for (auto &APICall : APICalls) {
30 for (auto &APIArg : APICall.Args) {
31 DefIDs.insert(APIArg.DefIDs.begin(), APIArg.DefIDs.end());
32 }
33 }
34
35 // Get Definitions
36 std::vector<std::shared_ptr<const Definition>> DefPtrs;
37 const auto &DefMap = InputReport.getDefMap();
38 for (auto DefID : DefIDs) {
39 auto Iter = DefMap.find(DefID);
40 assert(Iter != DefMap.end() && "Unexpected Program State");
41 DefPtrs.push_back(Iter->second);
42 }
43 FuzzInputGenerator InputGenerator;
44 std::tie(DefIDFuzzInputMap, DefIDFuzzNoInputMap) =
45 InputGenerator.generate(DefPtrs);
46 if (!DefIDFuzzInputMap.empty())
47 ProjectStatus = FUZZABLE;
48}
49
50const Unittest &Fuzzer::getUT() const {
51

Callers 1

createMethod · 0.80

Calls 6

sizeMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
emptyMethod · 0.80
findMethod · 0.45
generateMethod · 0.45

Tested by

no test coverage detected