Skip to content

Commit

Permalink
Re-land part of r55416, minus actually moving the test_suite.h conten…
Browse files Browse the repository at this point in the history
…ts to a .cc file.

Cleanup in base. This moves the implementation (and a bunch of header file
dependencies) from the multiprocess test and the test_suite headers to .cc
files. Moves multiprocess_test to the test directory, and all of this stuff to
the existing base_test_support project. I also used the base namespace.

Previously other projects included this functionality just by #include because
it was all inline, so I had to add dependencies on base_test_support in a few
places.

Moves and renames the command line switch this was using to base_switches. Move
the base switch for process type to chrome switches.

TEST=none
BUG=none
Review URL: http://codereview.chromium.org/3026055


git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56399 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
brettw@chromium.org committed Aug 17, 2010
1 parent 2045b41 commit 20e1491
Show file tree
Hide file tree
Showing 42 changed files with 442 additions and 336 deletions.
2 changes: 1 addition & 1 deletion app/test_suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "base/scoped_nsautorelease_pool.h"
#include "base/test/test_suite.h"

class AppTestSuite : public TestSuite {
class AppTestSuite : public base::TestSuite {
public:
AppTestSuite(int argc, char** argv) : TestSuite(argc, argv) {
}
Expand Down
3 changes: 0 additions & 3 deletions base/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ include_rules = [
"+third_party/modp_b64",
"+third_party/tcmalloc",

# Testing stuff shouldn't be used by the general base code.
"-base/test",

# ICU dependendencies must be separate from the rest of base.
"-i18n",
]
4 changes: 3 additions & 1 deletion base/base.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
'msvs_guid': '27A30967-4BBA-48D1-8522-CDE95F7B1CEC',
'sources': [
# Infrastructure files.
'multiprocess_test.h',
'test/run_all_unittests.cc',

# Tests.
Expand Down Expand Up @@ -243,6 +242,9 @@
}],
],
'sources': [
'test/multiprocess_test.cc',
'test/multiprocess_test.h',
'test/perf_test_suite.h',
'test/test_file_util.h',
'test/test_file_util_linux.cc',
'test/test_file_util_mac.cc',
Expand Down
26 changes: 13 additions & 13 deletions base/base_switches.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand All @@ -11,27 +11,27 @@ namespace switches {
// seconds for the debugger to attach to itself. Then a break point will be hit.
const char kDebugOnStart[] = "debug-on-start";

// Will wait for 60 seconds for a debugger to come to attach to the process.
const char kWaitForDebugger[] = "wait-for-debugger";

// Suppresses all error dialogs when present.
const char kNoErrorDialogs[] = "noerrdialogs";

// Disables the crash reporting.
const char kDisableBreakpad[] = "disable-breakpad";

// Enable DCHECKs in release mode.
const char kEnableDCHECK[] = "enable-dcheck";

// Generates full memory crash dump.
const char kFullMemoryCrashReport[] = "full-memory-crash-report";

// The value of this switch determines whether the process is started as a
// renderer or plugin host. If it's empty, it's the browser.
const char kProcessType[] = "type";

// Enable DCHECKs in release mode.
const char kEnableDCHECK[] = "enable-dcheck";
// Suppresses all error dialogs when present.
const char kNoErrorDialogs[] = "noerrdialogs";

// Disable win_util::MessageBox. This is useful when running as part of
// scripts that do not have a user interface.
const char kNoMessageBox[] = "no-message-box";

// When running certain tests that spawn child processes, this switch indicates
// to the test framework that the current process is a child process.
const char kTestChildProcess[] = "test-child-process";

// Will wait for 60 seconds for a debugger to come to attach to the process.
const char kWaitForDebugger[] = "wait-for-debugger";

} // namespace switches
8 changes: 4 additions & 4 deletions base/base_switches.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand All @@ -11,13 +11,13 @@
namespace switches {

extern const char kDebugOnStart[];
extern const char kWaitForDebugger[];
extern const char kDisableBreakpad[];
extern const char kEnableDCHECK[];
extern const char kFullMemoryCrashReport[];
extern const char kNoErrorDialogs[];
extern const char kProcessType[];
extern const char kEnableDCHECK[];
extern const char kNoMessageBox[];
extern const char kTestChildProcess[];
extern const char kWaitForDebugger[];

} // namespace switches

Expand Down
121 changes: 0 additions & 121 deletions base/multiprocess_test.h

This file was deleted.

13 changes: 7 additions & 6 deletions base/process_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
#include "base/command_line.h"
#include "base/eintr_wrapper.h"
#include "base/file_path.h"
#include "base/multiprocess_test.h"
#include "base/path_service.h"
#include "base/platform_thread.h"
#include "base/process_util.h"
#include "base/scoped_ptr.h"
#include "base/test/multiprocess_test.h"
#include "base/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"

#if defined(OS_LINUX)
#include <errno.h>
Expand Down Expand Up @@ -62,7 +63,7 @@ void SignalChildren(const char* filename) {

} // namespace

class ProcessUtilTest : public MultiProcessTest {
class ProcessUtilTest : public base::MultiProcessTest {
#if defined(OS_POSIX)
public:
// Spawn a child process that counts how many file descriptors are open.
Expand All @@ -75,7 +76,7 @@ MULTIPROCESS_TEST_MAIN(SimpleChildProcess) {
}

TEST_F(ProcessUtilTest, SpawnChild) {
base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess");
base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess", false);
ASSERT_NE(base::kNullProcessHandle, handle);
EXPECT_TRUE(base::WaitForSingleProcess(handle, 5000));
base::CloseProcessHandle(handle);
Expand All @@ -88,7 +89,7 @@ MULTIPROCESS_TEST_MAIN(SlowChildProcess) {

TEST_F(ProcessUtilTest, KillSlowChild) {
remove("SlowChildProcess.die");
base::ProcessHandle handle = this->SpawnChild("SlowChildProcess");
base::ProcessHandle handle = this->SpawnChild("SlowChildProcess", false);
ASSERT_NE(base::kNullProcessHandle, handle);
SignalChildren("SlowChildProcess.die");
EXPECT_TRUE(base::WaitForSingleProcess(handle, 5000));
Expand All @@ -98,7 +99,7 @@ TEST_F(ProcessUtilTest, KillSlowChild) {

TEST_F(ProcessUtilTest, DidProcessCrash) {
remove("SlowChildProcess.die");
base::ProcessHandle handle = this->SpawnChild("SlowChildProcess");
base::ProcessHandle handle = this->SpawnChild("SlowChildProcess", false);
ASSERT_NE(base::kNullProcessHandle, handle);

bool child_exited = true;
Expand All @@ -118,7 +119,7 @@ TEST_F(ProcessUtilTest, DidProcessCrash) {
// Note: a platform may not be willing or able to lower the priority of
// a process. The calls to SetProcessBackground should be noops then.
TEST_F(ProcessUtilTest, SetProcessBackgrounded) {
base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess");
base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess", false);
base::Process process(handle);
int old_priority = process.GetPriority();
process.SetProcessBackgrounded(true);
Expand Down
10 changes: 4 additions & 6 deletions base/shared_memory_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
// found in the LICENSE file.

#include "base/basictypes.h"
#include "base/multiprocess_test.h"
#include "base/platform_thread.h"
#include "base/scoped_nsautorelease_pool.h"
#include "base/shared_memory.h"
#include "base/scoped_ptr.h"
#include "base/test/multiprocess_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"

static const int kNumThreads = 5;
static const int kNumTasks = 5;
Expand Down Expand Up @@ -271,13 +272,11 @@ TEST(SharedMemoryTest, AnonymousPrivate) {
for (int i = 0; i < count; i++) {
memories[i].Close();
}

}


// On POSIX it is especially important we test shmem across processes,
// not just across threads. But the test is enabled on all platforms.
class SharedMemoryProcessTest : public MultiProcessTest {
class SharedMemoryProcessTest : public base::MultiProcessTest {
public:

static void CleanUp() {
Expand Down Expand Up @@ -326,7 +325,7 @@ TEST_F(SharedMemoryProcessTest, Tasks) {

base::ProcessHandle handles[kNumTasks];
for (int index = 0; index < kNumTasks; ++index) {
handles[index] = SpawnChild("SharedMemoryTestMain");
handles[index] = SpawnChild("SharedMemoryTestMain", false);
}

int exit_code = 0;
Expand All @@ -342,5 +341,4 @@ MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) {
return SharedMemoryProcessTest::TaskTestMain();
}


} // namespace base
6 changes: 4 additions & 2 deletions base/stats_table_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
#include <windows.h>
#endif

#include "base/multiprocess_test.h"
#include "base/platform_thread.h"
#include "base/simple_thread.h"
#include "base/shared_memory.h"
#include "base/stats_table.h"
#include "base/stats_counters.h"
#include "base/string_piece.h"
#include "base/string_util.h"
#include "base/test/multiprocess_test.h"
#include "base/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
Expand Down Expand Up @@ -204,7 +206,7 @@ TEST_F(StatsTableTest, MultipleProcesses) {

// Spawn the processes.
for (int16 index = 0; index < kMaxProcs; index++) {
procs[index] = this->SpawnChild("StatsTableMultipleProcessMain");
procs[index] = this->SpawnChild("StatsTableMultipleProcessMain", false);
EXPECT_NE(base::kNullProcessHandle, procs[index]);
}

Expand Down
Loading

0 comments on commit 20e1491

Please sign in to comment.