diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-13 17:38:49 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-13 17:38:49 +0000 |
commit | c78566309f95a11cd5253e1cac681038d9885f21 (patch) | |
tree | 74bac802565ea385f1585d5d7d8ca15891b1979c /net/tools | |
parent | 2ccbdbe2508fdf17fde95a96ee197d45faabe467 (diff) | |
download | chromium_src-c78566309f95a11cd5253e1cac681038d9885f21.zip chromium_src-c78566309f95a11cd5253e1cac681038d9885f21.tar.gz chromium_src-c78566309f95a11cd5253e1cac681038d9885f21.tar.bz2 |
Port crash_cache tool to Linux.
Review URL: http://codereview.chromium.org/17353
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7939 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools')
-rw-r--r-- | net/tools/crash_cache/crash_cache.cc | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/net/tools/crash_cache/crash_cache.cc b/net/tools/crash_cache/crash_cache.cc index 243ed45..df641a2 100644 --- a/net/tools/crash_cache/crash_cache.cc +++ b/net/tools/crash_cache/crash_cache.cc @@ -7,14 +7,15 @@ // works properly on debug mode, because the crash functionality is not compiled // on release builds of the cache. -#include <windows.h> #include <string> #include "base/at_exit.h" +#include "base/command_line.h" #include "base/file_util.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/path_service.h" +#include "base/process_util.h" #include "base/string_util.h" #include "net/disk_cache/backend_impl.h" @@ -39,39 +40,31 @@ int RunSlave(RankCrashes action) { std::wstring exe; PathService::Get(base::FILE_EXE, &exe); - std::wstring command = StringPrintf(L"%ls %d", exe.c_str(), action); - - STARTUPINFO startup_info = {0}; - startup_info.cb = sizeof(startup_info); - PROCESS_INFORMATION process_info; - - // I really don't care about this call modifying the string. - if (!::CreateProcess(exe.c_str(), const_cast<wchar_t*>(command.c_str()), NULL, - NULL, FALSE, 0, NULL, NULL, &startup_info, - &process_info)) { +#if defined(OS_WIN) + CommandLine cmdline(StringPrintf(L"%ls %d", exe.c_str(), action)); +#elif defined(OS_POSIX) + std::vector<std::string> cmd_argv; + cmd_argv.push_back(WideToUTF8(exe)); + cmd_argv.push_back(IntToString(action)); + CommandLine cmdline(cmd_argv); +#endif + + base::ProcessHandle handle; + if (!base::LaunchApp(cmdline, false, false, &handle)) { printf("Unable to run test %d\n", action); return GENERIC; } - DWORD reason = ::WaitForSingleObject(process_info.hProcess, INFINITE); - - int code; - bool ok = ::GetExitCodeProcess(process_info.hProcess, - reinterpret_cast<PDWORD>(&code)) ? true : - false; + int exit_code; - ::CloseHandle(process_info.hProcess); - ::CloseHandle(process_info.hThread); - - if (!ok) { + if (!base::WaitForExitCode(handle, &exit_code)) { printf("Unable to get return code, test %d\n", action); return GENERIC; } + if (ALL_GOOD != exit_code) + printf("Test %d failed, code %d\n", action, exit_code); - if (ALL_GOOD != code) - printf("Test %d failed, code %d\n", action, code); - - return code; + return exit_code; } // Main loop for the master process. @@ -124,6 +117,9 @@ bool CreateTargetFolder(const std::wstring& path, RankCrashes action, *full_path = path; file_util::AppendToPath(full_path, folders[action]); + if (file_util::PathExists(*full_path)) + return false; + return file_util::CreateDirectory(*full_path); } |