Skip to content

Commit

Permalink
Add job to run the sample and check for memory leak (#2071)
Browse files Browse the repository at this point in the history
* Add job to run the sample and check for memory leak

* Simulate a memory leak

* MEMALLOC instead of MALLOC

* Remove simulated memory leak

* Print the exit statuses in case of failure
  • Loading branch information
sirknightj authored Nov 1, 2024
1 parent 6ba8728 commit 499eca3
Showing 1 changed file with 89 additions and 12 deletions.
101 changes: 89 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
cmake .. -DBUILD_TEST=TRUE -DCOMPILER_WARNINGS=TRUE
make
- name: Run tests
run: |
run: |
cd build
./tst/webrtc_client_test
mac-os-build-gcc:
Expand All @@ -71,7 +71,7 @@ jobs:
cmake .. -DBUILD_TEST=TRUE -DCOMPILER_WARNINGS=TRUE
make
- name: Run tests
run: |
run: |
cd build
./tst/webrtc_client_test
mac-os-m1-build-clang:
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
sh -c 'cmake .. -DBUILD_TEST=TRUE -DCMAKE_C_COMPILER=$(brew --prefix llvm@15)/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++'
make
- name: Run tests
run: |
run: |
cd build
./tst/webrtc_client_test
static-build-mac:
Expand All @@ -124,7 +124,7 @@ jobs:
cmake .. -DBUILD_STATIC_LIBS=TRUE -DBUILD_TEST=TRUE
make
- name: Run tests
run: |
run: |
cd build
./tst/webrtc_client_test
address-sanitizer:
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
make
ulimit -c unlimited -S
- name: Run tests
run: |
run: |
cd build
timeout --signal=SIGABRT 60m ./tst/webrtc_client_test
undefined-behavior-sanitizer:
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
make
ulimit -c unlimited -S
- name: Run tests
run: |
run: |
cd build
timeout --signal=SIGABRT 60m ./tst/webrtc_client_test
# memory-sanitizer:
Expand Down Expand Up @@ -250,7 +250,7 @@ jobs:
make
ulimit -c unlimited -S
- name: Run tests
run: |
run: |
cd build
timeout --signal=SIGABRT 60m ./tst/webrtc_client_test
linux-gcc-4_4:
Expand Down Expand Up @@ -288,7 +288,7 @@ jobs:
make
ulimit -c unlimited -S
- name: Run tests
run: |
run: |
cd build
timeout --signal=SIGABRT 60m ./tst/webrtc_client_test
static-build-linux:
Expand Down Expand Up @@ -348,7 +348,7 @@ jobs:
make
ulimit -c unlimited -S
- name: Run tests
run: |
run: |
cd build
timeout --signal=SIGABRT 60m ./tst/webrtc_client_test
mbedtls-ubuntu-gcc-11:
Expand Down Expand Up @@ -382,7 +382,7 @@ jobs:
make
ulimit -c unlimited -S
- name: Run tests
run: |
run: |
cd build
timeout --signal=SIGABRT 60m ./tst/webrtc_client_test
Expand Down Expand Up @@ -448,7 +448,7 @@ jobs:
make
ulimit -c unlimited -S
- name: Run tests
run: |
run: |
cd build
timeout --signal=SIGABRT 60m ./tst/webrtc_client_test
sample-check:
Expand Down Expand Up @@ -530,7 +530,7 @@ jobs:
cmake .. -DBUILD_TEST=TRUE
make
- name: Run tests
run: |
run: |
cd build
timeout --signal=SIGABRT 60m ./tst/webrtc_client_test
windows-msvc-openssl:
Expand Down Expand Up @@ -668,3 +668,80 @@ jobs:
mkdir build && cd build
cmake .. -DBUILD_OPENSSL=TRUE -DBUILD_OPENSSL_PLATFORM=linux-generic32 -DBUILD_LIBSRTP_HOST_PLATFORM=x86_64-unknown-linux-gnu -DBUILD_LIBSRTP_DESTINATION_PLATFORM=arm-unknown-linux-uclibcgnueabi
make
valgrind-check:
runs-on: ubuntu-latest
env:
AWS_KVS_LOG_LEVEL: 7
permissions:
id-token: write
contents: read
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Install deps
run: |
sudo apt clean && sudo apt update
sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6'
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ jammy main'
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ jammy universe'
sudo apt-get -q update
sudo apt-get -y install libcurl4-openssl-dev valgrind
- name: Build repository
run: |
mkdir build && cd build
cmake .. -DUSE_OPENSSL=OFF -DUSE_MBEDTLS=ON
make
ulimit -c unlimited -S
- name: Run tests
run: |
cd build
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-master.txt ./samples/kvsWebrtcClientMaster demo-channel-gh-actions &
PID_MASTER=$!
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-viewer.txt ./samples/kvsWebrtcClientViewer demo-channel-gh-actions &
PID_VIEWER=$!
# Wait for processes to run initially
sleep 30 # Wait 30s
# Send SIGINT (2) to both processes
kill -2 $PID_VIEWER
sleep 30
kill -2 $PID_MASTER
# Start a background task to enforce a timeout for graceful shutdown
(
sleep 10
kill -9 $PID_MASTER 2>/dev/null
kill -9 $PID_VIEWER 2>/dev/null
) &
wait $PID_MASTER
EXIT_STATUS_MASTER=$?
wait $PID_VIEWER
EXIT_STATUS_VIEWER=$?
# Check exit statuses to determine if the interrupt was successful
if [ $EXIT_STATUS_MASTER -ne 0 ] || [ $EXIT_STATUS_VIEWER -ne 0 ]; then
echo "Process did not exit gracefully."
echo "Master exit code: $EXIT_STATUS_MASTER"
echo "Viewer exit code: $EXIT_STATUS_VIEWER"
exit 1
else
echo "Processes exited successfully."
fi
# Check for memory leaks in Valgrind output files
if grep "All heap blocks were freed -- no leaks are possible" valgrind-master.txt && grep "All heap blocks were freed -- no leaks are possible" valgrind-viewer.txt; then
echo "No memory leaks detected."
else
echo "Memory leaks detected."
exit 1
fi

0 comments on commit 499eca3

Please sign in to comment.