summaryrefslogtreecommitdiff
path: root/test/sanitizer_common
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2019-01-08 21:49:37 +0000
committerDavid Carlier <devnexen@gmail.com>2019-01-08 21:49:37 +0000
commiteb52eec5f49e5020dee345a7165eb9c87f94a11b (patch)
tree85758868c43d923497ae6f638a480faf9de94748 /test/sanitizer_common
parent33115af331fe4287df889bcae356b9e94db331f6 (diff)
downloadcompiler-rt-eb52eec5f49e5020dee345a7165eb9c87f94a11b.tar.gz
[Sanitizer] Intercept fdevname on FreeBSD
- Is a file descriptor flavor FreeBSD's specific. - reentrant version included. Reviewers: vitalybuka, krytarowski, emaste Reviewed By: emaste Differential Revision: https://reviews.llvm.org/D56268 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@350658 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/sanitizer_common')
-rw-r--r--test/sanitizer_common/TestCases/FreeBSD/fdevname.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/sanitizer_common/TestCases/FreeBSD/fdevname.cc b/test/sanitizer_common/TestCases/FreeBSD/fdevname.cc
new file mode 100644
index 000000000..252335e9a
--- /dev/null
+++ b/test/sanitizer_common/TestCases/FreeBSD/fdevname.cc
@@ -0,0 +1,44 @@
+// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
+
+#include <assert.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+void test_fdevname() {
+ int fd = open("/dev/null", O_RDONLY);
+ char *name;
+
+ printf("test_fdevname\n");
+ assert(fd != -1);
+ assert((name = fdevname(fd)));
+ close(fd);
+
+ printf("%s\n", name);
+}
+
+void test_fdevname_r() {
+ int fd = open("/dev/null", O_RDONLY);
+ char *name;
+ char buf[5];
+
+ printf("test_fdevname_r\n");
+ assert(fd != -1);
+ assert((name = fdevname_r(fd, buf, sizeof(buf))));
+ close(fd);
+
+ printf("%s\n", name);
+}
+
+int main(void) {
+ test_fdevname();
+ test_fdevname_r();
+ // CHECK: test_fdevname
+ // CHECK: null
+ // CHECK: test_fdevname_r
+ // CHECK: null
+
+ return 0;
+}