summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2014-05-01 13:00:32 -0700
committerChristopher Ferris <cferris@google.com>2014-05-01 13:10:48 -0700
commit8b1ade5c0bdb5b3186c73c3081cc3013540190d9 (patch)
treeeda6eb15366d6a346236648e795cbcf5cd1d693a
parent9fb53dd4dbaa7633c234d9da8417827fa3d3c32f (diff)
downloadbionic-8b1ade5c0bdb5b3186c73c3081cc3013540190d9.zip
bionic-8b1ade5c0bdb5b3186c73c3081cc3013540190d9.tar.gz
bionic-8b1ade5c0bdb5b3186c73c3081cc3013540190d9.tar.bz2
Modify hard-coded directory.
Use the ANDROID_DATA environment variable instead of the hard-coded directory for these benchmarks. Change-Id: I00bae7b4a24e81e77fc8f52e1fe99f4d4918f520
-rw-r--r--benchmarks/property_benchmark.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/benchmarks/property_benchmark.cpp b/benchmarks/property_benchmark.cpp
index 4311a1d..6d17ec7 100644
--- a/benchmarks/property_benchmark.cpp
+++ b/benchmarks/property_benchmark.cpp
@@ -15,6 +15,9 @@
*/
#include "benchmark.h"
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
@@ -32,10 +35,17 @@ struct LocalPropertyTestState {
LocalPropertyTestState(int nprops) : nprops(nprops), valid(false) {
static const char prop_name_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_";
- char dir_template[] = "/data/local/tmp/prop-XXXXXX";
+ const char* android_data = getenv("ANDROID_DATA");
+ if (android_data == NULL) {
+ printf("ANDROID_DATA environment variable not set\n");
+ return;
+ }
+ char dir_template[PATH_MAX];
+ snprintf(dir_template, sizeof(dir_template), "%s/local/tmp/prop-XXXXXX", android_data);
char *dirname = mkdtemp(dir_template);
if (!dirname) {
- perror("making temp file for test state failed (is /data/local/tmp writable?)");
+ printf("making temp file for test state failed (is %s/local/tmp writable?): %s\n",
+ android_data, strerror(errno));
return;
}