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

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

Issue 348853006: Linux sandbox: add test to ensure that pread64 can be forwarded. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Exclude Android from new test. Created 6 years, 6 months 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
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 a1f38df3ae95ac580be65b207020aa3249ce3256..63535cb1a2e9bd4c2cbe4a8c73a1d4867cb34547 100644
--- a/sandbox/linux/services/broker_process_unittest.cc
+++ b/sandbox/linux/services/broker_process_unittest.cc
@@ -24,6 +24,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
#include "base/posix/unix_domain_socket_linux.h"
+#include "sandbox/linux/tests/scoped_temporary_file.h"
#include "sandbox/linux/tests/test_utils.h"
#include "sandbox/linux/tests/unit_tests.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -39,38 +40,6 @@ class BrokerProcessTestHelper {
namespace {
-// Creates and open a temporary file on creation and closes
-// and removes it on destruction.
-// Unlike base/ helpers, this does not require JNI on Android.
-class ScopedTemporaryFile {
- public:
- ScopedTemporaryFile()
- : fd_(-1) {
-#if defined(OS_ANDROID)
- static const char file_template[] = "/data/local/tmp/ScopedTempFileXXXXXX";
-#else
- static const char file_template[] = "/tmp/ScopedTempFileXXXXXX";
-#endif // defined(OS_ANDROID)
- COMPILE_ASSERT(sizeof(full_file_name_) >= sizeof(file_template),
- full_file_name_is_large_enough);
- memcpy(full_file_name_, file_template, sizeof(file_template));
- fd_ = mkstemp(full_file_name_);
- CHECK_LE(0, fd_);
- }
- ~ScopedTemporaryFile() {
- CHECK_EQ(0, unlink(full_file_name_));
- CHECK_EQ(0, IGNORE_EINTR(close(fd_)));
- }
-
- int fd() const { return fd_; }
- const char* full_file_name() const { return full_file_name_; }
-
- private:
- int fd_;
- char full_file_name_[128];
- DISALLOW_COPY_AND_ASSIGN(ScopedTemporaryFile);
-};
-
bool NoOpCallback() { return true; }
} // namespace

Powered by Google App Engine
This is Rietveld 408576698