aboutsummaryrefslogtreecommitdiff
path: root/src/test/testing_common.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <hans@eds.org>2019-10-16 18:52:36 +0200
committerNick Mathewson <nickm@torproject.org>2019-12-10 15:55:40 -0500
commit4d4cbf739f24dae421ba5509d084becb50deaf6a (patch)
treef463cd81e7cbf7a89419e8ff1e68f5a20d098440 /src/test/testing_common.c
parent944bdde50edbc6030dfc954ff501c92cd9e73fb0 (diff)
downloadtor-4d4cbf739f24dae421ba5509d084becb50deaf6a.tar.gz
tor-4d4cbf739f24dae421ba5509d084becb50deaf6a.zip
set up tmp dir for test suite to run on Android
There is no /tmp or mkdtemp on Android, there is /data/local/tmp for root and the shell user. So this fakes mkdtemp. Also, FYI, tor might not like the default perms of /data/local/tmp, e.g. 0770. https://trac.torproject.org/projects/tor/ticket/32172
Diffstat (limited to 'src/test/testing_common.c')
-rw-r--r--src/test/testing_common.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/testing_common.c b/src/test/testing_common.c
index c28d02be77..378a6f1924 100644
--- a/src/test/testing_common.c
+++ b/src/test/testing_common.c
@@ -89,6 +89,17 @@ setup_directory(void)
(int)getpid(), rnd32);
r = mkdir(temp_dir);
}
+#elif defined(__ANDROID__)
+ /* tor might not like the default perms, so create a subdir */
+ tor_snprintf(temp_dir, sizeof(temp_dir),
+ "/data/local/tmp/tor_%d_%d_%s",
+ (int) getuid(), (int) getpid(), rnd32);
+ r = mkdir(temp_dir, 0700);
+ if (r) {
+ fprintf(stderr, "Can't create directory %s:", temp_dir);
+ perror("");
+ exit(1);
+ }
#else /* !defined(_WIN32) */
tor_snprintf(temp_dir, sizeof(temp_dir), "/tmp/tor_test_%d_%s",
(int) getpid(), rnd32);