[Unit-tests] Implement module tests in Drone CI
This commit is contained in:
parent
b7bc78ec6f
commit
6d31e846a8
|
@ -10,7 +10,11 @@ steps:
|
|||
- cat /proc/sys/kernel/core_pattern
|
||||
- ./bootstrap.sh -j
|
||||
- echo "applications/mod_test" >> modules.conf
|
||||
- export ASAN_OPTIONS=log_path=stdout;
|
||||
- sed -i '/applications\/mod_http_cache/s/^#//g' modules.conf
|
||||
- sed -i '/event_handlers\/mod_rayo/s/^#//g' modules.conf
|
||||
- sed -i '/formats\/mod_opusfile/s/^#//g' modules.conf
|
||||
- sed -i '/languages\/mod_lua/s/^#//g' modules.conf
|
||||
- export ASAN_OPTIONS=log_path=stdout:disable_coredump=0:unmap_shadow_on_exit=1;
|
||||
- ./configure --enable-address-sanitizer
|
||||
- echo "#!/bin/bash\nmake -j`nproc --all` |& tee ./unit-tests-build-result.txt\nexitstatus=\${PIPESTATUS[0]}\necho \$exitstatus > ./build-status.txt\nmake install\n" > build.sh
|
||||
- chmod +x build.sh
|
||||
|
@ -45,6 +49,6 @@ trigger:
|
|||
- push
|
||||
---
|
||||
kind: signature
|
||||
hmac: 5ebcc916118f95811470ed7e622a2acb71e84790e33f9b172c04fe3e119d78fe
|
||||
hmac: d43f842f682df8328dc4cfbf16051bf8a8e481a051b63349b444447962709435
|
||||
|
||||
...
|
||||
|
|
|
@ -3,17 +3,24 @@
|
|||
echo "Collecting test logs"
|
||||
LOG_DIR=./logs
|
||||
html="<html><h3>There are failed unit-tests:</h3><table>"
|
||||
html+="<tr align=\"left\"><th><br>Unit tests</th></tr>"
|
||||
logs=$(find $LOG_DIR -type f -iname "*.html" -print)
|
||||
logs=$(find $LOG_DIR -type f -iname "*.html" -print | sort)
|
||||
logs_found=0
|
||||
olddirname=""
|
||||
for name in $logs
|
||||
do
|
||||
logname=$(basename $name)
|
||||
testname=$(echo $logname | awk -F 'log_run-tests_' '{print $2}' | awk -F '.html' '{print $1}')
|
||||
html+="<tr align=\"left\"><td><a href="$logname">$testname</a>"
|
||||
testpath="${testname//!/\/}"
|
||||
dirname=$(dirname $testpath)
|
||||
test=$(basename $testpath)
|
||||
if [ "$olddirname" != "$dirname" ]; then
|
||||
html+="<tr align=\"left\"><th><br>$dirname</th></tr>" ;
|
||||
olddirname=$dirname ;
|
||||
fi
|
||||
html+="<tr align=\"left\"><td><a href="$logname">$test</a>"
|
||||
backtrace="backtrace_$testname.txt"
|
||||
if test -f "${LOG_DIR}/$backtrace"; then
|
||||
html+=". Core dumped, backtrace is available <a href=\"$backtrace\">here</a>"
|
||||
html+=". Core dumped, backtrace is available <a href=\"$backtrace\">here</a>"
|
||||
fi
|
||||
html+="</td></tr>"
|
||||
logs_found=1
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
TESTS=$(make -f - 2>/dev/null <<EOF
|
||||
include Makefile
|
||||
all:
|
||||
@echo \$(TESTS)
|
||||
EOF
|
||||
)
|
||||
# All output will be collected here
|
||||
TESTSUNITPATH=$PWD
|
||||
|
||||
# "print_tests" returns relative paths to all the tests
|
||||
TESTS=$(make -s -C ../.. print_tests)
|
||||
|
||||
# All relative paths are based on the tree's root
|
||||
FSBASEDIR=$(realpath "$PWD/../../")
|
||||
|
||||
echo "-----------------------------------------------------------------";
|
||||
echo "Starting tests";
|
||||
|
@ -14,20 +16,36 @@ echo "-----------------------------------------------------------------";
|
|||
for i in $TESTS
|
||||
do
|
||||
echo "Testing $i" ;
|
||||
logfilename="log_run-tests_$i.html";
|
||||
./$i | tee >(ansi2html > $logfilename) ;
|
||||
|
||||
# Change folder to where the test is
|
||||
currenttestpath="$FSBASEDIR/$i"
|
||||
cd $(dirname "$currenttestpath")
|
||||
|
||||
# Tests are unique per module, so need to distinguish them by their directory
|
||||
relativedir=$(dirname "$i")
|
||||
echo "Relative dir is $relativedir"
|
||||
|
||||
file=$(basename -- "$currenttestpath")
|
||||
log="$TESTSUNITPATH/log_run-tests_${relativedir//\//!}!$file.html";
|
||||
|
||||
# Execute the test
|
||||
$currenttestpath | tee >(ansi2html > $log) ;
|
||||
exitstatus=${PIPESTATUS[0]} ;
|
||||
|
||||
if [ "0" -eq $exitstatus ] ; then
|
||||
rm $logfilename ;
|
||||
rm $log ;
|
||||
else
|
||||
echo "*** ./$i exit status is $exitstatus" ;
|
||||
if ls /cores/core.*.!drone!src!tests!unit!.libs!$i.* 1> /dev/null 2>&1; then
|
||||
echo "Coredump found";
|
||||
COREDUMP=$(ls /cores/core.*.!drone!src!tests!unit!.libs!$i.*) ;
|
||||
echo $COREDUMP;
|
||||
gdb -ex "set logging file backtrace_$i.txt" -ex "set logging on" -ex "set pagination off" -ex "bt" -ex "bt full" -ex "info threads" -ex "thread apply all bt" -ex "thread apply all bt full" -ex "quit" /drone/src/tests/unit/.libs/$i $COREDUMP ;
|
||||
corefilesearch=/cores/core.*.!drone!src!${relativedir//\//!}!.libs!$file.* ;
|
||||
echo $corefilesearch ;
|
||||
if ls $corefilesearch 1> /dev/null 2>&1; then
|
||||
echo "coredump found";
|
||||
coredump=$(ls $corefilesearch) ;
|
||||
echo $coredump;
|
||||
echo "set logging file $TESTSUNITPATH/backtrace_${i//\//!}.txt" ;
|
||||
gdb -ex "set logging file $TESTSUNITPATH/backtrace_${i//\//!}.txt" -ex "set logging on" -ex "set pagination off" -ex "bt full" -ex "bt" -ex "info threads" -ex "thread apply all bt" -ex "thread apply all bt full" -ex "quit" /drone/src/$relativedir/.libs/$file $coredump ;
|
||||
fi ;
|
||||
echo "*** $logfilename was saved" ;
|
||||
echo "*** $log was saved" ;
|
||||
fi ;
|
||||
echo "----------------" ;
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue