Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak action #321

Merged
merged 4 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/check-address-sanitizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Check for memory issues

# This action will compile netplan with ASAN (address sanitizer) and run
# all the C unit tests and call the generator for every single file in the
# examples directory.
# The job will fail if a memory issue is detected by ASAN.

on:
push:
branches: [ main ]
pull_request:
branches: [ '**' ]

jobs:
memory-sanitizer:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2

- name: Install build depends
run: |
echo "APT::Get::Always-Include-Phased-Updates \"true\";" | sudo tee /etc/apt/apt.conf.d/90phased-updates
sudo sed -i '/deb-src/s/^# //' /etc/apt/sources.list
sudo apt update
sudo apt -y install python3-rich python3-coverage python3-pytest python3-pytest-cov curl meson gcovr expect libcmocka-dev
sudo apt -y build-dep netplan.io

- name: Run unit tests
run: |
unbuffer ./tools/run_asan.sh

3 changes: 3 additions & 0 deletions examples/bonding.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
network:
version: 2
renderer: networkd
ethernets:
enp3s0: {}
enp4s0: {}
bonds:
bond0:
dhcp4: yes
Expand Down
11 changes: 6 additions & 5 deletions examples/direct_connect_gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ network:
version: 2
renderer: networkd
ethernets:
addresses: [ "10.10.10.1/24" ]
routes:
- to: 0.0.0.0/0
via: 9.9.9.9
on-link: true
eth0:
addresses: [ "10.10.10.1/24" ]
routes:
- to: 0.0.0.0/0
via: 9.9.9.9
on-link: true
11 changes: 6 additions & 5 deletions examples/direct_connect_gateway_ipv6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ network:
version: 2
renderer: networkd
ethernets:
addresses: [ "2001:cafe:face:beef::dead:dead/64" ]
routes:
- to: "::/0"
via: "2001:cafe:face::1"
on-link: true
eth0:
addresses: [ "2001:cafe:face:beef::dead:dead/64" ]
routes:
- to: "::/0"
via: "2001:cafe:face::1"
on-link: true
2 changes: 1 addition & 1 deletion examples/static_singlenic_multiip_multigateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ network:
metric: 100
- to: 0.0.0.0/0
via: 11.0.0.1
metric: 100
metric: 200
2 changes: 2 additions & 0 deletions examples/wireguard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ network:
routes:
- to: default
via: 10.10.10.21
metric: 100
wg1: #client
mode: wireguard
addresses: [20.20.20.10/24]
Expand All @@ -29,3 +30,4 @@ network:
routes:
- to: default
via: 20.20.20.11
metric: 200
26 changes: 26 additions & 0 deletions tools/run_asan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e
set -x

BUILDDIR="_leakcheckbuild"

meson setup ${BUILDDIR} -Db_sanitize=address,undefined
meson compile -C ${BUILDDIR} --verbose

TESTS=$(find ${BUILDDIR}/tests/ctests/ -executable -type f)
for test in ${TESTS}
do
./${test}
done

mkdir -p ${BUILDDIR}/fakeroot/{etc/netplan,run}
export LD_LIBRARY_PATH="${BUILDDIR}/src"

for yaml in examples/*.yaml
do
cp ${yaml} ${BUILDDIR}/fakeroot/etc/netplan/
chmod 600 ${BUILDDIR}/fakeroot/etc/netplan/${yaml##*/}
./${BUILDDIR}/src/generate --root-dir ${BUILDDIR}/fakeroot
rm ${BUILDDIR}/fakeroot/etc/netplan/${yaml##*/}
done