[GHA] Add tests.

This commit is contained in:
s3rj1k
2024-07-25 19:47:30 +02:00
parent b4ebd0936c
commit 07283ac104
7 changed files with 269 additions and 21 deletions

5
tests/unit/run-tests.mk Normal file
View File

@@ -0,0 +1,5 @@
.DEFAULT:
./test.sh "$@"
all: $(TEST_LIST)

View File

@@ -3,26 +3,27 @@
# "print_tests" returns relative paths to all the tests
TESTS=$(make -s -C ../.. print_tests)
chunks=${1:-1}
chunk_number=${2:-1}
IFS=$'\n' read -d '' -r -a lines <<< "$TESTS"
result=""
for ((i=chunk_number-1; i<${#lines[@]}; i+=chunks))
do
result+="${lines[$i]}"$'\n'
done
TESTS=$result
echo "-----------------------------------------------------------------";
echo "Starting tests";
echo "Starting tests on $(nproc --all) processors";
echo "Tests found: ${TESTS}";
echo "-----------------------------------------------------------------";
echo "Starting" > pids.txt
for i in $TESTS
do
echo "Testing $i" ;
./test.sh "$i" &
pid=($!)
pids+=($pid)
echo "$pid $i" >> pids.txt
echo "----------------" ;
done
for pid in "${pids[@]}"
do
echo "$pid waiting" >> pids.txt
wait "$pid"
echo "$pid finished" >> pids.txt
done
make -f run-tests.mk TEST_LIST=$TESTS
echo "Done running tests!"
echo "Timing results:"
cat test_times.log
echo "Done running tests!"

View File

@@ -1,11 +1,16 @@
#!/bin/bash
start_time=$(date +%s)
# All output will be collected here
TESTSUNITPATH=$PWD
# All relative paths are based on the tree's root
FSBASEDIR=$(realpath "$PWD/../../")
ulimit -c unlimited
ulimit -a
i=$1
echo "----------------------------------" ;
@@ -28,20 +33,23 @@ echo "Start executing $currenttestpath"
$currenttestpath 2>&1 | tee >(ansi2html > $log) ;
exitstatus=${PIPESTATUS[0]} ;
echo "End executing $currenttestpath"
end_time=$(date +%s)
duration=$((end_time - start_time))
echo "Test $1 took $duration seconds" >> test_times.log
echo "Exit status is $exitstatus"
if [ "0" -eq $exitstatus ] ; then
rm $log ;
else
echo "*** ./$i exit status is $exitstatus" ;
corefilesearch=/cores/core.*.!drone!src!${relativedir//\//!}!.libs!$file.* ;
corefilesearch=/cores/core.*.!__w!freeswitch!freeswitch!${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 ;
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" /__w/freeswitch/freeswitch/$relativedir/.libs/$file $coredump ;
fi ;
echo "*** $log was saved" ;
fi ;