[compiler-rt] r298743 - Fix flaky strtok.c test.

Alex Shlyapnikov via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 24 14:43:56 PDT 2017


Author: alekseyshl
Date: Fri Mar 24 16:43:56 2017
New Revision: 298743

URL: http://llvm.org/viewvc/llvm-project?rev=298743&view=rev
Log:
Fix flaky strtok.c test.

Asserting the result of strtok when we expect delimiter overflow is
flaky, the result depends on the random state of memory right after the
delimiters.

Modified:
    compiler-rt/trunk/test/asan/TestCases/strtok.c

Modified: compiler-rt/trunk/test/asan/TestCases/strtok.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/strtok.c?rev=298743&r1=298742&r2=298743&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/strtok.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/strtok.c Fri Mar 24 16:43:56 2017
@@ -27,7 +27,7 @@
 #include <string.h>
 #include <sanitizer/asan_interface.h>
 
-// Check that we find overflows in the delimiters on the first call 
+// Check that we find overflows in the delimiters on the first call
 // with strict_string_checks.
 void test1() {
   char *token;
@@ -36,7 +36,6 @@ void test1() {
   __asan_poison_memory_region ((char *)&token_delimiter[1], 2);
   token = strtok(s, token_delimiter);
   // CHECK1:'token_delimiter' <== Memory access at offset {{[0-9]+}} partially overflows this variable
-  assert(strcmp(token, "a") == 0);
 }
 
 // Check that we find overflows in the delimiters on the second call (str == NULL)
@@ -50,7 +49,6 @@ void test2() {
   __asan_poison_memory_region ((char *)&token_delimiter[1], 2);
   token = strtok(NULL, token_delimiter);
   // CHECK2:'token_delimiter' <== Memory access at offset {{[0-9]+}} partially overflows this variable
-  assert(strcmp(token, "c") == 0);
 }
 
 // Check that we find overflows in the string (only on the first call) with strict_string_checks.
@@ -61,7 +59,6 @@ void test3() {
   __asan_poison_memory_region ((char *)&s[3], 2);
   token = strtok(s, token_delimiter);
   // CHECK3:'s' <== Memory access at offset {{[0-9]+}} partially overflows this variable
-  assert(token == s);
 }
 
 // Check that we do not crash when strtok returns NULL with strict_string_checks.
@@ -82,7 +79,6 @@ void test5() {
   __asan_poison_memory_region ((char *)&token_delimiter[1], 2);
   token = strtok(s, token_delimiter);
   // CHECK5:'s' <== Memory access at offset {{[0-9]+}} partially overflows this variable
-  assert(token == s);
 }
 
 // Check that we find overflows in the delimiters (only on the first call) with !strict_string_checks.
@@ -93,7 +89,6 @@ void test6() {
   __asan_poison_memory_region ((char *)&token_delimiter[1], 2);
   token = strtok(s, &token_delimiter[1]);
   // CHECK6:'token_delimiter' <== Memory access at offset {{[0-9]+}} overflows this variable
-  assert(strcmp(token, "abc") == 0);
 }
 
 int main(int argc, char **argv) {




More information about the llvm-commits mailing list