[PATCH] [Msan] Fix tests reading /proc files on FreeBSD
Phabricator
reviews at reviews.llvm.org
Mon Jan 12 12:16:59 PST 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D6926
Files:
compiler-rt/trunk/lib/msan/tests/msan_test.cc
Index: compiler-rt/trunk/lib/msan/tests/msan_test.cc
===================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc
@@ -73,6 +73,13 @@
# include <immintrin.h>
#endif
+// On FreeBSD procfs is not enabled by default.
+#if defined(__FreeBSD__)
+# define FILE_TO_READ "/bin/cat"
+#else
+# define FILE_TO_READ "/proc/self/stat"
+#endif
+
static const size_t kPageSize = 4096;
typedef unsigned char U1;
@@ -564,7 +571,7 @@
TEST(MemorySanitizer, fread) {
char *x = new char[32];
- FILE *f = fopen("/proc/self/stat", "r");
+ FILE *f = fopen(FILE_TO_READ, "r");
ASSERT_TRUE(f != NULL);
fread(x, 1, 32, f);
EXPECT_NOT_POISONED(x[0]);
@@ -576,7 +583,7 @@
TEST(MemorySanitizer, read) {
char *x = new char[32];
- int fd = open("/proc/self/stat", O_RDONLY);
+ int fd = open(FILE_TO_READ, O_RDONLY);
ASSERT_GT(fd, 0);
int sz = read(fd, x, 32);
ASSERT_EQ(sz, 32);
@@ -589,7 +596,7 @@
TEST(MemorySanitizer, pread) {
char *x = new char[32];
- int fd = open("/proc/self/stat", O_RDONLY);
+ int fd = open(FILE_TO_READ, O_RDONLY);
ASSERT_GT(fd, 0);
int sz = pread(fd, x, 32, 0);
ASSERT_EQ(sz, 32);
@@ -607,7 +614,7 @@
iov[0].iov_len = 5;
iov[1].iov_base = buf + 10;
iov[1].iov_len = 2000;
- int fd = open("/proc/self/stat", O_RDONLY);
+ int fd = open(FILE_TO_READ, O_RDONLY);
ASSERT_GT(fd, 0);
int sz = readv(fd, iov, 2);
ASSERT_GE(sz, 0);
@@ -631,7 +638,7 @@
iov[0].iov_len = 5;
iov[1].iov_base = buf + 10;
iov[1].iov_len = 2000;
- int fd = open("/proc/self/stat", O_RDONLY);
+ int fd = open(FILE_TO_READ, O_RDONLY);
ASSERT_GT(fd, 0);
int sz = preadv(fd, iov, 2, 3);
ASSERT_GE(sz, 0);
@@ -662,10 +669,9 @@
delete [] x;
}
-
TEST(MemorySanitizer, stat) {
struct stat* st = new struct stat;
- int res = stat("/proc/self/stat", st);
+ int res = stat(FILE_TO_READ, st);
ASSERT_EQ(0, res);
EXPECT_NOT_POISONED(st->st_dev);
EXPECT_NOT_POISONED(st->st_mode);
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6926.18035.patch
Type: text/x-patch
Size: 2061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150112/c671d4cf/attachment.bin>
More information about the llvm-commits
mailing list