From 4d4cbf739f24dae421ba5509d084becb50deaf6a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 16 Oct 2019 18:52:36 +0200 Subject: [PATCH 1/2] 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 --- src/test/testing_common.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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); From fefa08df752c87a16b4a203576670c0501736c98 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 10 Dec 2019 10:54:45 -0500 Subject: [PATCH 2/2] Add a changes file for ticket 32172. --- changes/ticket32172 | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changes/ticket32172 diff --git a/changes/ticket32172 b/changes/ticket32172 new file mode 100644 index 0000000000..a661617999 --- /dev/null +++ b/changes/ticket32172 @@ -0,0 +1,4 @@ + o Minor features (tests, Android): + - When running the unit tests on Android, create temporary files + in a subdirectory of /data/local/tmp. Closes ticket + 32172. Based on a patch from Hans-Christoph Steiner.