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

Adding dynamic analysis #61

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
55 changes: 41 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,62 @@ jobs:
build-and-test:
runs-on: ubuntu-latest
container:
image: ${{ matrix.distro.image }}
image: ${{ matrix.distro[0] }}
env:
LDFLAGS: ${{ matrix.linking.ldflags }}
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
LDFLAGS: ${{ matrix.link-n-sane[0] }}
CC: ${{ matrix.compiler[0] }}
CXX: ${{ matrix.compiler[1] }}
options: --privileged
strategy:
fail-fast: false
matrix:
distro:
- { image: "debian:testing", update_cmd: "apt update", install_cmd: "apt install -y" }
- { image: "alpine:3.20", update_cmd: "true", install_cmd: "apk add --no-cache", packages: "g++ musl-dev" }
- { image: "alpine:edge", update_cmd: "true", install_cmd: "apk add --no-cache", packages: "g++ musl-dev" }
- [ "debian:testing", "apt update", "apt install -y" ]
- [ "alpine:3.20", "true", "apk add --no-cache", "g++ musl-dev compiler-rt" ]
- [ "alpine:edge", "true", "apk add --no-cache", "g++ musl-dev compiler-rt" ]
compiler:
- { cc: gcc, cxx: g++ }
- { cc: clang, cxx: clang++ }
linking:
- { ldflags: "" }
- { ldflags: "-static" }
- [ gcc, g++ ]
- [ clang, clang++ ]
link-n-sane:
- [ "", "none" ]
- [ "-static", "none" ]
- [ "", "address,undefined" ]
- [ "", "thread" ]
- [ "", "memory" ]
- [ "", "leak" ]
options:
- { pcie_opt: "true" }
- { pcie_opt: "false" }
exclude:
- link-n-sane: [ "", "memory" ]
compiler: [ gcc, g++ ]
- link-n-sane: [ "", "leak" ]
distro: [ "alpine:3.20", "true", "apk add --no-cache", "g++ musl-dev compiler-rt" ]
- link-n-sane: [ "", "leak" ]
distro: [ "alpine:edge", "true", "apk add --no-cache", "g++ musl-dev compiler-rt" ]
- link-n-sane: [ "", "thread" ]
distro: [ "alpine:3.20", "true", "apk add --no-cache", "g++ musl-dev compiler-rt" ]
- link-n-sane: [ "", "thread" ]
distro: [ "alpine:edge", "true", "apk add --no-cache", "g++ musl-dev compiler-rt" ]
- link-n-sane: [ "", "memory" ]
distro: [ "alpine:3.20", "true", "apk add --no-cache", "g++ musl-dev compiler-rt" ]
- link-n-sane: [ "", "memory" ]
distro: [ "alpine:edge", "true", "apk add --no-cache", "g++ musl-dev compiler-rt" ]
- link-n-sane: [ "", "address,undefined" ]
distro: [ "alpine:3.20", "true", "apk add --no-cache", "g++ musl-dev compiler-rt" ]
- link-n-sane: [ "", "address,undefined" ]
distro: [ "alpine:edge", "true", "apk add --no-cache", "g++ musl-dev compiler-rt" ]
steps:
- name: Install dependencies
run: ${{ matrix.distro.update_cmd }} && ${{ matrix.distro.install_cmd }} git meson ${{ matrix.distro.packages }} ${{ matrix.compiler.cc }}
run: ${{ matrix.distro[1] }} && ${{ matrix.distro[2] }} git meson ${{ matrix.distro[3] }} ${{ matrix.compiler[0] }}
- uses: actions/checkout@v4
with:
submodules: true
- name: Configure
run: meson setup --buildtype release --werror -Dpcie_opt=${{ matrix.options.pcie_opt }} build || cat build/meson-logs/meson-log.txt /nonexistent
run: meson setup --buildtype release --debug --werror -Dpcie_opt=${{ matrix.options.pcie_opt }} -Db_sanitize=${{ matrix.link-n-sane[1] }} build || cat build/meson-logs/meson-log.txt /nonexistent
- name: Build
run: ninja -C build
- name: Allow tests to run
run: echo 1 > /proc/sys/fs/suid_dumpable
- name: Run tests
run: ninja -C build test
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ catch2 = dependency('catch2-with-main', fallback: 'catch2')

header_dir = 'uhal'

test_env = ['LSAN_OPTIONS=use_tls=0:verbosity=1:log_threads=1']

subdir('include')
subdir('util')
subdir('templates')
Expand Down
3 changes: 3 additions & 0 deletions util/tests/copy-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
#include <cstring>
#include <iostream>

#include "defer.h"
#include "pcie-open.h"
#include "test-util.h"

int main()
{
struct pcie_bars bars;
dummy_dev_open(bars);
defer _(nullptr, [&bars](...){dev_close(bars);});

const size_t s = bars.sizes[1] / sizeof(uint32_t);
uint32_t *p = reinterpret_cast<uint32_t *>(const_cast<void *>(bars.bar2));
Expand Down
2 changes: 1 addition & 1 deletion util/tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ tests = [
]
foreach test_name : tests
exe = executable(test_name, test_name + '.cc', dependencies: [utilities, catch2])
test(test_name, exe)
test(test_name, exe, env: test_env)
endforeach
3 changes: 2 additions & 1 deletion util/tests/test-util.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <sys/mman.h>
#include <stdexcept>

#include "test-util.h"
Expand All @@ -18,7 +19,7 @@ void dummy_dev_open(struct pcie_bars &bars)

auto allocate_bar = [](volatile void *&ptr, size_t &size, size_t desired_size) {
size = desired_size;
ptr = malloc(size);
ptr = mmap(0, desired_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
};

/* same sizes as our devices */
Expand Down
Loading