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

Function TEST_F

tests/utanalysis/TestTargetAPIFinder.cpp:10–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8class TestTargetAPIFinder : public TestBase {};
9
10TEST_F(TestTargetAPIFinder, BasicP) {
11
12 const std::string CODE = "void API_1();\n"
13 "void API_2();\n"
14 "void API_3();\n"
15 "void test() {\n"
16 " API_1();\n"
17 " API_2();\n"
18 "}\n";
19
20 ASSERT_TRUE(loadC(CODE));
21
22 auto *API1 = IRAH->getFunction("API_1");
23 auto *API2 = IRAH->getFunction("API_2");
24 ASSERT_TRUE(API1);
25 ASSERT_TRUE(API2);
26
27 auto *Test = IRAH->getFunction("test");
28 ASSERT_TRUE(Test);
29
30 std::set<llvm::Function *> APIFuncs = {API1, API2};
31 std::vector<llvm::Function *> Funcs = {Test};
32 auto Finder = TargetAPIFinder(APIFuncs);
33 auto TargetAPIs = Finder.findAPIs(Funcs);
34 ASSERT_EQ(TargetAPIs.size(), 2);
35 ASSERT_NE(TargetAPIs.find(API1), TargetAPIs.end());
36 ASSERT_NE(TargetAPIs.find(API2), TargetAPIs.end());
37
38 auto APICallers = Finder.findAPICallers(Funcs);
39 ASSERT_EQ(APICallers.size(), 2);
40 auto *Caller = IRAH->getInstruction("test", 0, 0);
41 ASSERT_TRUE(Caller);
42 ASSERT_TRUE(isa<CallBase>(Caller));
43 ASSERT_NE(APICallers.find(dyn_cast<CallBase>(Caller)), APICallers.end());
44
45 Caller = IRAH->getInstruction("test", 0, 1);
46 ASSERT_TRUE(Caller);
47 ASSERT_TRUE(isa<CallBase>(Caller));
48 ASSERT_NE(APICallers.find(dyn_cast<CallBase>(Caller)), APICallers.end());
49}
50
51TEST_F(TestTargetAPIFinder, NullAPIN) {
52

Callers

nothing calls this directly

Calls 9

TargetAPIFinderClass · 0.85
getFunctionMethod · 0.80
findAPIsMethod · 0.80
sizeMethod · 0.80
endMethod · 0.80
findAPICallersMethod · 0.80
getInstructionMethod · 0.80
getBasicBlockMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected