-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
runLibTests.sh
executable file
·92 lines (79 loc) · 2.16 KB
/
runLibTests.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
#!/bin/bash
#
# Script to rebuild libraries and dependencies
# (with or without a sanitizer) and run the tests.
#
# The use case of the script is mainly for development purposes -
# to clean and rebuild a single library, with all of its dependencies,
# and run the tests.
#
# Usage: ./runLibTests.sh library [address | undefined | thread] [<test> | -all | none]
#
# Example: ./runLibTests.sh Data/SQLite address
# (distcleans, rebuilds and runs tests for Data/SQLite with address sanitizer)
#
# Known shortcomings (TODO):
# - the script does not check if the library is a dependency of another library
# workaround: run the script for the dependent libraries first
#
# g++ does not like empty quoted arguments, but
# the shellcheck wants them quoted to remain quiet
# shellcheck disable=SC2086
path=$1
if [ -z "${path}" ]; then
echo "Library not specified"
echo "Usage: $0 path [address | undefined | thread] [<test> | -all | none]"
exit 1
fi
libraries=
IFS='/' read -r -a libraries <<< "$path"
self="${BASH_SOURCE[0]}"
if [ -d "$self" ] ; then
basedir="$(cd "$self" || exit; pwd -P)"
else
basedir="$(cd "$(dirname "$self")" || exit; pwd -P)"
fi
# shellcheck disable=SC1091
. "$basedir"/poco_env.bash
flag=$2
flags=
if [ -n "${flag}" ]; then
flags=SANITIZEFLAGS+=-fsanitize="$flag"
fi
path="$basedir"/"${libraries[0]}"
make distclean -C "$basedir"/Foundation
make distclean -C "$basedir"/CppUnit
make -s -j4 -C "$basedir"/Foundation $flags
make -s -j4 -C "$basedir"/CppUnit $flags
test=$3
if [ -z "${test}" ]; then
test="-all"
fi
# Foundation requested, build/run tests and exit
if [[ "$path" == "$basedir"/"Foundation" ]]; then
cd "$path/testsuite/" || exit
make -s -j4 -C ./ $flags
cd "bin/$OSNAME/$OSARCH/" || exit
if [[ "$test" != "none" ]]; then
./testrunner "${test}"
./testrunnerd "${test}"
fi
echo "$path $flags done."
exit 0
fi
for library in "${libraries[@]}"
do
cd "$library" || exit
make distclean
make -s -j4 -C ./ $flags
cd testsuite || exit
make distclean
make -s -j4 -C ./ $flags
cd bin/"$OSNAME"/"$OSARCH"/ || exit
if [[ "$test" != "none" ]]; then
./testrunner "${test}"
./testrunnerd "${test}"
fi
echo "$1 $flags done."
cd ../../../../ || exit
done