summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Keeler <mjkeeler7@gmail.com>2018-04-24 17:12:49 -0700
committerMatt Keeler <mjkeeler7@gmail.com>2018-04-25 08:28:23 -0700
commit45a3b9cd6e5407a031f102b1ea987f150b06d059 (patch)
tree7bbcf98058a5b2faedad020eee4e5cea47a542ae
parent0eca42304a10c9ad6170a38a440dfab8e354d38d (diff)
downloadlibgit2-45a3b9cd6e5407a031f102b1ea987f150b06d059.tar.gz
tests: fix issue with /tmp paths on macOS[1]
-rw-r--r--tests/clar/sandbox.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/clar/sandbox.h b/tests/clar/sandbox.h
index 4b83bf31d..2114819e4 100644
--- a/tests/clar/sandbox.h
+++ b/tests/clar/sandbox.h
@@ -1,3 +1,7 @@
+#ifdef __APPLE__
+#include <sys/syslimits.h>
+#endif
+
static char _clar_path[4096];
static int
@@ -31,6 +35,10 @@ find_tmp_path(char *buffer, size_t length)
continue;
if (is_valid_tmp_path(env)) {
+#ifdef __APPLE__
+ if (length >= PATH_MAX && realpath(env, buffer) != NULL)
+ return 0;
+#endif
strncpy(buffer, env, length);
return 0;
}
@@ -38,6 +46,10 @@ find_tmp_path(char *buffer, size_t length)
/* If the environment doesn't say anything, try to use /tmp */
if (is_valid_tmp_path("/tmp")) {
+#ifdef __APPLE__
+ if (length >= PATH_MAX && realpath("/tmp", buffer) != NULL)
+ return 0;
+#endif
strncpy(buffer, "/tmp", length);
return 0;
}