]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
travis: enable -fsanitize=undefined 3238/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 23 Dec 2019 19:12:57 +0000 (20:12 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 23 Dec 2019 21:12:09 +0000 (22:12 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
.travis.yml
configure.ac
src/lxc/Makefile.am
src/tests/travis.sh [new file with mode: 0755]

index b8c695ffee9e5c052b9e333eb2be29dd1040b3d6..4fc67d0f19f1044458c77cdde9d05f7c9e7e1790 100644 (file)
@@ -6,22 +6,7 @@ before_install:
  - sudo add-apt-repository ppa:ubuntu-lxc/daily -y
  - sudo apt-get update -qq
  - sudo apt-get install -qq coccinelle parallel libapparmor-dev libcap-dev libseccomp-dev python3-dev python3-setuptools docbook2x libgnutls-dev libselinux1-dev linux-libc-dev
-script:
- - ./coccinelle/run-coccinelle.sh -i
- - git diff --exit-code
- - export CFLAGS="-Wall -Werror"
- - export LDFLAGS="-pthread -lpthread"
- - ./autogen.sh
- - rm -Rf build
- - mkdir build
- - cd build
- - ../configure --enable-tests --with-distro=unknown
- - make -j4
- - make DESTDIR=$TRAVIS_BUILD_DIR/install install
- - cd ../config/apparmor
- - ./lxc-generate-aa-rules.py container-rules.base > /tmp/output
- - diff /tmp/output container-rules
-
+script: src/tests/travis.sh
 notifications:
   email:
     recipients:
index 3ef4d37fdbe7057d2937911898bd0a779f3d4c00..2cf74b86ba16cd4e38dbd2764cef85adbfd01ccf 100644 (file)
@@ -440,6 +440,12 @@ AC_ARG_ENABLE([asan],
        [enable_asan=$enableval], [enable_asan=no])
 AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = "xyes"])
 
+# Build with UBSAN commands
+AC_ARG_ENABLE([ubsan],
+       [AS_HELP_STRING([--enable-ubsan], [build with ubsan sanitizer enabled [default=no]])],
+       [enable_asan=$enableval], [enable_ubsan=no])
+AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = "xyes"])
+
 # Optional test binaries
 AC_ARG_ENABLE([tests],
        [AS_HELP_STRING([--enable-tests], [build test/example binaries [default=no]])],
index eea8adcc9d4210e38079a71e66bce3a002ef74e1..b85ebedfe0ded88b766fb1e42ef9691d910cb9dc 100644 (file)
@@ -240,12 +240,17 @@ endif
 liblxc_la_CFLAGS = -fPIC \
                   -DPIC \
                   $(AM_CFLAGS) \
+                  $(LIBLXC_SANITIZER) \
                   -pthread
 if ENABLE_ASAN
 liblxc_la_CFLAGS += -fsanitize=address \
                    -fno-omit-frame-pointer
 endif
 
+if ENABLE_UBSAN
+liblxc_la_CFLAGS += -fsanitize=undefined
+endif
+
 liblxc_la_LDFLAGS = -pthread \
                    -Wl,-no-undefined \
                    -Wl,-soname,liblxc.so.$(firstword $(subst ., ,@LXC_ABI@)) \
diff --git a/src/tests/travis.sh b/src/tests/travis.sh
new file mode 100755 (executable)
index 0000000..e57004e
--- /dev/null
@@ -0,0 +1,22 @@
+#! /bin/bash
+
+set -e
+
+./coccinelle/run-coccinelle.sh -i
+git diff --exit-code
+export CFLAGS="-Wall -Werror"
+export LDFLAGS="-pthread -lpthread"
+./autogen.sh
+rm -Rf build
+mkdir build
+cd build
+if [ "$CC_FOR_BUILD" == "gcc" ]; then
+  ../configure --enable-tests --enable-ubsan --with-distro=unknown
+else
+  ../configure --enable-tests --with-distro=unknown
+fi
+make -j4
+make DESTDIR="$TRAVIS_BUILD_DIR"/install install
+cd ../config/apparmor
+./lxc-generate-aa-rules.py container-rules.base > /tmp/output
+diff /tmp/output container-rules