diff mbox series

[ovs-dev,v2,1/3] tests: Set handle_segv fpr UBSAN to allow SIGSEGV tests.

Message ID a461ed3c4b92c2b47e923bae623c9601396f5b2e.1704882144.git.echaudro@redhat.com
State Accepted
Delegated to: Eelco Chaudron
Headers show
Series [ovs-dev,v2,1/3] tests: Set handle_segv fpr UBSAN to allow SIGSEGV tests. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Eelco Chaudron Jan. 10, 2024, 10:22 a.m. UTC
Previously tests that were generating a SIGSEGV were excluded
from UBSAN runs. With the correct environment variable, these
tests can be run. This is working even with the clang version
supplied by Ubuntu 20.04.

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
 tests/atlocal.in      | 10 ----------
 tests/daemon.at       | 28 ++++++++--------------------
 tests/ovsdb-server.at | 28 ++++++++--------------------
 3 files changed, 16 insertions(+), 50 deletions(-)

Comments

Ilya Maximets Jan. 10, 2024, 7 p.m. UTC | #1
On 1/10/24 11:22, Eelco Chaudron wrote:
> Previously tests that were generating a SIGSEGV were excluded
> from UBSAN runs. With the correct environment variable, these
> tests can be run. This is working even with the clang version
> supplied by Ubuntu 20.04.

Hmm, interesting.  I'm pretty sure that didn't work at some point.
But it's awesome if it does!  Did you try with both gcc and clang?
We don't need another CI job for gcc with sanitizers, but people
may run with gcc locally.

Best regards, Ilya Maximets.
Eelco Chaudron Jan. 11, 2024, 9:01 a.m. UTC | #2
On 10 Jan 2024, at 20:00, Ilya Maximets wrote:

> On 1/10/24 11:22, Eelco Chaudron wrote:
>> Previously tests that were generating a SIGSEGV were excluded
>> from UBSAN runs. With the correct environment variable, these
>> tests can be run. This is working even with the clang version
>> supplied by Ubuntu 20.04.
>
> Hmm, interesting.  I'm pretty sure that didn't work at some point.
> But it's awesome if it does!  Did you try with both gcc and clang?
> We don't need another CI job for gcc with sanitizers, but people
> may run with gcc locally.

Yes did a ubsan run on my Fedora system with GCC and it worked fine.

//Eelco
Simon Horman Jan. 11, 2024, noon UTC | #3
On Wed, Jan 10, 2024 at 11:22:22AM +0100, Eelco Chaudron wrote:
> Previously tests that were generating a SIGSEGV were excluded
> from UBSAN runs. With the correct environment variable, these
> tests can be run. This is working even with the clang version
> supplied by Ubuntu 20.04.
> 
> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>

Acked-by: Simon Horman <horms@ovn.org>
diff mbox series

Patch

diff --git a/tests/atlocal.in b/tests/atlocal.in
index 1013098a1..372576a91 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -194,16 +194,6 @@  else
     DIFF_SUPPORTS_NORMAL_FORMAT=no
 fi
 
-# Check whether UB Sanitizer is being used.
-case "$CFLAGS" in
-*fsanitize=undefined*)
-    TESTS_WITH_UBSAN=yes
-    ;;
-*)
-    TESTS_WITH_UBSAN=no
-    ;;
-esac
-
 # Turn off proxies.
 unset http_proxy
 unset https_proxy
diff --git a/tests/daemon.at b/tests/daemon.at
index 2c7fac57c..6cb8b9888 100644
--- a/tests/daemon.at
+++ b/tests/daemon.at
@@ -78,12 +78,9 @@  AT_CLEANUP
 AT_SETUP([daemon --monitor])
 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
 
-# This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it.
+# This test intentionally causes SIGSEGV, so make sanitizers ignore it.
 ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS
-
-# Skip it if UB Sanitizer is being used.  There's no way to disable the
-# SEGV check at runtime.
-AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes])
+UBSAN_OPTIONS=$UBSAN_OPTIONS:handle_segv=0; export UBSAN_OPTIONS
 
 # Start the daemon and wait for the pidfile to get created.
 on_exit 'kill $(cat *.pid)'
@@ -150,12 +147,9 @@  AT_CLEANUP
 AT_SETUP([daemon --detach --monitor])
 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
 
-# This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it.
+# This test intentionally causes SIGSEGV, so make sanitizers ignore it.
 ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS
-
-# Skip it if UB Sanitizer is being used.  There's no way to disable the
-# SEGV check at runtime.
-AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes])
+UBSAN_OPTIONS=$UBSAN_OPTIONS:handle_segv=0; export UBSAN_OPTIONS
 
 on_exit 'kill $(cat *.pid)'
 
@@ -239,12 +233,9 @@  AT_SETUP([backtrace without monitor])
 AT_SKIP_IF([test "$HAVE_BACKTRACE" = "no" && test "$HAVE_UNWIND" = "no"])
 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
 
-# This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it.
+# This test intentionally causes SIGSEGV, so make sanitizers ignore it.
 ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS
-
-# Skip it if UB Sanitizer is being used.  There's no way to disable the
-# SEGV check at runtime.
-AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes])
+UBSAN_OPTIONS=$UBSAN_OPTIONS:handle_segv=0; export UBSAN_OPTIONS
 
 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --no-db \
                        --log-file --verbose=DBG], [0], [ignore], [ignore])
@@ -263,12 +254,9 @@  AT_SETUP([backtrace with monitor])
 AT_SKIP_IF([test "$HAVE_BACKTRACE" = "no" && test "$HAVE_UNWIND" = "no"])
 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
 
-# This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it.
+# This test intentionally causes SIGSEGV, so make sanitizers ignore it.
 ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS
-
-# Skip it if UB Sanitizer is being used.  There's no way to disable the
-# SEGV check at runtime.
-AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes])
+UBSAN_OPTIONS=$UBSAN_OPTIONS:handle_segv=0; export UBSAN_OPTIONS
 
 on_exit 'kill $(cat *.pid)'
 
diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at
index d36c3c117..6916c0742 100644
--- a/tests/ovsdb-server.at
+++ b/tests/ovsdb-server.at
@@ -302,12 +302,9 @@  AT_SETUP([ovsdb-server/add-db with --monitor])
 AT_KEYWORDS([ovsdb server positive])
 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
 
-# This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it.
+# This test intentionally causes SIGSEGV, so make sanitizers ignore it.
 ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS
-
-# Skip it if UB Sanitizer is being used.  There's no way to disable the
-# SEGV check at runtime.
-AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes])
+UBSAN_OPTIONS=$UBSAN_OPTIONS:handle_segv=0; export UBSAN_OPTIONS
 
 # Start ovsdb-server, initially with one db.
 ordinal_schema > schema
@@ -344,12 +341,9 @@  AT_SETUP([ovsdb-server/add-db and remove-db with --monitor])
 AT_KEYWORDS([ovsdb server positive])
 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
 
-# This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it.
+# This test intentionally causes SIGSEGV, so make sanitizers ignore it.
 ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS
-
-# Skip it if UB Sanitizer is being used.  There's no way to disable the
-# SEGV check at runtime.
-AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes])
+UBSAN_OPTIONS=$UBSAN_OPTIONS:handle_segv=0; export UBSAN_OPTIONS
 
 # Start ovsdb-server, initially with one db.
 ordinal_schema > schema
@@ -503,12 +497,9 @@  AT_SETUP([ovsdb-server/add-remote with --monitor])
 AT_KEYWORDS([ovsdb server positive])
 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
 
-# This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it.
+# This test intentionally causes SIGSEGV, so make sanitizers ignore it.
 ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS
-
-# Skip it if UB Sanitizer is being used.  There's no way to disable the
-# SEGV check at runtime.
-AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes])
+UBSAN_OPTIONS=$UBSAN_OPTIONS:handle_segv=0; export UBSAN_OPTIONS
 
 # Start ovsdb-server, initially with no remotes.
 ordinal_schema > schema
@@ -545,12 +536,9 @@  AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor])
 AT_KEYWORDS([ovsdb server positive])
 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
 
-# This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it.
+# This test intentionally causes SIGSEGV, so make sanitizers ignore it.
 ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS
-
-# Skip it if UB Sanitizer is being used.  There's no way to disable the
-# SEGV check at runtime.
-AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes])
+UBSAN_OPTIONS=$UBSAN_OPTIONS:handle_segv=0; export UBSAN_OPTIONS
 
 # Start ovsdb-server, initially with no remotes.
 ordinal_schema > schema