[PATCH] [Msan] Fix the getgrnam_r unit test to pass on FreeBSD

Phabricator reviews at reviews.llvm.org
Mon Feb 16 05:21:32 PST 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D7339

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
@@ -99,11 +99,13 @@
 # define DIR_TO_READ "/bin"
 # define SUBFILE_TO_READ "cat"
 # define SYMLINK_TO_READ "/usr/bin/tar"
+# define SUPERUSER_GROUP "wheel"
 #else
 # define FILE_TO_READ "/proc/self/stat"
 # define DIR_TO_READ "/proc/self"
 # define SUBFILE_TO_READ "stat"
 # define SYMLINK_TO_READ "/proc/self/exe"
+# define SUPERUSER_GROUP "root"
 #endif
 
 static const size_t kPageSize = 4096;
@@ -3273,8 +3275,10 @@
   struct group grp;
   struct group *grpres;
   char buf[10000];
-  int res = getgrnam_r("root", &grp, buf, sizeof(buf), &grpres);
+  int res = getgrnam_r(SUPERUSER_GROUP, &grp, buf, sizeof(buf), &grpres);
   ASSERT_EQ(0, res);
+  // Note that getgrnam_r() returns 0 if the matching group is not found.
+  ASSERT_NE(nullptr, grpres);
   EXPECT_NOT_POISONED(grp.gr_name);
   ASSERT_TRUE(grp.gr_name != NULL);
   EXPECT_NOT_POISONED(grp.gr_name[0]);

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7339.20024.patch
Type: text/x-patch
Size: 1090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150216/07e38966/attachment.bin>


More information about the llvm-commits mailing list