[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
|
- cat /proc/sys/kernel/core_pattern
|
||||||
- ./bootstrap.sh -j
|
- ./bootstrap.sh -j
|
||||||
- echo "applications/mod_test" >> modules.conf
|
- 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
|
- ./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
|
- 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
|
- chmod +x build.sh
|
||||||
|
@ -45,6 +49,6 @@ trigger:
|
||||||
- push
|
- push
|
||||||
---
|
---
|
||||||
kind: signature
|
kind: signature
|
||||||
hmac: 5ebcc916118f95811470ed7e622a2acb71e84790e33f9b172c04fe3e119d78fe
|
hmac: d43f842f682df8328dc4cfbf16051bf8a8e481a051b63349b444447962709435
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
|
@ -3,17 +3,24 @@
|
||||||
echo "Collecting test logs"
|
echo "Collecting test logs"
|
||||||
LOG_DIR=./logs
|
LOG_DIR=./logs
|
||||||
html="<html><h3>There are failed unit-tests:</h3><table>"
|
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 | sort)
|
||||||
logs=$(find $LOG_DIR -type f -iname "*.html" -print)
|
|
||||||
logs_found=0
|
logs_found=0
|
||||||
|
olddirname=""
|
||||||
for name in $logs
|
for name in $logs
|
||||||
do
|
do
|
||||||
logname=$(basename $name)
|
logname=$(basename $name)
|
||||||
testname=$(echo $logname | awk -F 'log_run-tests_' '{print $2}' | awk -F '.html' '{print $1}')
|
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"
|
backtrace="backtrace_$testname.txt"
|
||||||
if test -f "${LOG_DIR}/$backtrace"; then
|
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
|
fi
|
||||||
html+="</td></tr>"
|
html+="</td></tr>"
|
||||||
logs_found=1
|
logs_found=1
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
TESTS=$(make -f - 2>/dev/null <<EOF
|
# All output will be collected here
|
||||||
include Makefile
|
TESTSUNITPATH=$PWD
|
||||||
all:
|
|
||||||
@echo \$(TESTS)
|
# "print_tests" returns relative paths to all the tests
|
||||||
EOF
|
TESTS=$(make -s -C ../.. print_tests)
|
||||||
)
|
|
||||||
|
# All relative paths are based on the tree's root
|
||||||
|
FSBASEDIR=$(realpath "$PWD/../../")
|
||||||
|
|
||||||
echo "-----------------------------------------------------------------";
|
echo "-----------------------------------------------------------------";
|
||||||
echo "Starting tests";
|
echo "Starting tests";
|
||||||
|
@ -14,20 +16,36 @@ echo "-----------------------------------------------------------------";
|
||||||
for i in $TESTS
|
for i in $TESTS
|
||||||
do
|
do
|
||||||
echo "Testing $i" ;
|
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]} ;
|
exitstatus=${PIPESTATUS[0]} ;
|
||||||
|
|
||||||
if [ "0" -eq $exitstatus ] ; then
|
if [ "0" -eq $exitstatus ] ; then
|
||||||
rm $logfilename ;
|
rm $log ;
|
||||||
else
|
else
|
||||||
echo "*** ./$i exit status is $exitstatus" ;
|
echo "*** ./$i exit status is $exitstatus" ;
|
||||||
if ls /cores/core.*.!drone!src!tests!unit!.libs!$i.* 1> /dev/null 2>&1; then
|
corefilesearch=/cores/core.*.!drone!src!${relativedir//\//!}!.libs!$file.* ;
|
||||||
echo "Coredump found";
|
echo $corefilesearch ;
|
||||||
COREDUMP=$(ls /cores/core.*.!drone!src!tests!unit!.libs!$i.*) ;
|
if ls $corefilesearch 1> /dev/null 2>&1; then
|
||||||
echo $COREDUMP;
|
echo "coredump found";
|
||||||
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 ;
|
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 ;
|
fi ;
|
||||||
echo "*** $logfilename was saved" ;
|
echo "*** $log was saved" ;
|
||||||
fi ;
|
fi ;
|
||||||
echo "----------------" ;
|
echo "----------------" ;
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue