From 1d7790604c0c4e189bf8d91583cae8f1e027b1fb Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Mon, 3 Aug 2020 13:21:08 -0700 Subject: [PATCH] [UBSan] Increase robustness of tests These UBSan tests assert the absence of runtime errors via `count 0`, which means "expect no output". This fails the test unnecessarily in some environments (e.g., iOS simulator in our case). Alter the test to be a bit more specific and "expect no error" instead of "expect no output". rdar://65503408 Differential Revision: https://reviews.llvm.org/D85155 --- compiler-rt/test/ubsan/TestCases/Misc/nonnull.cpp | 4 +++- compiler-rt/test/ubsan/TestCases/Misc/nullability.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler-rt/test/ubsan/TestCases/Misc/nonnull.cpp b/compiler-rt/test/ubsan/TestCases/Misc/nonnull.cpp index d5cd2bf..c612cd8 100644 --- a/compiler-rt/test/ubsan/TestCases/Misc/nonnull.cpp +++ b/compiler-rt/test/ubsan/TestCases/Misc/nonnull.cpp @@ -1,5 +1,5 @@ // RUN: %clangxx -fsanitize=returns-nonnull-attribute -w %s -O3 -o %t -// RUN: %run %t foo 2>&1 | count 0 +// RUN: %run %t foo 2>&1 | FileCheck %s --check-prefix=NOERROR --allow-empty --implicit-check-not='runtime error' // RUN: %run %t 2>&1 | FileCheck %s // RUN: %clangxx -fsanitize=returns-nonnull-attribute -fno-sanitize-recover=returns-nonnull-attribute -w %s -O3 -o %t.abort // RUN: not %run %t.abort &> /dev/null @@ -40,3 +40,5 @@ int main(int argc, char **argv) { return 0; } + +// NOERROR-NOT: runtime error diff --git a/compiler-rt/test/ubsan/TestCases/Misc/nullability.c b/compiler-rt/test/ubsan/TestCases/Misc/nullability.c index a68d0f8..4283798 100644 --- a/compiler-rt/test/ubsan/TestCases/Misc/nullability.c +++ b/compiler-rt/test/ubsan/TestCases/Misc/nullability.c @@ -1,6 +1,6 @@ // UNSUPPORTED: android // RUN: %clang -w -fsanitize=nullability-arg,nullability-assign,nullability-return %s -O3 -o %t -// RUN: %run %t foo 2>&1 | count 0 +// RUN: %run %t foo 2>&1 | FileCheck %s --check-prefix=NOERROR --allow-empty --implicit-check-not='runtime error' // RUN: %run %t 2>&1 | FileCheck %s // RUN: echo "nullability-arg:nullability.c" > %t.supp @@ -67,3 +67,5 @@ int main(int argc, char **argv) { nonnull_init2(p); return 0; } + +// NOERROR-NOT: runtime error -- 2.7.4