Ensure that the /data/misc/perfetto-traces directory exists.
This is required for some tests due to SELinux permissions, but some
emulators like the ones travis-ci uses does not have this directory.
Bug: 128966650
Change-Id: I1b2ad746145ac7eb0b96464b968f831f68806445
diff --git a/tools/run_android_test b/tools/run_android_test
index e8109e7..f22138d 100755
--- a/tools/run_android_test
+++ b/tools/run_android_test
@@ -131,6 +131,12 @@
target_dir = '/data/local/tmp/' + args.test_name
AdbCall('shell', 'rm -rf "%s"; mkdir -p "%s"' % (2 * (target_dir,)))
+ # Some tests require the trace directory to exist, while true for android
+ # devices in general some emulators might not have it set up. So we check to
+ # see if it exists, and if not create it.
+ trace_dir = '/data/misc/perfetto-traces'
+ AdbCall('shell', 'test -d "%s" || mkdir -p "%s"' % (2 * (trace_dir,)))
+ AdbCall('shell', 'rm -rf "%s/*"; ' % trace_dir)
AdbCall('shell', 'mkdir -p /data/nativetest')
# This needs to go into /data/nativetest in order to have the system linker
# namespace applied, which we need in order to link libdexfile_external.so.