From b1cdc497b8c858b2f292a94e28ed39a4960f5274 Mon Sep 17 00:00:00 2001 From: Bernd Schubert Date: Wed, 6 Mar 2024 00:23:22 +0100 Subject: ci-build.sh: Run ASAN and UBSAN at the same time Also set halt_on_error=1 to make UBSAN to fail if it would find something. --- test/ci-build.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/ci-build.sh b/test/ci-build.sh index 28ff0d8..c266ea2 100755 --- a/test/ci-build.sh +++ b/test/ci-build.sh @@ -3,6 +3,10 @@ set -e TEST_CMD="python3 -m pytest --maxfail=99 test/" +SAN="-Db_sanitize=address,undefined" + +# not default +export UBSAN_OPTIONS=halt_on_error=1 # Make sure binaries can be accessed when invoked by root. umask 0022 @@ -26,7 +30,7 @@ export CC # Standard build for CC in gcc gcc-9 gcc-10 clang; do echo "=== Building with ${CC} ===" - mkdir build-${CC}; cd build-${CC} + mkdir build-${CC}; pushd build-${CC} if [ "${CC}" == "clang" ]; then export CXX="clang++" export TEST_WITH_VALGRIND=false @@ -49,25 +53,25 @@ for CC in gcc gcc-9 gcc-10 clang; do sudo chown root:root util/fusermount3 sudo chmod 4755 util/fusermount3 ${TEST_CMD} - cd .. + popd done -(cd build-$CC; sudo ninja install) sanitized_build() -{ - san=$1 - additonal_option=$2 +( + echo "=== Building with clang and sanitizers" - echo "=== Building with clang and ${san} sanitizer ===" - [ -n ${additonal_option} ] || echo "Additional option: ${additonal_option}" + mkdir build-san; pushd build-san - mkdir build-${san}; pushd build-${san} + meson setup -D werror=true\ + "${SOURCE_DIR}" \ + || (ct meson-logs/meson-log.txt; false) + meson configure $SAN # b_lundef=false is required to work around clang # bug, cf. https://groups.google.com/forum/#!topic/mesonbuild/tgEdAXIIdC4 - meson setup -D b_sanitize=${san} -D b_lundef=false -D werror=true\ - ${additonal_option} "${SOURCE_DIR}" \ - || (cat meson-logs/meson-log.txt; false) + meson configure -D b_lundef=false + + meson configure ninja # Test as root and regular user @@ -80,23 +84,19 @@ sanitized_build() ${TEST_CMD} popd - rm -fr build-${san} -} + rm -fr build-san +) # Sanitized build CC=clang CXX=clang++ TEST_WITH_VALGRIND=false -for san in undefined address; do - sanitized_build ${san} -done +sanitized_build $SAN # Sanitized build without libc versioned symbols CC=clang CXX=clang++ -for san in undefined address; do - sanitized_build ${san} "-Ddisable-libc-symbol-version=true" -done +sanitized_build # Documentation. (cd "${SOURCE_DIR}"; doxygen doc/Doxyfile) -- cgit v1.2.3 From aab146eea8877ee744a1b5a0da8bbbf31d14bad1 Mon Sep 17 00:00:00 2001 From: Bernd Schubert Date: Wed, 6 Mar 2024 00:37:53 +0100 Subject: ci-build.sh: Always install and add s-bit for fusermount3 As per pull #898, fusermount3 had a severe issue that should have been detected by ASAN. I guess tests used the system default and not the sanitized binary. Order of execution of fusermount3 is to try 1) full install path if that fails 2) just fusermount3 So tests should be fixed by installing libfuse, setting the s-bit on fusermount3 and then to run the tests. --- test/ci-build.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/ci-build.sh b/test/ci-build.sh index c266ea2..a023c15 100755 --- a/test/ci-build.sh +++ b/test/ci-build.sh @@ -18,6 +18,9 @@ umask 0022 # readable/executable. SOURCE_DIR="$(readlink -f .)" TEST_DIR="$(mktemp -dt libfuse-build-XXXXXX)" + +PREFIX_DIR="$(mktemp -dt libfuse-install-XXXXXXX)" + chmod 0755 "${TEST_DIR}" cd "${TEST_DIR}" echo "Running in ${TEST_DIR}" @@ -47,13 +50,17 @@ for CC in gcc gcc-9 gcc-10 clang; do else build_opts='' fi - meson setup -D werror=true ${build_opts} "${SOURCE_DIR}" || (cat meson-logs/meson-log.txt; false) + meson setup -Dprefix=${PREFIX_DIR} -D werror=true ${build_opts} "${SOURCE_DIR}" || (cat meson-logs/meson-log.txt; false) ninja + sudo ninja install + + # libfuse will first try the install path and then system defaults + sudo chmod 4755 ${PREFIX_DIR}/bin/fusermount3 - sudo chown root:root util/fusermount3 - sudo chmod 4755 util/fusermount3 ${TEST_CMD} popd + rm -fr build-${CC} + sudo rm -fr ${PREFIX_DIR} done sanitized_build() @@ -62,7 +69,7 @@ sanitized_build() mkdir build-san; pushd build-san - meson setup -D werror=true\ + meson setup -Dprefix=${PREFIX_DIR} -D werror=true\ "${SOURCE_DIR}" \ || (ct meson-logs/meson-log.txt; false) meson configure $SAN @@ -73,11 +80,11 @@ sanitized_build() meson configure ninja + sudo ninja install + sudo chmod 4755 ${PREFIX_DIR}/bin/fusermount3 # Test as root and regular user sudo ${TEST_CMD} - sudo chown root:root util/fusermount3 - sudo chmod 4755 util/fusermount3 # Cleanup temporary files (since they are now owned by root) sudo rm -rf test/.pytest_cache/ test/__pycache__ @@ -85,6 +92,7 @@ sanitized_build() popd rm -fr build-san + sudo rm -fr ${PREFIX_DIR} ) # Sanitized build -- cgit v1.2.3