[compiler-rt] r286850 - Split strncmp and strncasecmp test and XFAIL one for Windows
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 14 09:51:12 PST 2016
Author: rnk
Date: Mon Nov 14 11:51:11 2016
New Revision: 286850
URL: http://llvm.org/viewvc/llvm-project?rev=286850&view=rev
Log:
Split strncmp and strncasecmp test and XFAIL one for Windows
Added:
compiler-rt/trunk/test/asan/TestCases/strncasecmp_strict.c
- copied, changed from r286848, compiler-rt/trunk/test/asan/TestCases/strncmp_strict.c
Modified:
compiler-rt/trunk/test/asan/TestCases/strncmp_strict.c
Copied: compiler-rt/trunk/test/asan/TestCases/strncasecmp_strict.c (from r286848, compiler-rt/trunk/test/asan/TestCases/strncmp_strict.c)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/strncasecmp_strict.c?p2=compiler-rt/trunk/test/asan/TestCases/strncasecmp_strict.c&p1=compiler-rt/trunk/test/asan/TestCases/strncmp_strict.c&r1=286848&r2=286850&rev=286850&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/strncmp_strict.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/strncasecmp_strict.c Mon Nov 14 11:51:11 2016
@@ -14,18 +14,7 @@
// RUN: %env_asan_opts=strict_string_checks=false %run %t i 2>&1
// RUN: %env_asan_opts=strict_string_checks=true not %run %t i 2>&1 | FileCheck %s
-// RUN: %env_asan_opts=strict_string_checks=false %run %t A 2>&1
-// RUN: %env_asan_opts=strict_string_checks=true %run %t A 2>&1
-// RUN: not %run %t B 2>&1 | FileCheck %s
-// RUN: not %run %t C 2>&1 | FileCheck %s
-// RUN: not %run %t D 2>&1 | FileCheck %s
-// RUN: not %run %t E 2>&1 | FileCheck %s
-// RUN: not %run %t F 2>&1 | FileCheck %s
-// RUN: not %run %t G 2>&1 | FileCheck %s
-// RUN: %env_asan_opts=strict_string_checks=false %run %t H 2>&1
-// RUN: %env_asan_opts=strict_string_checks=true not %run %t H 2>&1 | FileCheck %s
-// RUN: %env_asan_opts=strict_string_checks=false %run %t I 2>&1
-// RUN: %env_asan_opts=strict_string_checks=true not %run %t I 2>&1 | FileCheck %s
+// XFAIL: win32
#include <assert.h>
#include <stdlib.h>
@@ -42,38 +31,35 @@ int main(int argc, char **argv) {
memset(s1, fill, size);
memset(s2, fill, size);
- int (*cmp_fn)(const char *, const char *, size_t);
- cmp_fn = islower(argv[1][0]) ? &strncmp : &strncasecmp;
-
- switch(tolower(argv[1][0])) {
+ switch (argv[1][0]) {
case 'a':
s1[size - 1] = 'z';
s2[size - 1] = 'x';
for (int i = 0; i <= size; ++i)
- assert((cmp_fn(s1, s2, i) == 0) == (i < size));
+ assert((strncasecmp(s1, s2, i) == 0) == (i < size));
s1[size - 1] = '\0';
s2[size - 1] = '\0';
- assert(cmp_fn(s1, s2, 2*size) == 0);
+ assert(strncasecmp(s1, s2, 2*size) == 0);
break;
case 'b':
- return cmp_fn(s1-1, s2, 1);
+ return strncasecmp(s1-1, s2, 1);
case 'c':
- return cmp_fn(s1, s2-1, 1);
+ return strncasecmp(s1, s2-1, 1);
case 'd':
- return cmp_fn(s1+size, s2, 1);
+ return strncasecmp(s1+size, s2, 1);
case 'e':
- return cmp_fn(s1, s2+size, 1);
+ return strncasecmp(s1, s2+size, 1);
case 'f':
- return cmp_fn(s1+1, s2, size);
+ return strncasecmp(s1+1, s2, size);
case 'g':
- return cmp_fn(s1, s2+1, size);
+ return strncasecmp(s1, s2+1, size);
case 'h':
s1[size - 1] = '\0';
- assert(cmp_fn(s1, s2, 2*size) != 0);
+ assert(strncasecmp(s1, s2, 2*size) != 0);
break;
case 'i':
s2[size - 1] = '\0';
- assert(cmp_fn(s1, s2, 2*size) != 0);
+ assert(strncasecmp(s1, s2, 2*size) != 0);
break;
// CHECK: {{.*}}ERROR: AddressSanitizer: stack-buffer-{{ov|und}}erflow on address
}
Modified: compiler-rt/trunk/test/asan/TestCases/strncmp_strict.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/strncmp_strict.c?rev=286850&r1=286849&r2=286850&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/strncmp_strict.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/strncmp_strict.c Mon Nov 14 11:51:11 2016
@@ -14,19 +14,6 @@
// RUN: %env_asan_opts=strict_string_checks=false %run %t i 2>&1
// RUN: %env_asan_opts=strict_string_checks=true not %run %t i 2>&1 | FileCheck %s
-// RUN: %env_asan_opts=strict_string_checks=false %run %t A 2>&1
-// RUN: %env_asan_opts=strict_string_checks=true %run %t A 2>&1
-// RUN: not %run %t B 2>&1 | FileCheck %s
-// RUN: not %run %t C 2>&1 | FileCheck %s
-// RUN: not %run %t D 2>&1 | FileCheck %s
-// RUN: not %run %t E 2>&1 | FileCheck %s
-// RUN: not %run %t F 2>&1 | FileCheck %s
-// RUN: not %run %t G 2>&1 | FileCheck %s
-// RUN: %env_asan_opts=strict_string_checks=false %run %t H 2>&1
-// RUN: %env_asan_opts=strict_string_checks=true not %run %t H 2>&1 | FileCheck %s
-// RUN: %env_asan_opts=strict_string_checks=false %run %t I 2>&1
-// RUN: %env_asan_opts=strict_string_checks=true not %run %t I 2>&1 | FileCheck %s
-
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
@@ -42,38 +29,35 @@ int main(int argc, char **argv) {
memset(s1, fill, size);
memset(s2, fill, size);
- int (*cmp_fn)(const char *, const char *, size_t);
- cmp_fn = islower(argv[1][0]) ? &strncmp : &strncasecmp;
-
- switch(tolower(argv[1][0])) {
+ switch (argv[1][0]) {
case 'a':
s1[size - 1] = 'z';
s2[size - 1] = 'x';
for (int i = 0; i <= size; ++i)
- assert((cmp_fn(s1, s2, i) == 0) == (i < size));
+ assert((strncmp(s1, s2, i) == 0) == (i < size));
s1[size - 1] = '\0';
s2[size - 1] = '\0';
- assert(cmp_fn(s1, s2, 2*size) == 0);
+ assert(strncmp(s1, s2, 2*size) == 0);
break;
case 'b':
- return cmp_fn(s1-1, s2, 1);
+ return strncmp(s1-1, s2, 1);
case 'c':
- return cmp_fn(s1, s2-1, 1);
+ return strncmp(s1, s2-1, 1);
case 'd':
- return cmp_fn(s1+size, s2, 1);
+ return strncmp(s1+size, s2, 1);
case 'e':
- return cmp_fn(s1, s2+size, 1);
+ return strncmp(s1, s2+size, 1);
case 'f':
- return cmp_fn(s1+1, s2, size);
+ return strncmp(s1+1, s2, size);
case 'g':
- return cmp_fn(s1, s2+1, size);
+ return strncmp(s1, s2+1, size);
case 'h':
s1[size - 1] = '\0';
- assert(cmp_fn(s1, s2, 2*size) != 0);
+ assert(strncmp(s1, s2, 2*size) != 0);
break;
case 'i':
s2[size - 1] = '\0';
- assert(cmp_fn(s1, s2, 2*size) != 0);
+ assert(strncmp(s1, s2, 2*size) != 0);
break;
// CHECK: {{.*}}ERROR: AddressSanitizer: stack-buffer-{{ov|und}}erflow on address
}
More information about the llvm-commits
mailing list