Question: #include Assignment - 4 . h #include SVF - LLVM / LLVMUtil . h #include SVF - LLVM / SVFIRBuilder .

#include "Assignment-4.h"
#include "SVF-LLVM/LLVMUtil.h"
#include "SVF-LLVM/SVFIRBuilder.h"
#include "Graphs/CallGraph.h"
#include "Util/Options.h"
#include "Util/CommandLine.h"
using namespace std;
void Test1()
{
cout <<"
running test1: "<< endl;
SVFModule *svfModule = LLVMModuleSet::getLLVMModuleSet()->buildSVFModule({"./Assignment-4/testcase/bc/test1.ll"});
/// Build Program Assignment Graph (SVFIR)
SVF::SVFIRBuilder builder(svfModule);
SVF::SVFIR *pag = builder.build();
TaintGraphTraversal *taint = new TaintGraphTraversal(pag);
taint->taintChecking();
set expected ={"START->5->1->2->3->6->7->8->9->END"};
assert(taint->getPaths()== expected && "
wrong paths generated - test1 failed !");
cout <<"
test1 passed !"<< endl;
SVF::LLVMModuleSet::releaseLLVMModuleSet();
SVF::SVFIR::releaseSVFIR();
}
void Test2()
{
cout <<"
running test2 :"<< endl;
SVFModule *svfModule = LLVMModuleSet::getLLVMModuleSet()->buildSVFModule({"./Assignment-4/testcase/bc/test2.ll"});
/// Build Program Assignment Graph (SVFIR)
SVF::SVFIRBuilder builder(svfModule);
SVF::SVFIR *pag = builder.build();
TaintGraphTraversal *taint = new TaintGraphTraversal(pag);
taint->taintChecking();
assert(taint->getPaths().size()==0 && "
should not exist tainted path - test2 failed !");
cout <<"
test2 passed !"<< endl;
SVF::LLVMModuleSet::releaseLLVMModuleSet();
SVF::SVFIR::releaseSVFIR();
}
void Test3()
{
cout <<"
running test3 :"<< endl;
SVFModule *svfModule = LLVMModuleSet::getLLVMModuleSet()->buildSVFModule({"./Assignment-4/testcase/bc/test3.ll"});
/// Build Program Assignment Graph (SVFIR)
SVF::SVFIRBuilder builder(svfModule);
SVF::SVFIR *pag = builder.build();
TaintGraphTraversal *taint = new TaintGraphTraversal(pag);
taint->taintChecking();
assert(taint->getPaths().size()==0 && "
should not exist tainted path - test3 failed !");
cout <<"
test3 passed !"<< endl;
SVF::SVFIR::releaseSVFIR();
SVF::LLVMModuleSet::releaseLLVMModuleSet();
}
void Test4()
{
cout <<"
running test4 :"<< endl;
SVFModule *svfModule = LLVMModuleSet::getLLVMModuleSet()->buildSVFModule({"./Assignment-4/testcase/bc/test4.ll"});
/// Build Program Assignment Graph (SVFIR)
SVF::SVFIRBuilder builder(svfModule);
SVF::SVFIR *pag = builder.build();
TaintGraphTraversal *taint = new TaintGraphTraversal(pag);
taint->taintChecking();
set expected ={"START->5->1->2->3->6->7->8->9->10->12->14->END"};
assert(taint->getPaths()== expected && "
wrong paths generated - test4 failed !");
cout <<"
test4 passed !"<< endl;
SVF::LLVMModuleSet::releaseLLVMModuleSet();
SVF::SVFIR::releaseSVFIR();
}
int main(int argc, char **argv)
{
int arg_num =0;
int extraArgc =1;
char **arg_value = new char *[argc + extraArgc];
for (; arg_num < argc; ++arg_num)
{
arg_value[arg_num]= argv[arg_num];
}
// You may comment it to see the details of the analysis
arg_value[arg_num++]=(char *)"-stat=false";
std::vector moduleNameVec;
moduleNameVec = OptionBase::parseOptions(
arg_num, arg_value, "Teaching-Software-Analysis Assignment 4","[options]");
Test1();
Test2();
Test3();
Test4();
return 0;
}
These are the test files

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!