[PATCH] [Msan] Fix the unit tests' PathToLoadable() to work on FreeBSD

Alexey Samsonov vonosmas at gmail.com
Thu Feb 12 10:05:25 PST 2015


================
Comment at: lib/msan/tests/msan_test.cc:109
@@ -108,1 +108,3 @@
+const size_t kPageSize = 4096;
+const size_t kPathRoom = 4096;
 
----------------
kMaxPathLength?

================
Comment at: lib/msan/tests/msan_test.cc:2850
@@ -2836,10 +2849,3 @@
 // directory.  Only use string routines that we intercept so far to do this.
-static int PathToLoadable(char *buf, size_t sz) {
-  const char *basename = "libmsan_loadable.x86_64.so";
-  char *argv0 = program_invocation_name;
-  char *last_slash = strrchr(argv0, '/');
-  assert(last_slash);
-  int res =
-      snprintf(buf, sz, "%.*s/%s", int(last_slash - argv0), argv0, basename);
-  assert(res >= 0);
-  return (size_t)res < sz ? 0 : res;
+static void PathToLoadable(char *buf, size_t sz) {
+  char program_path[kPathRoom];
----------------
kutuzov.viktor.84 wrote:
> Hm, with the returning type eliminated we may want to rename it to GetPathToLoadable()?
Yes, please.

================
Comment at: lib/msan/tests/msan_test.cc:2862
@@ -2846,1 +2861,3 @@
+  ASSERT_GE(res, 0);
+  ASSERT_LT((size_t) res, sz);
 }
----------------
Please run clang-format on this diff

http://reviews.llvm.org/D7587

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list