mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-17 06:48:33 +00:00
[Unit-tests] Implement module tests in Drone CI
This commit is contained in:
1 parent
b7bc78ec6f
commit
6d31e846a8
3 files changed
+50
-21
No files matched your search
+33
-15
@@ -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