-
Notifications
You must be signed in to change notification settings - Fork 10
/
build-tests.sh
executable file
·119 lines (88 loc) · 2.65 KB
/
build-tests.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
#!/usr/bin/env bash
set -e -o pipefail
if [[ -z "$BUILD_DIR" ]]; then
BUILD_DIR="$(realpath -m ./builds/tests)"
fi
if [[ -z "$CONTRACTS_DIR" ]]; then
CONTRACTS_DIR="$(realpath ./data/tests/)"
fi
if [[ -z "$EVM_DIR" ]]; then
EVM_DIR="$(realpath ./src/eEVM/)"
fi
source scripts/common.sh
set -u
mkdir -p "$BUILD_DIR" || true
echo "[+] Compiling all solidity files"
pushd "$CONTRACTS_DIR" >/dev/null
make clean
make
popd >/dev/null
SUCCESS=0
ATTEMPTS=0
for contract in $CONTRACTS_DIR/*.combined.json; do
reset_evm_repo
echo "--------------------------------------------------"
contract_id="$(basename "$contract" | cut -d '.' -f 1)"
OUT_PREFIX="$BUILD_DIR/$contract_id"
OUT_PREFIX="$(realpath -m "$OUT_PREFIX")"
if test -e "$OUT_PREFIX.build.tar.xz"; then
echo "[+] already built!"
continue
fi
echo "[+] eEVM repo cleanup"
pushd "$EVM_DIR" >/dev/null
rm -rf ./contracts/
rm -rf ./fuzz/out
rm -rf ./fuzz/dict/
rm -rf ./fuzz/abi/
rm -rf ./fuzz/build/
mkdir ./contracts/
mkdir ./fuzz/dict/
mkdir ./fuzz/abi/
mkdir ./fuzz/build/
echo "$contract_id" > target_name
popd
echo "[+] running evm2cpp"
pushd "$CONTRACTS_DIR" >/dev/null
if print_and_run /usr/bin/time -v -o "$OUT_PREFIX.translate.time" \
evm2cpp \
--evm-path="$EVM_DIR" \
"$contract_id" \
"$contract" 2>&1 \
| tee "$OUT_PREFIX.build.log";
then
echo "1" >"$OUT_PREFIX.build.status"
else
echo "[WARNING] evm2cpp seems to have failed for $contract_id!"
echo "0" >"$OUT_PREFIX.build.status"
echo "skipping contract $contract_id"
continue
fi
popd >/dev/null
echo "[+] Building contract $contract_id"
pushd "$EVM_DIR" >/dev/null
if print_and_run /usr/bin/time -v -o "$OUT_PREFIX.build.time" \
./quick-build.sh afuzz "$contract_id" \
| tee -a "$OUT_PREFIX.build.log";
then
echo "1" >"$OUT_PREFIX.build.status"
SUCCESS=$(($SUCCESS + 1))
else
echo "[WARNING] Build seems to have failed for $contract_id!"
echo "0" >"$OUT_PREFIX.build.status"
echo "skipping contract $contract_id"
continue
fi
echo "[+] creating build tarball"
timed_print_and_run tar --exclude=".git" --exclude=".ccache" -hcf "$OUT_PREFIX.build.tar" .
timed_print_and_run xz -3 -T 0 "$OUT_PREFIX.build.tar"
popd >/dev/null # EVM_DIR
echo "[+] $contract_id done"
ATTEMPTS=$(($ATTEMPTS + 1))
done
echo "[+] $SUCCESS successful builds of $ATTEMPTS attempted builds"
if [[ "$SUCCESS" -eq "$ATTEMPTS" ]]; then
exit 0
else
exit 1
fi