sanitizer_common: add test that calls wcslen
authorThurston Dang <thurston@google.com>
Fri, 19 May 2023 21:32:54 +0000 (21:32 +0000)
committerThurston Dang <thurston@google.com>
Wed, 24 May 2023 19:30:05 +0000 (19:30 +0000)
This is a very simple test that calls wsclen. There are currently no other HWASan tests that call wsclen, which is why the wcslen interceptor issue (triggered by https://reviews.llvm.org/D150708 and fixed in https://reviews.llvm.org/D150909) was only detected by stage2/hwasan check on the buildbots. With this test, the issue would have been caught by stage1 check-sanitizer, with a more obvious diagnosis.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D151000

compiler-rt/test/sanitizer_common/TestCases/wcslen_test.c [new file with mode: 0644]

diff --git a/compiler-rt/test/sanitizer_common/TestCases/wcslen_test.c b/compiler-rt/test/sanitizer_common/TestCases/wcslen_test.c
new file mode 100644 (file)
index 0000000..28efd76
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: %clang %s -O0 -o %t && %run %t 2>&1
+
+#include <assert.h>
+#include <wchar.h>
+
+int main(int argc, char **argv) {
+  wchar_t x[] = L"Hello World!";
+  assert(wcslen(x) == 12);
+  return 0;
+}