-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
73 lines (56 loc) · 1.94 KB
/
run.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
65
66
67
68
69
70
71
72
73
#! /bin/bash
set -e
function new_s2e_project {
source ${WORKDIR}/s2e-env/venv/bin/activate && source ${WORKDIR}/s2e/s2e_activate
s2e new_project -i debian-9.2.1-x86_64 ${PROG_PATH}
cd ${S2E_DIR}/projects/$(basename "${PROG_PATH}")
# disable unwanted plugins
sed -i 's/add_plugin("WebServiceInterface")/--add_plugin("WebServiceInterface")/' s2e-config.lua
sed -i 's/add_plugin("LuaBindings")/--add_plugin("LuaBindings")/' s2e-config.lua
sed -i 's/add_plugin("LuaCoreEvents")/--add_plugin("LuaCoreEvents")/' s2e-config.lua
sed -i 's/add_plugin("TranslationBlockCoverage")/--add_plugin("TranslationBlockCoverage")/' s2e-config.lua
sed -i 's/add_plugin("TestCaseGenerator")/--add_plugin("TestCaseGenerator")/' s2e-config.lua
echo -e "
add_plugin(\"FunctionMonitor\")
add_plugin(\"OOBTracker\")
pluginsConfig.OOBTracker = {
resultsPath = \"${RESULT_DIR}/dynamic-analysis-results.json\",
statsPath = \"${RESULT_DIR}/dynamic-analysis-stats.json\",
}
add_plugin(\"MemoryTracker\")
pluginsConfig.MemoryTracker = {
auxiliaryDataPath = \"${STATIC_ANALYSIS_PATH}\",
}
add_plugin(\"OOBAnalyzer\")
" >> s2e-config.lua
}
function run_s2e {
cd ${WORKDIR}/s2e/projects/$(basename "${PROG_PATH}")
source ${WORKDIR}/s2e-env/venv/bin/activate && source ${WORKDIR}/s2e/s2e_activate
./launch-s2e.sh
}
if [[ -z "${PROG_PATH}" ]]; then
echo "ERROR: PROG_PATH is not set"
exit 1
fi
if [[ -z "${STATIC_ANALYSIS_PATH}" ]]; then
echo "ERROR: STATIC_ANALYSIS_PATH is not set"
exit 1
fi
if [[ -z "${WORKDIR}" ]]; then
echo "ERROR: WORKDIR is not set"
exit 1
fi
if [[ -z "${RESULT_DIR}" ]]; then
RESULT_DIR="$(dirname "${PROG_PATH}")"
echo "WARNING: RESULT_DIR is not set, using ${RESULT_DIR}"
fi
if [ "$1" == "init" ]; then
new_s2e_project
elif [ "$1" == "run" ]; then
run_s2e
else
echo "Available commands: init, run"
echo "Expected environment variables: PROG_PATH, STATIC_ANALYSIS_PATH, WORKDIR, RESULT_DIR"
exit 1
fi