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 #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);