forked from dbry/lzw-ab
-
Notifications
You must be signed in to change notification settings - Fork 1
/
coverage_toolchains.sh
executable file
·82 lines (65 loc) · 2.08 KB
/
coverage_toolchains.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
#!/usr/bin/env bash
set -e
DIR=$(dirname "${BASH_SOURCE[0]}")
cd "$DIR"
CPU_COUNT=$(grep -c "^processor" "/proc/cpuinfo" || sysctl -n "hw.ncpu")
TMP_PATH="$(pwd)/../tmp"
TMP_SIZE="64"
./temp/mount.sh "$TMP_PATH" "$TMP_SIZE"
cd "$TMP_PATH"
build="toolchain-build"
mkdir -p "$build"
cd "$build"
if ([ -n "$CI" ]); then
curl -s "https://codecov.io/bash" > "codecov.sh"
chmod +x "codecov.sh"
fi
# We need to make test builds for coverage toolchain and all dictionaries.
DICTIONARIES=("linked-list" "sparse-array")
BIGNUM_LIBRARIES=("gmp" "tommath")
toolchains="../../cmake/toolchains"
some_test_passed=false
while read -r toolchain; do
for dictionary in "${DICTIONARIES[@]}"; do
for bignum_library in "${BIGNUM_LIBRARIES[@]}"; do
echo "toolchain: ${toolchain}, dictionary: ${dictionary}, bignum library: ${bignum_library}"
find "." -depth \( \
-name "CMake*" \
-o -name "*.cmake" \
-o -name "*.gcov" \
-o -name "*.gcda" \
-o -name "*.gcno" \
\) -exec rm -rf {} +
# Toolchain may not work.
cmake "../.." \
-DCMAKE_TOOLCHAIN_FILE="$toolchain" \
-DCMAKE_GENERATOR_USE_CURRENT_TOOLCHAIN=ON \
-DLZWS_COMPRESSOR_DICTIONARY="$dictionary" \
-DLZWS_BIGNUM_LIBRARY="$bignum_library" \
-DLZWS_SHARED=ON \
-DLZWS_STATIC=ON \
-DLZWS_CLI=OFF \
-DLZWS_TESTS=ON \
-DLZWS_EXAMPLES=ON \
-DLZWS_MAN=OFF \
-DLZWS_COVERAGE=ON \
-DCMAKE_BUILD_TYPE="Debug" \
|| continue
cmake --build "." --target "clean"
cmake --build "." -j${CPU_COUNT} --target "check" --config "Debug"
if ([ -n "$CI" ]); then
if (echo "$toolchain" | grep -q "clang/coverage.cmake$") && (command -v "llvm-cov" > /dev/null 2>&1); then
cov="llvm-cov gcov"
else
cov="gcov"
fi
./codecov.sh -x "$cov" || continue
fi
some_test_passed=true
done
done
done < <(find "$toolchains" -type f -name "coverage.cmake")
if [ "$some_test_passed" = false ]; then
>&2 echo "At least one test should pass"
exit 1
fi