2023-11-01 00:25:21 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2023-11-04 23:11:38 +01:00
|
|
|
# Script to rebuild libraries and dependencies
|
2023-11-01 00:25:21 +01:00
|
|
|
# (with or without a sanitizer) and run the tests.
|
|
|
|
#
|
2023-11-04 23:11:38 +01:00
|
|
|
# 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.
|
2023-11-01 00:25:21 +01:00
|
|
|
#
|
2023-12-09 21:16:24 +01:00
|
|
|
# Usage: ./runLibTests.sh library [address | undefined | thread] [<test> | -all | none]
|
2023-11-04 23:11:38 +01:00
|
|
|
#
|
|
|
|
# Example: ./runLibTests.sh Data/SQLite address
|
|
|
|
# (distcleans, rebuilds and runs tests for Data/SQLite with address sanitizer)
|
|
|
|
#
|
2023-12-09 21:16:24 +01:00
|
|
|
# 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
|
|
|
|
#
|
2023-11-04 23:11:38 +01:00
|
|
|
|
|
|
|
# g++ does not like empty quoted arguments, but
|
|
|
|
# the shellcheck wants them quoted to remain quiet
|
|
|
|
# shellcheck disable=SC2086
|
2023-11-01 00:25:21 +01:00
|
|
|
|
2023-11-04 23:11:38 +01:00
|
|
|
path=$1
|
|
|
|
if [ -z "${path}" ]; then
|
2023-11-01 00:25:21 +01:00
|
|
|
echo "Library not specified"
|
2023-12-09 21:16:24 +01:00
|
|
|
echo "Usage: $0 path [address | undefined | thread] [<test> | -all | none]"
|
2023-11-01 00:25:21 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-11-04 23:11:38 +01:00
|
|
|
libraries=
|
|
|
|
IFS='/' read -r -a libraries <<< "$path"
|
|
|
|
|
2023-11-01 00:25:21 +01:00
|
|
|
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
|
2023-11-04 23:11:38 +01:00
|
|
|
flags=
|
|
|
|
if [ -n "${flag}" ]; then
|
|
|
|
flags=SANITIZEFLAGS+=-fsanitize="$flag"
|
2023-11-01 19:21:20 +01:00
|
|
|
fi
|
2023-11-01 00:25:21 +01:00
|
|
|
|
2023-11-04 23:11:38 +01:00
|
|
|
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
|
|
|
|
|
2023-12-09 21:16:24 +01:00
|
|
|
test=$3
|
|
|
|
if [ -z "${test}" ]; then
|
|
|
|
test="-all"
|
|
|
|
fi
|
|
|
|
|
2023-11-04 23:11:38 +01:00
|
|
|
# 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
|
2023-12-09 21:16:24 +01:00
|
|
|
if [[ "$test" != "none" ]]; then
|
|
|
|
./testrunner "${test}"
|
|
|
|
./testrunnerd "${test}"
|
|
|
|
fi
|
2023-11-04 23:11:38 +01:00
|
|
|
echo "$path $flags done."
|
|
|
|
exit 0
|
2023-11-01 00:25:21 +01:00
|
|
|
fi
|
2023-11-01 19:21:20 +01:00
|
|
|
|
2023-11-04 23:11:38 +01:00
|
|
|
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
|
2023-12-09 21:16:24 +01:00
|
|
|
if [[ "$test" != "none" ]]; then
|
|
|
|
./testrunner "${test}"
|
|
|
|
./testrunnerd "${test}"
|
|
|
|
fi
|
2023-11-04 23:11:38 +01:00
|
|
|
echo "$1 $flags done."
|
|
|
|
cd ../../../../ || exit
|
|
|
|
done
|