Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Unified Diff: sandbox/linux/services/broker_process_unittest.cc

Issue 11647024: Update Linux sandbox tests to pass on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@seccomp-2
Patch Set: Guard the Android path_utils.h. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/services/broker_process_unittest.cc
diff --git a/sandbox/linux/services/broker_process_unittest.cc b/sandbox/linux/services/broker_process_unittest.cc
index 879fe6660c755a6692d6ef88d55d72b508011c67..7319ae97c17952fd6ae6f988d848fec7ea674592 100644
--- a/sandbox/linux/services/broker_process_unittest.cc
+++ b/sandbox/linux/services/broker_process_unittest.cc
@@ -12,6 +12,10 @@
#include <string>
#include <vector>
+#if defined(OS_ANDROID)
+#include "base/android/path_utils.h"
+#endif
+#include "base/file_path.h"
#include "base/logging.h"
#include "sandbox/linux/tests/unit_tests.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -172,12 +176,24 @@ TEST(BrokerProcess, OpenCpuinfoNoClientCheck) {
}
TEST(BrokerProcess, OpenFileRW) {
- char templatename[] = "BrokerProcessXXXXXX";
- int tempfile = mkstemp(templatename);
+ const char basename[] = "BrokerProcessXXXXXX";
+ char template_name[2048];
+#if defined(OS_ANDROID)
+ FilePath cache_directory;
+ ASSERT_TRUE(base::android::GetCacheDirectory(&cache_directory));
+ ssize_t length = snprintf(template_name, sizeof(template_name),
+ "%s%s",
+ cache_directory.value().c_str(), basename);
+ ASSERT_LT(length, static_cast<ssize_t>(sizeof(template_name)));
+#else
+ strncpy(template_name, basename, sizeof(basename) - 1);
+ template_name[sizeof(basename) - 1] = '\0';
+#endif
+ int tempfile = mkstemp(template_name);
ASSERT_GE(tempfile, 0);
char tempfile_name[2048];
int written = snprintf(tempfile_name, sizeof(tempfile_name),
- "/proc/self/fd/%d", tempfile);
+ "/proc/self/fd/%d", tempfile);
ASSERT_LT(written, static_cast<int>(sizeof(tempfile_name)));
std::vector<std::string> whitelist;
« no previous file with comments | « sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698