Skip to content

Commit 3187014

Browse files
committed
add tests
1 parent e4606ed commit 3187014

File tree

1 file changed

+32
-0
lines changed
  • compiler-rt/test/sanitizer_common/TestCases/Linux

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %clangxx -O0 %s -o %t && %run %t
2+
// RUN: %env_tool_opts=handle_segv=2 not %run %t 3 2>&1 | FileCheck --check-prefixes=CHECK1,CHECK
3+
4+
// UNSUPPORTED: android
5+
6+
#include <assert.h>
7+
#include <fcntl.h>
8+
#include <sys/uio.h>
9+
#include <unistd.h>
10+
11+
// CHECK: [[SAN:.*Sanitizer]]:DEADLYSIGNAL
12+
// CHECK: ERROR: [[SAN]]: SEGV on unknown address {{0x[^ ]*}} (pc
13+
int main(void) {
14+
int fd = open("/proc/self/stat", O_RDONLY);
15+
char bufa[7];
16+
char bufb[7];
17+
struct iovec vec[2];
18+
vec[0].iov_base = bufa + 4;
19+
vec[0].iov_len = 1;
20+
vec[1].iov_base = bufb;
21+
vec[1].iov_len = sizeof(bufb);
22+
ssize_t rd = preadv2(fd, vec, 2, 0, 0);
23+
assert(rd > 0);
24+
vec[0].iov_base = bufa;
25+
rd = preadv2(fd, vec, 2, 0, 0);
26+
assert(rd > 0);
27+
vec[1].iov_len = 1024;
28+
preadv2(fd, vec, 2, 0, 0);
29+
// CHECK1: #{{[0-9]+ .*}}main {{.*}}preadv2.cpp:[[@LINE-1]]:[[TAB:[0-9]+]]
30+
// CHECK1: SUMMARY: [[SAN]]: SEGV {{.*}}preadv2.cpp:[[@LINE-2]]:[[TAB]] in main
31+
return 0;
32+
}

0 commit comments

Comments
 (0)