-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathtest-angha-1k.sh
executable file
·131 lines (108 loc) · 3.15 KB
/
test-angha-1k.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
SRC_DIR=$( cd "$( dirname "${DIR}" )" && pwd )
LLVM_VERSION=14
RELLIC_DECOMPILE="rellic-decomp-${LLVM_VERSION}.0"
function Help
{
echo "Run Rellic on AnghaBech-1K"
echo ""
echo "Options:"
echo " --rellic-cmd <cmd> The rellic decompile command to invoke. Default ${RELLIC_DECOMPILE}"
echo " -h --help Print help."
}
function check_test
{
local input_json=${1}
if [[ ! -f ${1} ]]
then
echo "[!] Could not find python results for: ${input_json}"
return 1
fi
# count number of failures
fail_msg=$(\
PYTHONPATH=${SRC_DIR}/external/lifting-tools-ci/tool_run_scripts \
python3 -c "import stats,sys; s=stats.Stats(); s.load_json(sys.stdin); print(s.get_fail_count())" \
< ${input_json})
if [[ "${fail_msg}" != "0" ]]
then
echo "[!] There were [${fail_msg}] failures on ${arch}:"
PYTHONPATH=${SRC_DIR}/external/lifting-tools-ci/tool_run_scripts \
python3 -c "import stats,sys; s=stats.Stats(); s.load_json(sys.stdin); s.print_fails()" \
< ${input_json}
return 1
fi
return 0
}
set -euo pipefail
while [[ $# -gt 0 ]] ; do
key="$1"
case $key in
-h)
Help
exit 0
;;
--help)
Help
exit 0
;;
# Cmd to run for decompilation
--rellic-cmd)
RELLIC_DECOMPILE=${2}
shift # past argument
;;
*)
# unknown option
echo "[x] Unknown option: ${key}"
exit 1
;;
esac
shift # past argument or value
done
if ! ${RELLIC_DECOMPILE} --version &>/dev/null;
then
echo "[!] Could not execute rellic cmd: ${RELLIC_DECOMPILE}"
exit 1
fi
# create a working directory
mkdir -p rellic-angha-test-1k
pushd rellic-angha-test-1k
# fetch the test set: 1K bitcode (per arch)
${SRC_DIR}/external/lifting-tools-ci/datasets/fetch_anghabench.sh --run-size 1k --bitcode --clang 14
# extract it
for tarfile in *.tar.xz
do
tar -xJf ${tarfile}
done
FAILED="no"
for arch in $(ls -1 bitcode/)
do
echo "[+] Testing architecture ${arch}"
${SRC_DIR}/external/lifting-tools-ci/tool_run_scripts/rellic.py \
--rellic "${RELLIC_DECOMPILE}" \
--input-dir "$(pwd)/bitcode/${arch}" \
--output-dir "$(pwd)/decompile/${arch}" \
--run-name "rellic-live-ci-${arch}" \
--test-options "${SRC_DIR}/ci/angha_1k_test_settings.json" \
--dump-stats
if ! check_test "$(pwd)/decompile/${arch}/stats.json"
then
echo "[!] Failed decompilation for ${arch}"
FAILED="yes"
fi
# This is currently informational only
mkdir -p "$(pwd)/recompile/${arch}"
${SRC_DIR}/external/lifting-tools-ci/tool_run_scripts/recompile.py \
--clang "clang-${LLVM_VERSION}" \
--input-dir "$(pwd)/decompile/${arch}" \
--output-dir "$(pwd)/recompile/${arch}" \
--run-name "recompile-live-ci-${arch}" \
--dump-stats
done
if [[ "${FAILED}" = "no" ]]
then
echo "[+] All tests successful!"
exit 0
fi
echo "[!] One or more failures encountered during test"
exit 1