-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_analyses.sh
executable file
·64 lines (59 loc) · 2.69 KB
/
run_analyses.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
C_FILES=c_testcases.list
CPP_FILES=cpp_testcases.list
ABS_REPORT_PATH=$PWD/reports
rm -rf reports
mkdir reports;
# clang static analyzer
echo 'Running scan-build (clang analyzer) analyses...'
mkdir reports/scan-build;
for mkfile in `cat $C_FILES $CPP_FILES | xargs -l -n1 dirname | sort -u`; do
pushd $mkfile;
scan-build -plist -o $ABS_REPORT_PATH/scan-build make > /dev/null 2>&1;
make clean;
popd;
done
printf "\tDone\n"
# cppcheck
echo 'Running cppcheck analyses...'
mkdir reports/cppcheck;
cat $C_FILES $CPP_FILES > cppcheck.list;
echo juliet/testcasesupport/std_thread.c >> cppcheck.list
echo juliet/testcasesupport/io.c >> cppcheck.list
echo juliet/testcasesupport/main_linux.cpp >> cppcheck.list
cppcheck -I/home/athos/USP/pesquisa/experiments/juliet/testcasesupport --file-list=cppcheck.list cppcheck --enable=all --xml --xml-version=2cppcheck 2> reports/cppcheck/cppcheck.log 1> /dev/null;
rm cppcheck.list;
printf "\tDone\n"
# frama-c
echo 'Running Frama-C analyses...'
mkdir reports/frama-c;
# frama-c must analyze complementary testcases ending with '[abcde].c' together
partial_testcase_head_regex="[0-9]a\.c$"
partial_testcase_regex="[0-9][bcde]\.c$"
for c_file in `cat $C_FILES`; do
if [[ $c_file =~ $partial_testcase_regex ]]; then
continue;
elif [[ $c_file =~ $partial_testcase_head_regex ]]; then
target_files=`sed 's/a\.c$//'<<<$c_file`
frama-c -val -value-log ew:reports/frama-c/framac_temp.log -kernel-log ew:reports/frama-c/framac_temp.log -cpp-extra-args='-Ijuliet/testcasesupport -DINCLUDEMAIN -U__cplusplus' juliet/testcasesupport/io.c ${target_files}*.c > /dev/null;
else
frama-c -val -value-log ew:reports/frama-c/framac_temp.log -kernel-log ew:reports/frama-c/framac_temp.log -cpp-extra-args='-Ijuliet/testcasesupport -DINCLUDEMAIN -U__cplusplus' juliet/testcasesupport/io.c $c_file > /dev/null;
fi
cat reports/frama-c/framac_temp.log >> reports/frama-c/frama-c.log;
rm reports/frama-c/framac_temp.log
done;
printf "\tDone\n"
# flawfinder
echo 'Running flawfinder analyses...'
mkdir reports/flawfinder;
# we remove unwanted testcases to run flawfinder in the whole testsuite (this is faster)
cp -R juliet juliet_backup;
find juliet/testcases | grep '/CWE[^/]*w32.*\.c$\|/CWE[^/]*wchar_t.*\.c$' | sort -u > c_testcases.toremove;
find juliet/testcases | grep '/CWE[^/]*w32.*\.cpp$\|/CWE[^/]*wchar_t.*\.cpp$' | sort -u > cpp_testcases.toremove;
sort $C_FILES $C_FILES c_testcases.toremove | uniq -u | xargs rm
sort $CPP_FILES $CPP_FILES cpp_testcases.toremove | uniq -u | xargs rm
flawfinder juliet/testcasesupport juliet/testcases > reports/flawfinder/flawfinder.log;
rm -rf juliet
rm c_testcases.toremove cpp_testcases.toremove
mv juliet_backup juliet
printf "\tDone\n"