From 7a354e8088aaa20d58a1c5cd24e52b084c76d959 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 4 Mar 2023 21:57:36 +0100 Subject: [PATCH 1/2] fuzz: Compile using libstd++ It looks like libfuzzer is compiled using libstd++ on Debian Bookworm and not libc++. Using libc++ causes linking errors, use libstd++ instead. Signed-off-by: Hauke Mehrtens --- tests/fuzz/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt index cca74fd..6114a7c 100644 --- a/tests/fuzz/CMakeLists.txt +++ b/tests/fuzz/CMakeLists.txt @@ -4,7 +4,7 @@ MACRO(ADD_FUZZER_TEST name) ADD_EXECUTABLE(${name} ${name}.c) TARGET_COMPILE_OPTIONS(${name} PRIVATE -g -O1 -fno-omit-frame-pointer -fsanitize=fuzzer,address,leak,undefined) TARGET_INCLUDE_DIRECTORIES(${name} PRIVATE ${PROJECT_SOURCE_DIR}) - TARGET_LINK_OPTIONS(${name} PRIVATE -stdlib=libc++ -fsanitize=fuzzer,address,leak,undefined) + TARGET_LINK_OPTIONS(${name} PRIVATE -fsanitize=fuzzer,address,leak,undefined) TARGET_LINK_LIBRARIES(${name} ubox blobmsg_json json_script ${json}) ADD_TEST( NAME ${name} From 776d8ff441314bb48064382baf9688036fe13480 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 4 Mar 2023 20:27:22 +0100 Subject: [PATCH 2/2] CI: Add github action Add a github action to build libubox and then execute the tests. clang 14 generates debug informations in DWARF 5 format, but valgrind 19.0 does not support that. Install valgrind 20.0 from experimental which supports it. Signed-off-by: Hauke Mehrtens --- .github/workflows/test.yml | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..091fd81 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,62 @@ +name: 'Run tests' + +on: + push: + pull_request: + +jobs: + build_test: + strategy: + matrix: + include: + - compiler: "-DCMAKE_C_COMPILER=clang" + - compiler: "-DCMAKE_C_COMPILER=gcc" + + name: Build and run tests + runs-on: ubuntu-latest + container: + image: debian:bookworm + + steps: + + - name: Add Debian experimental + run: | + echo "deb http://deb.debian.org/debian/ experimental main" >> /etc/apt/sources.list + + - name: Install compiler + run: | + apt update + apt install -y cmake build-essential lua5.1 pkgconf libjson-c-dev liblua5.1-0-dev python3.11-venv clang libc++abi-dev libc++-dev + apt -t experimental install -y valgrind + useradd -ms /bin/bash buildbot + + - name: Checkout libubox + uses: actions/checkout@v3 + with: + path: libubox + + - name: Create build directory + run: mkdir build + + - name: Fix permission + run: chown -R buildbot:buildbot build libubox + + - name: Run cmake + shell: su buildbot -c "sh -e {0}" + working-directory: build + run: cmake ../libubox -DUNIT_TESTING=true ${{ matrix.compiler }} + + - name: Run build + shell: su buildbot -c "sh -e {0}" + working-directory: build + run: make + + - name: Run tests + shell: su buildbot -c "sh -e {0}" + working-directory: build + run: make test + + - name: Show logs + shell: su buildbot -c "sh -e {0}" + working-directory: build + run: cat Testing/Temporary/LastTest.log