From ef3bd2d8c30f0fab0220a88629b4e3be761542e0 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Wed, 9 Oct 2024 00:34:22 +0800 Subject: [PATCH 1/3] [core] fix base64 decoded size when encoded string contains padding = --- src/switch_utils.c | 2 +- tests/unit/switch_utils.c | 43 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/switch_utils.c b/src/switch_utils.c index aa3fc74cae..1293ca3fbd 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -1076,7 +1076,7 @@ SWITCH_DECLARE(switch_size_t) switch_b64_decode(const char *in, char *out, switc l64[(int) switch_b64_table[i]] = (char) i; } - for (ip = in; ip && *ip; ip++) { + for (ip = in; ip && *ip && (*ip != '='); ip++) { c = l64[(int) *ip]; if (c == -1) { continue; diff --git a/tests/unit/switch_utils.c b/tests/unit/switch_utils.c index 1fc291ea96..391ec6e8e6 100644 --- a/tests/unit/switch_utils.c +++ b/tests/unit/switch_utils.c @@ -80,6 +80,49 @@ FST_TEST_BEGIN(b64) } FST_TEST_END() +FST_TEST_BEGIN(b64_pad2) +{ + switch_size_t size; + char str[] = {0, 0, 0, 0}; + unsigned char b64_str[128]; + char decoded_str[128]; + int i; + switch_status_t status = switch_b64_encode((unsigned char *)str, sizeof(str), b64_str, sizeof(b64_str)); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "b64_str: %s\n", b64_str); + fst_check(status == SWITCH_STATUS_SUCCESS); + fst_check_string_equals((const char *)b64_str, "AAAAAA=="); + + size = switch_b64_decode((const char *)b64_str, decoded_str, sizeof(decoded_str)); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "decoded_str: %s\n", decoded_str); + fst_check_string_equals(decoded_str, str); + fst_check(size == sizeof(str) + 1); + for (i = 0; i < sizeof(str); i++) { + fst_check(decoded_str[i] == str[i]); + } +} +FST_TEST_END() + +FST_TEST_BEGIN(b64_pad1) +{ + switch_size_t size; + char str[] = {0, 0, 0, 0, 0}; + unsigned char b64_str[128]; + char decoded_str[128]; + int i; + switch_status_t status = switch_b64_encode((unsigned char *)str, sizeof(str), b64_str, sizeof(b64_str)); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "b64_str: %s\n", b64_str); + fst_check(status == SWITCH_STATUS_SUCCESS); + fst_check_string_equals((const char *)b64_str, "AAAAAAA="); + + size = switch_b64_decode((const char *)b64_str, decoded_str, sizeof(decoded_str)); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "decoded_str: %s\n", decoded_str); + fst_check_string_equals(decoded_str, str); + fst_check(size == sizeof(str) + 1); + for (i = 0; i < sizeof(str); i++) { + fst_check(decoded_str[i] == str[i]); + } +} +FST_TEST_END() FST_SUITE_END() From b4ebd0936c756f32a5e65ec181429a431dff4505 Mon Sep 17 00:00:00 2001 From: Jakub Karolczyk Date: Fri, 11 Oct 2024 14:16:02 +0100 Subject: [PATCH 2/3] [core, mod_sofia] Fix codec set deadlock --- src/include/switch_core.h | 11 +++++++++++ src/mod/endpoints/mod_sofia/mod_sofia.c | 13 ++++++++++++- src/switch_core_codec.c | 21 +++++++++++++++++++++ src/switch_core_media.c | 6 ++---- src/switch_core_session.c | 4 ++++ 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index e4c615941d..ff04fa0954 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -1822,6 +1822,17 @@ SWITCH_DECLARE(void) switch_core_session_unlock_codec_write(_In_ switch_core_ses SWITCH_DECLARE(void) switch_core_session_lock_codec_read(_In_ switch_core_session_t *session); SWITCH_DECLARE(void) switch_core_session_unlock_codec_read(_In_ switch_core_session_t *session); +/*! + \brief Lock codec read mutex and codec write mutex using trylock in an infinite loop + \param session session to lock the codec in +*/ +SWITCH_DECLARE(void) switch_core_codec_lock_full(switch_core_session_t *session); + +/*! + \brief Unlock codec read mutex and codec write mutex + \param session session to unlock the codec in +*/ +SWITCH_DECLARE(void) switch_core_codec_unlock_full(switch_core_session_t *session); SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); SWITCH_DECLARE(switch_status_t) switch_core_session_get_real_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index c5ce6e3855..c41ed9b2e3 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1339,6 +1339,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if (msg->message_id == SWITCH_MESSAGE_INDICATE_SIGNAL_DATA) { sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) msg->pointer_arg; + + switch_core_session_lock_codec_write(session); switch_mutex_lock(tech_pvt->sofia_mutex); if (switch_core_session_in_thread(session)) { de->session = session; @@ -1346,8 +1348,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi sofia_process_dispatch_event(&de); - switch_mutex_unlock(tech_pvt->sofia_mutex); + switch_core_session_unlock_codec_write(session); goto end; } @@ -1363,6 +1365,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi /* ones that do not need to lock sofia mutex */ switch (msg->message_id) { + case SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY: + case SWITCH_MESSAGE_RESAMPLE_EVENT: + goto end; case SWITCH_MESSAGE_INDICATE_KEEPALIVE: { if (msg->numeric_arg) { @@ -1523,6 +1528,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } /* ones that do need to lock sofia mutex */ + switch_core_session_lock_codec_write(session); switch_mutex_lock(tech_pvt->sofia_mutex); if (switch_channel_down(channel) || sofia_test_flag(tech_pvt, TFLAG_BYE)) { @@ -1557,7 +1563,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi tech_pvt->proxy_refer_uuid = (char *)msg->string_array_arg[0]; } else if (!switch_channel_var_true(tech_pvt->channel, "sip_refer_continue_after_reply")) { switch_mutex_unlock(tech_pvt->sofia_mutex); + switch_core_session_unlock_codec_write(session); sofia_wait_for_reply(tech_pvt, 9999, 10); + switch_core_session_lock_codec_write(session); switch_mutex_lock(tech_pvt->sofia_mutex); if ((var = switch_channel_get_variable(tech_pvt->channel, "sip_refer_reply"))) { @@ -2391,6 +2399,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi /* Unlock the session signal to allow the ack to make it in */ // Maybe we should timeout? switch_mutex_unlock(tech_pvt->sofia_mutex); + switch_core_session_unlock_codec_write(session); while (switch_channel_ready(channel) && !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) { switch_ivr_parse_all_events(session); @@ -2398,6 +2407,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } /* Regain lock on sofia */ + switch_core_session_lock_codec_write(session); switch_mutex_lock(tech_pvt->sofia_mutex); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n"); @@ -2706,6 +2716,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi //} switch_mutex_unlock(tech_pvt->sofia_mutex); + switch_core_session_unlock_codec_write(session); end: diff --git a/src/switch_core_codec.c b/src/switch_core_codec.c index e5c22cd610..5cedbed6e0 100644 --- a/src/switch_core_codec.c +++ b/src/switch_core_codec.c @@ -59,6 +59,27 @@ SWITCH_DECLARE(void) switch_core_session_unset_read_codec(switch_core_session_t switch_mutex_unlock(session->codec_read_mutex); } +SWITCH_DECLARE(void) switch_core_codec_lock_full(switch_core_session_t *session) +{ + do { + if (switch_mutex_trylock(session->codec_write_mutex) == SWITCH_STATUS_SUCCESS) { + if (switch_mutex_trylock(session->codec_read_mutex) == SWITCH_STATUS_SUCCESS) { + return; + } + + switch_mutex_unlock(session->codec_write_mutex); + } + + switch_cond_next(); + } while (1); +} + +SWITCH_DECLARE(void) switch_core_codec_unlock_full(switch_core_session_t *session) +{ + switch_mutex_unlock(session->codec_read_mutex); + switch_mutex_unlock(session->codec_write_mutex); +} + SWITCH_DECLARE(void) switch_core_session_lock_codec_write(switch_core_session_t *session) { switch_mutex_lock(session->codec_write_mutex); diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 58ef94a53e..de5d0eff74 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -3601,8 +3601,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_ switch_assert(session); - switch_core_session_lock_codec_write(session); - switch_core_session_lock_codec_read(session); + switch_core_codec_lock_full(session); switch_mutex_lock(session->codec_init_mutex); @@ -3756,8 +3755,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_ switch_mutex_unlock(session->codec_init_mutex); - switch_core_session_unlock_codec_read(session); - switch_core_session_unlock_codec_write(session); + switch_core_codec_unlock_full(session); return status; } diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 61aa500070..94944faa2f 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -1392,6 +1392,8 @@ SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session, s { switch_channel_t *channel = switch_core_session_get_channel(session); + switch_core_codec_lock_full(session); + if (reset_read_codec) { switch_core_session_set_read_codec(session, NULL); if (session->sdata && switch_core_codec_ready(&session->sdata->codec)) { @@ -1425,6 +1427,8 @@ SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session, s switch_clear_flag(session, SSF_WARN_TRANSCODE); switch_ivr_deactivate_unicast(session); switch_channel_clear_flag(channel, CF_BREAK); + + switch_core_codec_unlock_full(session); } From 07283ac104e4d43fd6cdadb10c95f9df9e249408 Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Thu, 25 Jul 2024 19:47:30 +0200 Subject: [PATCH 3/3] [GHA] Add tests. --- .github/workflows/ci.yml | 94 ++++++++++++++++++++ .github/workflows/unit-test.yml | 111 ++++++++++++++++++++++++ scan_build.sh | 28 ++++++ src/mod/endpoints/mod_sofia/Makefile.am | 3 +- tests/unit/run-tests.mk | 5 ++ tests/unit/run-tests.sh | 37 ++++---- tests/unit/test.sh | 12 ++- 7 files changed, 269 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/unit-test.yml create mode 100755 scan_build.sh create mode 100644 tests/unit/run-tests.mk diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..d16f1a987a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,94 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + types: + - opened + - synchronize + +jobs: + unit-tests_1: + name: "unit-tests (group 1)" + uses: ./.github/workflows/unit-test.yml + with: + total-groups: 2 + current-group: 1 + secrets: inherit + + unit-tests_2: + name: "unit-tests (group 2)" + uses: ./.github/workflows/unit-test.yml + with: + total-groups: 2 + current-group: 2 + secrets: inherit + + scan-build: + runs-on: ubuntu-latest + container: + image: signalwire/freeswitch-public-base:bookworm + credentials: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + options: --privileged + env: + REPOTOKEN: ${{ secrets.REPOTOKEN }} + DEBIAN_FRONTEND: noninteractive + + steps: + - name: Install dependencies + shell: bash + run: | + echo "machine freeswitch.signalwire.com password $REPOTOKEN" > /etc/apt/auth.conf && \ + apt-get update && \ + apt-get -y remove \ + libsofia-sip-ua0 \ + libspandsp-dev && \ + apt-get -y install \ + autoconf \ + libsofia-sip-ua-dev \ + libspandsp3-dev && \ + rm -rf /etc/apt/auth.conf + + - name: Checkout code + uses: actions/checkout@v4 + with: + path: /__w/freeswitch/freeswitch + + - name: Bootstrap + shell: bash + working-directory: /__w/freeswitch/freeswitch + run: | + ./bootstrap.sh -j || exit 1 + + - name: Scan-build FreeSwitch + shell: bash + working-directory: /__w/freeswitch/freeswitch + run: | + cp build/modules.conf.most modules.conf && \ + echo 'codecs/mod_openh264' >> modules.conf && \ + sed -i \ + -e '/mod_mariadb/s/^#//g' \ + -e '/mod_v8/s/^#//g' \ + -e '/mod_ilbc/s/^/#/g' \ + -e '/mod_isac/s/^/#/g' \ + -e '/mod_mp4/s/^/#/g' \ + -e '/mod_mongo/s/^/#/g' \ + -e '/mod_pocketsphinx/s/^/#/g' \ + -e '/mod_sangoma_codec/s/^/#/g' \ + -e '/mod_siren/s/^/#/g' \ + -e '/mod_avmd/s/^/#/g' \ + -e '/mod_basic/s/^/#/g' \ + -e '/mod_cdr_mongodb/s/^/#/g' \ + -e '/mod_cv/s/^/#/g' \ + -e '/mod_erlang_event/s/^/#/g' \ + -e '/mod_perl/s/^/#/g' \ + -e '/mod_rtmp/s/^/#/g' \ + -e '/mod_unimrcp/s/^/#/g' \ + -e '/mod_xml_rpc/s/^/#/g' \ + modules.conf && \ + ./configure && \ + ./scan_build.sh diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000000..8ff0d832a7 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,111 @@ +name: Unit tests + +on: + workflow_call: + inputs: + total-groups: + description: 'Total number of test groups' + required: true + type: number + current-group: + description: 'Current test group number' + required: true + type: number + +jobs: + unit-tests: + runs-on: ubuntu-latest + container: + image: signalwire/freeswitch-public-base:bookworm + credentials: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + options: --privileged + env: + DEBIAN_FRONTEND: noninteractive + ASAN_OPTIONS: log_path=stdout:disable_coredump=0:unmap_shadow_on_exit=1:fast_unwind_on_malloc=0 + + steps: + - name: Override core_pattern + shell: bash + run: | + cat /proc/sys/kernel/core_pattern + echo '/cores/core.%s.%E.%e.%p.%t' > /proc/sys/kernel/core_pattern + cat /proc/sys/kernel/core_pattern + + - name: Install dependencies + shell: bash + env: + REPOTOKEN: ${{ secrets.REPOTOKEN }} + run: | + echo "machine freeswitch.signalwire.com password $REPOTOKEN" > /etc/apt/auth.conf && \ + apt-get update && \ + apt-get -y remove \ + libsofia-sip-ua0 \ + libspandsp-dev && \ + apt-get -y install \ + libspandsp3-dev && \ + rm -rf /etc/apt/auth.conf + + - name: Checkout code + uses: actions/checkout@v4 + with: + path: /__w/freeswitch/freeswitch + + - name: Bootstrap + shell: bash + working-directory: /__w/freeswitch/freeswitch + run: | + ./bootstrap.sh -j || exit 1 + + - name: Checkout Sofia-Sip + uses: actions/checkout@v4 + with: + repository: freeswitch/sofia-sip + path: /__w/freeswitch/freeswitch/sofia-sip + + - name: Build sofia-sip + shell: bash + working-directory: /__w/freeswitch/freeswitch/sofia-sip + run: | + ./autogen.sh && \ + ./configure.gnu && \ + make -j$(nproc --all) install + + - name: Build FreeSwitch + shell: bash + working-directory: /__w/freeswitch/freeswitch + run: | + echo 'codecs/mod_openh264' >> modules.conf && \ + sed -i \ + -e '/applications\/mod_http_cache/s/^#//g' \ + -e '/event_handlers\/mod_rayo/s/^#//g' \ + -e '/formats\/mod_opusfile/s/^#//g' \ + -e '/languages\/mod_lua/s/^#//g' \ + modules.conf && \ + ./configure \ + --enable-address-sanitizer \ + --enable-fake-dlclose && \ + make -j$(nproc --all) |& tee ./unit-tests-build-result.txt + + echo ${PIPESTATUS[0]} > ./build-status.txt + if ! test "$(cat ./build-status.txt | tr -d '[:space:]')" -eq 0; then + exit "$(cat ./build-status.txt | tr -d '[:space:]')" + fi + make install + + - name: Run tests + shell: bash + working-directory: /__w/freeswitch/freeswitch/tests/unit + run: | + ./run-tests.sh ${{ inputs.total-groups }} ${{ inputs.current-group }} + mkdir logs && (mv log_run-tests_*.html logs || true) && (mv backtrace_*.txt logs || true) + ./collect-test-logs.sh + + - name: Notify result + if: failure() + uses: signalwire/actions-template/.github/actions/notify-ci-result@main + with: + for: "run_tests" + test_logs_path: /__w/freeswitch/freeswitch/tests/unit + test_artifacts_suffix: "-${{ inputs.current-group }}" diff --git a/scan_build.sh b/scan_build.sh new file mode 100755 index 0000000000..200cc2d2df --- /dev/null +++ b/scan_build.sh @@ -0,0 +1,28 @@ +#!/bin/bash +mkdir -p scan-build +scan-build-14 --force-analyze-debug-code -o ./scan-build/ make -j`nproc --all` |& tee ./scan-build-result.txt +exitstatus=${PIPESTATUS[0]} +echo "*** Exit status is $exitstatus" +export SubString="scan-build: No bugs found" +export COMPILATION_FAILED="false" +export BUGS_FOUND="false" +if [[ "0" != "$exitstatus" ]] ; then + export COMPILATION_FAILED="true" + echo MESSAGE="compilation failed" >> $GITHUB_OUTPUT +fi +export RESULTFILE="$PWD/scan-build-result.txt" +# cat $RESULTFILE +if ! grep -sq "$SubString" $RESULTFILE; then + export BUGS_FOUND="true" + echo MESSAGE="found bugs" >> $GITHUB_OUTPUT +fi +export REPORT=$PWD/`find scan-build* -mindepth 1 -type d` +echo "COMPILATION_FAILED: $COMPILATION_FAILED" +echo "BUGS_FOUND: $BUGS_FOUND" +echo "COMPILATION_FAILED=$COMPILATION_FAILED" >> $GITHUB_OUTPUT +echo "BUGS_FOUND=$BUGS_FOUND" >> $GITHUB_OUTPUT +echo "REPORT=$REPORT" >> $GITHUB_OUTPUT +if [[ "0" != "$exitstatus" ]] || ! grep -sq "$SubString" $RESULTFILE; then + exit 1 +fi +exit 0 diff --git a/src/mod/endpoints/mod_sofia/Makefile.am b/src/mod/endpoints/mod_sofia/Makefile.am index c813f9f597..3a5d295ddb 100644 --- a/src/mod/endpoints/mod_sofia/Makefile.am +++ b/src/mod/endpoints/mod_sofia/Makefile.am @@ -38,7 +38,8 @@ test_sipp_based_tests_CFLAGS = $(AM_CFLAGS) $(SOFIA_SIP_CFLAGS) -DSWITCH_TEST_BA test_sipp_based_tests_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS) test_sipp_based_tests_LDADD = libsofiamod.la $(SOFIA_SIP_LIBS) -TESTS = test/test_sofia_funcs.sh test/test_nuafail test/test_run_sipp.sh +TESTS = test/test_sofia_funcs.sh test/test_nuafail +#TESTS += test/test_run_sipp.sh if ISMAC mod_sofia_la_LDFLAGS += -framework CoreFoundation -framework SystemConfiguration diff --git a/tests/unit/run-tests.mk b/tests/unit/run-tests.mk new file mode 100644 index 0000000000..8c260cfa2a --- /dev/null +++ b/tests/unit/run-tests.mk @@ -0,0 +1,5 @@ +.DEFAULT: + ./test.sh "$@" + +all: $(TEST_LIST) + diff --git a/tests/unit/run-tests.sh b/tests/unit/run-tests.sh index bda6a32571..559dec4a8f 100755 --- a/tests/unit/run-tests.sh +++ b/tests/unit/run-tests.sh @@ -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!" \ No newline at end of file +echo "Timing results:" +cat test_times.log + +echo "Done running tests!" diff --git a/tests/unit/test.sh b/tests/unit/test.sh index 89711ca99b..08de6ccd99 100755 --- a/tests/unit/test.sh +++ b/tests/unit/test.sh @@ -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 ;