summaryrefslogtreecommitdiff
path: root/test/sanitizer_common
diff options
context:
space:
mode:
authorYury Gribov <y.gribov@samsung.com>2015-05-28 09:24:33 +0000
committerYury Gribov <y.gribov@samsung.com>2015-05-28 09:24:33 +0000
commitf2fa25015a85f504430864b8038c99995fd3fa95 (patch)
tree5056b4071beab3850d912a359c9d80e3bc500a83 /test/sanitizer_common
parentd7d4be4d271a5dc32b2ec0ddb7224f2421225e3e (diff)
downloadcompiler-rt-f2fa25015a85f504430864b8038c99995fd3fa95.tar.gz
[sanitizer] More string interceptors: strstr, strcasestr, strspn, strcspn, strpbrk.
Patch by Maria Guseva. Differential Revision: http://reviews.llvm.org/D9017 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@238406 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/sanitizer_common')
-rw-r--r--test/sanitizer_common/TestCases/strcasestr.c16
-rw-r--r--test/sanitizer_common/TestCases/strcspn.c13
-rw-r--r--test/sanitizer_common/TestCases/strpbrk.c14
-rw-r--r--test/sanitizer_common/TestCases/strspn.c13
-rw-r--r--test/sanitizer_common/TestCases/strstr.c12
5 files changed, 68 insertions, 0 deletions
diff --git a/test/sanitizer_common/TestCases/strcasestr.c b/test/sanitizer_common/TestCases/strcasestr.c
new file mode 100644
index 000000000..4de3cac7e
--- /dev/null
+++ b/test/sanitizer_common/TestCases/strcasestr.c
@@ -0,0 +1,16 @@
+// RUN: %clang %s -o %t && %run %t 2>&1
+
+// There's no interceptor for strcasestr on Windows
+// XFAIL: win32
+
+#define _GNU_SOURCE
+#include <assert.h>
+#include <string.h>
+int main(int argc, char **argv) {
+ char *r = 0;
+ char s1[] = "aB";
+ char s2[] = "b";
+ r = strcasestr(s1, s2);
+ assert(r == s1 + 1);
+ return 0;
+}
diff --git a/test/sanitizer_common/TestCases/strcspn.c b/test/sanitizer_common/TestCases/strcspn.c
new file mode 100644
index 000000000..066a27bbd
--- /dev/null
+++ b/test/sanitizer_common/TestCases/strcspn.c
@@ -0,0 +1,13 @@
+// RUN: %clang %s -o %t && %run %t 2>&1
+
+#include <assert.h>
+#include <string.h>
+
+int main(int argc, char **argv) {
+ size_t r;
+ char s1[] = "ad";
+ char s2[] = "cd";
+ r = strcspn(s1, s2);
+ assert(r == 1);
+ return 0;
+}
diff --git a/test/sanitizer_common/TestCases/strpbrk.c b/test/sanitizer_common/TestCases/strpbrk.c
new file mode 100644
index 000000000..318e3a497
--- /dev/null
+++ b/test/sanitizer_common/TestCases/strpbrk.c
@@ -0,0 +1,14 @@
+// RUN: %clang %s -o %t && %run %t 2>&1
+
+#include <assert.h>
+#include <string.h>
+
+
+int main(int argc, char **argv) {
+ char *r = 0;
+ char s1[] = "ad";
+ char s2[] = "cd";
+ r = strpbrk(s1, s2);
+ assert(r == s1 + 1);
+ return 0;
+}
diff --git a/test/sanitizer_common/TestCases/strspn.c b/test/sanitizer_common/TestCases/strspn.c
new file mode 100644
index 000000000..a9a24305c
--- /dev/null
+++ b/test/sanitizer_common/TestCases/strspn.c
@@ -0,0 +1,13 @@
+// RUN: %clang %s -o %t && %run %t 2>&1
+
+#include <assert.h>
+#include <string.h>
+
+int main(int argc, char **argv) {
+ size_t r;
+ char s1[] = "ab";
+ char s2[] = "ac";
+ r = strspn(s1, s2);
+ assert(r == 1);
+ return 0;
+}
diff --git a/test/sanitizer_common/TestCases/strstr.c b/test/sanitizer_common/TestCases/strstr.c
new file mode 100644
index 000000000..2089ac7b5
--- /dev/null
+++ b/test/sanitizer_common/TestCases/strstr.c
@@ -0,0 +1,12 @@
+// RUN: %clang %s -o %t && %run %t 2>&1
+
+#include <assert.h>
+#include <string.h>
+int main(int argc, char **argv) {
+ char *r = 0;
+ char s1[] = "ab";
+ char s2[] = "b";
+ r = strstr(s1, s2);
+ assert(r == s1 + 1);
+ return 0;
+}