mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-01-25 02:07:54 +00:00
[Unit-tests] Implement module tests in Drone CI
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user