diff options
author | Torne (Richard Coles) <torne@google.com> | 2013-06-19 11:58:07 +0100 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2013-06-19 11:58:07 +0100 |
commit | 7d4cd473f85ac64c3747c96c277f9e506a0d2246 (patch) | |
tree | f5fecd524f5ac22cd38bcc6713b81f666730d5a1 /testing | |
parent | 84f2b2352908c30e40ae12ffe850dd8470f6c048 (diff) | |
download | chromium_org-7d4cd473f85ac64c3747c96c277f9e506a0d2246.tar.gz |
Merge from Chromium at DEPS revision r207203
This commit was generated by merge_to_master.py.
Change-Id: I5fbb6854d092096c4d39edc2865a48be1b53c418
Diffstat (limited to 'testing')
-rw-r--r-- | testing/android/native_test_launcher.cc | 58 | ||||
-rw-r--r-- | testing/android/native_test_util.cc | 36 | ||||
-rw-r--r-- | testing/android/native_test_util.h | 4 | ||||
-rw-r--r-- | testing/gtest_prod.target.darwin-arm.mk | 1 | ||||
-rw-r--r-- | testing/gtest_prod.target.darwin-mips.mk | 1 | ||||
-rw-r--r-- | testing/gtest_prod.target.darwin-x86.mk | 1 | ||||
-rw-r--r-- | testing/gtest_prod.target.linux-arm.mk | 1 | ||||
-rw-r--r-- | testing/gtest_prod.target.linux-mips.mk | 1 | ||||
-rw-r--r-- | testing/gtest_prod.target.linux-x86.mk | 1 |
9 files changed, 52 insertions, 52 deletions
diff --git a/testing/android/native_test_launcher.cc b/testing/android/native_test_launcher.cc index 61d6c5faef..e39eb2bdcc 100644 --- a/testing/android/native_test_launcher.cc +++ b/testing/android/native_test_launcher.cc @@ -13,12 +13,14 @@ #include <signal.h> #include "base/android/base_jni_registrar.h" +#include "base/android/fifo_utils.h" #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" #include "base/at_exit.h" #include "base/base_switches.h" #include "base/command_line.h" +#include "base/file_util.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/strings/stringprintf.h" @@ -27,9 +29,7 @@ #include "testing/jni/ChromeNativeTestActivity_jni.h" using testing::native_test_util::ArgsToArgv; -using testing::native_test_util::CreateFIFO; using testing::native_test_util::ParseArgsFromCommandLineFile; -using testing::native_test_util::RedirectStream; using testing::native_test_util::ScopedMainEntryLogger; // The main function of the program to be wrapped as a test apk. @@ -78,6 +78,41 @@ void InstallHandlers() { } } +// Writes printf() style string to Android's logger where |priority| is one of +// the levels defined in <android/log.h>. +void AndroidLog(int priority, const char* format, ...) { + va_list args; + va_start(args, format); + __android_log_vprint(priority, kLogTag, format, args); + va_end(args); +} + +// Ensures that the fifo at |path| is created by deleting whatever is at |path| +// prior to (re)creating the fifo, otherwise logs the error and terminates the +// program. +void EnsureCreateFIFO(const base::FilePath& path) { + unlink(path.value().c_str()); + if (base::android::CreateFIFO(path, 0666)) + return; + + AndroidLog(ANDROID_LOG_ERROR, "Failed to create fifo %s: %s\n", + path.value().c_str(), strerror(errno)); + exit(EXIT_FAILURE); +} + +// Ensures that |stream| is redirected to |path|, otherwise logs the error and +// terminates the program. +void EnsureRedirectStream(FILE* stream, + const base::FilePath& path, + const char* mode) { + if (base::android::RedirectStream(stream, path, mode)) + return; + + AndroidLog(ANDROID_LOG_ERROR, "Failed to redirect stream to file: %s: %s\n", + path.value().c_str(), strerror(errno)); + exit(EXIT_FAILURE); +} + } // namespace // This method is called on a separate java thread so that we won't trigger @@ -115,7 +150,7 @@ static void RunTests(JNIEnv* env, // A few options, such "--gtest_list_tests", will just use printf directly // Always redirect stdout to a known file. base::FilePath fifo_path(files_dir.Append(base::FilePath("test.fifo"))); - CreateFIFO(fifo_path.value().c_str()); + EnsureCreateFIFO(fifo_path); base::FilePath stderr_fifo_path, stdin_fifo_path; @@ -123,29 +158,28 @@ static void RunTests(JNIEnv* env, // other tests, insert stderr content to the same fifo we use for stdout. if (command_line.HasSwitch(kSeparateStderrFifo)) { stderr_fifo_path = files_dir.Append(base::FilePath("stderr.fifo")); - CreateFIFO(stderr_fifo_path.value().c_str()); + EnsureCreateFIFO(stderr_fifo_path); } // DumpRenderTree uses stdin to receive input about which test to run. if (command_line.HasSwitch(kCreateStdinFifo)) { stdin_fifo_path = files_dir.Append(base::FilePath("stdin.fifo")); - CreateFIFO(stdin_fifo_path.value().c_str()); + EnsureCreateFIFO(stdin_fifo_path); } // Only redirect the streams after all fifos have been created. - RedirectStream(stdout, fifo_path.value().c_str(), "w"); + EnsureRedirectStream(stdout, fifo_path, "w"); if (!stdin_fifo_path.empty()) - RedirectStream(stdin, stdin_fifo_path.value().c_str(), "r"); + EnsureRedirectStream(stdin, stdin_fifo_path, "r"); if (!stderr_fifo_path.empty()) - RedirectStream(stderr, stderr_fifo_path.value().c_str(), "w"); + EnsureRedirectStream(stderr, stderr_fifo_path, "w"); else dup2(STDOUT_FILENO, STDERR_FILENO); if (command_line.HasSwitch(switches::kWaitForDebugger)) { - std::string msg = base::StringPrintf("Native test waiting for GDB because " - "flag %s was supplied", - switches::kWaitForDebugger); - __android_log_write(ANDROID_LOG_VERBOSE, kLogTag, msg.c_str()); + AndroidLog(ANDROID_LOG_VERBOSE, + "Native test waiting for GDB because flag %s was supplied", + switches::kWaitForDebugger); base::debug::WaitForDebugger(24 * 60 * 60, false); } diff --git a/testing/android/native_test_util.cc b/testing/android/native_test_util.cc index 084908beac..c0ea7b0fef 100644 --- a/testing/android/native_test_util.cc +++ b/testing/android/native_test_util.cc @@ -4,14 +4,6 @@ #include "testing/android/native_test_util.h" -#include <android/log.h> -#include <stdarg.h> -#include <stdio.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include "base/command_line.h" #include "base/file_util.h" #include "base/files/file_path.h" #include "base/strings/string_tokenizer.h" @@ -19,15 +11,6 @@ namespace { -const char kLogTag[] = "chromium"; - -void AndroidLogError(const char* format, ...) { - va_list args; - va_start(args, format); - __android_log_vprint(ANDROID_LOG_ERROR, kLogTag, format, args); - va_end(args); -} - void ParseArgsFromString(const std::string& command_line, std::vector<std::string>* args) { base::StringTokenizer tokenizer(command_line, kWhitespaceASCII); @@ -44,25 +27,6 @@ void ParseArgsFromString(const std::string& command_line, namespace testing { namespace native_test_util { -void CreateFIFO(const char* fifo_path) { - unlink(fifo_path); - // Default permissions for mkfifo is ignored, chmod is required. - if (mkfifo(fifo_path, 0666) || chmod(fifo_path, 0666)) { - AndroidLogError("Failed to create fifo %s: %s\n", - fifo_path, strerror(errno)); - exit(EXIT_FAILURE); - } -} - -void RedirectStream( - FILE* stream, const char* path, const char* mode) { - if (!freopen(path, mode, stream)) { - AndroidLogError("Failed to redirect stream to file: %s: %s\n", - path, strerror(errno)); - exit(EXIT_FAILURE); - } -} - void ParseArgsFromCommandLineFile( const char* path, std::vector<std::string>* args) { base::FilePath command_line(path); diff --git a/testing/android/native_test_util.h b/testing/android/native_test_util.h index 4e40222fde..a7567392b1 100644 --- a/testing/android/native_test_util.h +++ b/testing/android/native_test_util.h @@ -27,10 +27,6 @@ class ScopedMainEntryLogger { } }; -// Creates a fifo at the given |fifo_path|. -void CreateFIFO(const char* fifo_path); -// Redirects the |stream| to the file provided by |path|. -void RedirectStream(FILE* stream, const char* path, const char* mode); void ParseArgsFromCommandLineFile( const char* path, std::vector<std::string>* args); int ArgsToArgv(const std::vector<std::string>& args, std::vector<char*>* argv); diff --git a/testing/gtest_prod.target.darwin-arm.mk b/testing/gtest_prod.target.darwin-arm.mk index 691f7dd4ed..88e05c5f8f 100644 --- a/testing/gtest_prod.target.darwin-arm.mk +++ b/testing/gtest_prod.target.darwin-arm.mk @@ -64,6 +64,7 @@ MY_CFLAGS := \ MY_CFLAGS_C := MY_DEFS := \ + '-DANGLE_DX11' \ '-D_FILE_OFFSET_BITS=64' \ '-DUSE_LINUX_BREAKPAD' \ '-DNO_TCMALLOC' \ diff --git a/testing/gtest_prod.target.darwin-mips.mk b/testing/gtest_prod.target.darwin-mips.mk index aa8a375ba1..22de129efa 100644 --- a/testing/gtest_prod.target.darwin-mips.mk +++ b/testing/gtest_prod.target.darwin-mips.mk @@ -67,6 +67,7 @@ MY_CFLAGS := \ MY_CFLAGS_C := MY_DEFS := \ + '-DANGLE_DX11' \ '-D_FILE_OFFSET_BITS=64' \ '-DNO_TCMALLOC' \ '-DDISABLE_NACL' \ diff --git a/testing/gtest_prod.target.darwin-x86.mk b/testing/gtest_prod.target.darwin-x86.mk index ce13072cbd..12345a1b92 100644 --- a/testing/gtest_prod.target.darwin-x86.mk +++ b/testing/gtest_prod.target.darwin-x86.mk @@ -66,6 +66,7 @@ MY_CFLAGS := \ MY_CFLAGS_C := MY_DEFS := \ + '-DANGLE_DX11' \ '-D_FILE_OFFSET_BITS=64' \ '-DUSE_LINUX_BREAKPAD' \ '-DNO_TCMALLOC' \ diff --git a/testing/gtest_prod.target.linux-arm.mk b/testing/gtest_prod.target.linux-arm.mk index 691f7dd4ed..88e05c5f8f 100644 --- a/testing/gtest_prod.target.linux-arm.mk +++ b/testing/gtest_prod.target.linux-arm.mk @@ -64,6 +64,7 @@ MY_CFLAGS := \ MY_CFLAGS_C := MY_DEFS := \ + '-DANGLE_DX11' \ '-D_FILE_OFFSET_BITS=64' \ '-DUSE_LINUX_BREAKPAD' \ '-DNO_TCMALLOC' \ diff --git a/testing/gtest_prod.target.linux-mips.mk b/testing/gtest_prod.target.linux-mips.mk index aa8a375ba1..22de129efa 100644 --- a/testing/gtest_prod.target.linux-mips.mk +++ b/testing/gtest_prod.target.linux-mips.mk @@ -67,6 +67,7 @@ MY_CFLAGS := \ MY_CFLAGS_C := MY_DEFS := \ + '-DANGLE_DX11' \ '-D_FILE_OFFSET_BITS=64' \ '-DNO_TCMALLOC' \ '-DDISABLE_NACL' \ diff --git a/testing/gtest_prod.target.linux-x86.mk b/testing/gtest_prod.target.linux-x86.mk index ce13072cbd..12345a1b92 100644 --- a/testing/gtest_prod.target.linux-x86.mk +++ b/testing/gtest_prod.target.linux-x86.mk @@ -66,6 +66,7 @@ MY_CFLAGS := \ MY_CFLAGS_C := MY_DEFS := \ + '-DANGLE_DX11' \ '-D_FILE_OFFSET_BITS=64' \ '-DUSE_LINUX_BREAKPAD' \ '-DNO_TCMALLOC' \ |