Skip to content

Commit 2eb6e28

Browse files
author
bjjwwang
committed
update ass3
2 parents 042dfc1 + e360d20 commit 2eb6e28

File tree

2 files changed

+13
-54
lines changed

2 files changed

+13
-54
lines changed

Assignment-3/Assignment-3.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ bool ICFGTraversal::aliasCheck(const CallICFGNode* src, const CallICFGNode* snk)
8181
// There is a tainted flow from p@source to q@sink
8282
// if (1) alias(p,q)==true and (2) source reaches sink on ICFG.
8383
void ICFGTraversal::taintChecking() {
84-
const fs::path& config = CUR_DIR() / "../Tests/SrcSnk.txt";
84+
const fs::path& config = CUR_DIR() / "Tests/SrcSnk.txt";
8585
// configure sources and sinks for taint analysis
8686
readSrcSnkFromFile(config);
8787

@@ -113,4 +113,4 @@ void AndersenPTA::analyze() {
113113
reanalyze = true;
114114
} while (reanalyze);
115115
finalize();
116-
}
116+
}

Assignment-3/test.cpp

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ void TestICFG(std::vector<std::string>& moduleNameVec) {
2525
ICFG* icfg = pag->getICFG();
2626
// If you want to test your own case, please change the dump name
2727
ICFGTraversal* gt = new ICFGTraversal(pag);
28-
const fs::path& config = CUR_DIR() / "../Tests/SrcSnk.txt";
28+
const fs::path& config = CUR_DIR() / "Tests/SrcSnk.txt";
29+
2930
gt->readSrcSnkFromFile(config);
3031
for (const CallICFGNode* src : gt->identifySources()) {
3132
for (const CallICFGNode* snk : gt->identifySinks()) {
@@ -34,63 +35,22 @@ void TestICFG(std::vector<std::string>& moduleNameVec) {
3435
}
3536
std::string moduleName = moduleNameVec[0].substr(moduleNameVec[0].find_last_of('/') + 1);
3637

38+
// print gt->getPaths()
39+
for (auto path : gt->getPaths())
40+
std::cerr << path << "\n";
3741
if (moduleName == "test1.ll") {
3842
std::set<std::string> expected = {"START->3->4->5->END"};
3943
assert(gt->getPaths() == expected && " \n wrong paths generated - test1 failed !");
4044
checkICFGcase(moduleName, gt->getPaths(), expected);
4145
}
4246
else if (moduleName == "test2.ll") {
43-
std::set<std::string> expected = {"START->3->4->5->6->7->8->9->END",
44-
"START->3->4->5->6->7->END", "START->5->6->7->8->9->END",
45-
"START->5->6->7->END"};
46-
checkICFGcase(moduleName, gt->getPaths(), expected);
47-
}
48-
else if (moduleName == "test3.ll") {
4947
std::set<std::string> expected = {"START->6->7->8->1->5->2->9->10->END"};
5048
checkICFGcase(moduleName, gt->getPaths(), expected);
5149
}
52-
else if (moduleName == "test4.ll") {
53-
std::set<std::string> expected = {"START->12->13->14->3->8->9->1->7->2->10->11->4->15->16->END"};
54-
checkICFGcase(moduleName, gt->getPaths(), expected);
55-
}
56-
else if (moduleName == "test5.ll") {
57-
std::set<std::string> expected =
58-
{
59-
"START->6->7->8->9->10->1->5->2->11->14->END",
60-
"START->6->7->8->9->12->1->5->2->13->16->END",
61-
};
62-
checkICFGcase(moduleName, gt->getPaths(), expected);
63-
}
64-
else if (moduleName == "test6.ll") {
65-
std::set<std::string> expected =
66-
{
67-
"START->12->13->14->15->16->3->8->9->1->7->2->10->11->4->17->20->END",
68-
"START->12->13->14->15->18->3->8->9->1->7->2->10->11->4->19->22->END",
69-
};
70-
checkICFGcase(moduleName, gt->getPaths(), expected);
71-
}
72-
else if (moduleName == "test7.ll") {
73-
//START->16->1->2->END
74-
std::set<std::string> expected = {"START->17->1->7->END"};
75-
checkICFGcase(moduleName, gt->getPaths(), expected);
76-
}
77-
else if (moduleName == "test8.ll") {
78-
std::set<std::string> expected =
79-
{
80-
"START->6->7->8->9->10->1->5->2->11->14->END",
81-
"START->6->7->8->9->12->1->5->2->13->16->END",
82-
};
83-
checkICFGcase(moduleName, gt->getPaths(), expected);
84-
}
85-
else if (moduleName == "test9.ll") {
86-
std::set<std::string> expected = {"START->7->8->9->10->11->14->END"};
87-
checkICFGcase(moduleName, gt->getPaths(), expected);
88-
}
89-
else if (moduleName == "test10.ll") {
50+
else if (moduleName == "test3.ll") {
9051
std::set<std::string> expected =
9152
{
92-
"START->3->4->5->6->7->9->11->END",
93-
"START->3->4->5->6->8->10->14->17->END",
53+
"START->12->13->14->3->8->9->1->7->2->10->11->4->15->16->END",
9454
};
9555
checkICFGcase(moduleName, gt->getPaths(), expected);
9656
}
@@ -162,17 +122,16 @@ void TestTaint(std::vector<std::string>& moduleNameVec) {
162122
else {
163123

164124
}
125+
// print taint->getPaths()
126+
for (auto path : taint->getPaths())
127+
std::cerr << path << "\n";
128+
165129
std::string moduleName = moduleNameVec[0].substr(moduleNameVec[0].find_last_of('/') + 1);
166130
if (moduleName == "test1.ll") {
167131
set<string> expected = {"START->6->1->5->2->7->8->9->10->END"};
168132
assert(taint->getPaths() == expected && " \n wrong paths generated - test1 failed !");
169133
cout << "\n test1 passed !" << endl;
170134
}
171-
else if (moduleName == "test4.ll") {
172-
set<string> expected = {"START->6->1->5->2->7->8->9->10->11->13->14->END"};
173-
assert(taint->getPaths() == expected && " \n wrong paths generated - test4 failed !");
174-
cout << "\n test2 passed !" << endl;
175-
}
176135
SVF::SVFIR::releaseSVFIR();
177136
SVF::LLVMModuleSet::releaseLLVMModuleSet();
178137
}

0 commit comments

Comments
 (0)