Merge heap unit tests into src.
authorbmeurer@chromium.org <bmeurer@chromium.org>
Mon, 1 Sep 2014 09:12:50 +0000 (09:12 +0000)
committerbmeurer@chromium.org <bmeurer@chromium.org>
Mon, 1 Sep 2014 09:12:50 +0000 (09:12 +0000)
Also rip out the unused runtime-unittests; will be added back on-demand.

BUG=v8:3489
LOG=n
R=ulan@chromium.org, svenpanne@chromium.org

Review URL: https://codereview.chromium.org/525193004

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23545 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

15 files changed:
build/all.gyp
src/heap/gc-idle-time-handler-unittest.cc [moved from test/heap-unittests/heap-unittest.cc with 84% similarity]
src/heap/heap.gyp [moved from test/heap-unittests/heap-unittests.gyp with 93% similarity]
test/heap-unittests/DEPS [deleted file]
test/heap-unittests/heap-unittest.h [deleted file]
test/heap-unittests/heap-unittests.cc [deleted file]
test/heap-unittests/heap-unittests.h [deleted file]
test/runtime-unittests/DEPS [deleted file]
test/runtime-unittests/runtime-unittests.cc [deleted file]
test/runtime-unittests/runtime-unittests.gyp [deleted file]
test/runtime-unittests/runtime-unittests.h [deleted file]
test/runtime-unittests/runtime-unittests.status [deleted file]
test/runtime-unittests/testcfg.py [deleted file]
tools/presubmit.py
tools/run-tests.py

index d491d49..26dd575 100644 (file)
@@ -9,13 +9,12 @@
       'type': 'none',
       'dependencies': [
         '../samples/samples.gyp:*',
-        '../src/base/base.gyp:*',
+        '../src/base/base.gyp:base-unittests',
         '../src/d8.gyp:d8',
+        '../src/heap/heap.gyp:heap-unittests',
         '../src/libplatform/libplatform.gyp:libplatform-unittests',
         '../test/cctest/cctest.gyp:*',
         '../test/compiler-unittests/compiler-unittests.gyp:*',
-        '../test/heap-unittests/heap-unittests.gyp:*',
-        '../test/runtime-unittests/runtime-unittests.gyp:*',
       ],
       'conditions': [
         ['component!="shared_library"', {
similarity index 84%
rename from test/heap-unittests/heap-unittest.cc
rename to src/heap/gc-idle-time-handler-unittest.cc
index dd56f9d..b9989a8 100644 (file)
@@ -2,15 +2,47 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "test/heap-unittests/heap-unittest.h"
-
 #include <limits>
 
+#include "src/heap/gc-idle-time-handler.h"
+#include "testing/gtest/include/gtest/gtest.h"
 
 namespace v8 {
 namespace internal {
 
-TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeInitial) {
+namespace {
+
+class GCIdleTimeHandlerTest : public ::testing::Test {
+ public:
+  GCIdleTimeHandlerTest() {}
+  virtual ~GCIdleTimeHandlerTest() {}
+
+  GCIdleTimeHandler* handler() { return &handler_; }
+
+  GCIdleTimeHandler::HeapState DefaultHeapState() {
+    GCIdleTimeHandler::HeapState result;
+    result.contexts_disposed = 0;
+    result.size_of_objects = kSizeOfObjects;
+    result.incremental_marking_stopped = false;
+    result.can_start_incremental_marking = true;
+    result.sweeping_in_progress = false;
+    result.mark_compact_speed_in_bytes_per_ms = kMarkCompactSpeed;
+    result.incremental_marking_speed_in_bytes_per_ms = kMarkingSpeed;
+    return result;
+  }
+
+  static const size_t kSizeOfObjects = 100 * MB;
+  static const size_t kMarkCompactSpeed = 100 * KB;
+  static const size_t kMarkingSpeed = 100 * KB;
+
+ private:
+  GCIdleTimeHandler handler_;
+};
+
+}  // namespace
+
+
+TEST(GCIdleTimeHandler, EstimateMarkingStepSizeInitial) {
   size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0);
   EXPECT_EQ(
       static_cast<size_t>(GCIdleTimeHandler::kInitialConservativeMarkingSpeed *
@@ -19,7 +51,7 @@ TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeInitial) {
 }
 
 
-TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeNonZero) {
+TEST(GCIdleTimeHandler, EstimateMarkingStepSizeNonZero) {
   size_t marking_speed_in_bytes_per_millisecond = 100;
   size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
       1, marking_speed_in_bytes_per_millisecond);
@@ -29,7 +61,7 @@ TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeNonZero) {
 }
 
 
-TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeOverflow1) {
+TEST(GCIdleTimeHandler, EstimateMarkingStepSizeOverflow1) {
   size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
       10, std::numeric_limits<size_t>::max());
   EXPECT_EQ(static_cast<size_t>(GCIdleTimeHandler::kMaximumMarkingStepSize),
@@ -37,7 +69,7 @@ TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeOverflow1) {
 }
 
 
-TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeOverflow2) {
+TEST(GCIdleTimeHandler, EstimateMarkingStepSizeOverflow2) {
   size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
       std::numeric_limits<size_t>::max(), 10);
   EXPECT_EQ(static_cast<size_t>(GCIdleTimeHandler::kMaximumMarkingStepSize),
@@ -45,7 +77,7 @@ TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeOverflow2) {
 }
 
 
-TEST(EstimateMarkCompactTimeTest, EstimateMarkCompactTimeInitial) {
+TEST(GCIdleTimeHandler, EstimateMarkCompactTimeInitial) {
   size_t size = 100 * MB;
   size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, 0);
   EXPECT_EQ(size / GCIdleTimeHandler::kInitialConservativeMarkCompactSpeed,
@@ -53,7 +85,7 @@ TEST(EstimateMarkCompactTimeTest, EstimateMarkCompactTimeInitial) {
 }
 
 
-TEST(EstimateMarkCompactTimeTest, EstimateMarkCompactTimeNonZero) {
+TEST(GCIdleTimeHandler, EstimateMarkCompactTimeNonZero) {
   size_t size = 100 * MB;
   size_t speed = 10 * KB;
   size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, speed);
@@ -61,7 +93,7 @@ TEST(EstimateMarkCompactTimeTest, EstimateMarkCompactTimeNonZero) {
 }
 
 
-TEST(EstimateMarkCompactTimeTest, EstimateMarkCompactTimeMax) {
+TEST(GCIdleTimeHandler, EstimateMarkCompactTimeMax) {
   size_t size = std::numeric_limits<size_t>::max();
   size_t speed = 1;
   size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, speed);
@@ -208,6 +240,5 @@ TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop2) {
   EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
 }
 
-
 }  // namespace internal
 }  // namespace v8
similarity index 93%
rename from test/heap-unittests/heap-unittests.gyp
rename to src/heap/heap.gyp
index 99e638a..2970eb8 100644 (file)
       'target_name': 'heap-unittests',
       'type': 'executable',
       'dependencies': [
-        '../../testing/gmock.gyp:gmock',
         '../../testing/gtest.gyp:gtest',
+        '../../testing/gtest.gyp:gtest_main',
         '../../tools/gyp/v8.gyp:v8_libplatform',
       ],
       'include_dirs': [
         '../..',
       ],
       'sources': [  ### gcmole(all) ###
-        'heap-unittest.cc',
-        'heap-unittests.cc',
+        'gc-idle-time-handler-unittest.cc',
       ],
       'conditions': [
         ['component=="shared_library"', {
diff --git a/test/heap-unittests/DEPS b/test/heap-unittests/DEPS
deleted file mode 100644 (file)
index 9cae90b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-include_rules = [
-  "+src",
-  "+testing/gmock",
-  "+testing/gmock-support.h",
-  "+testing/gtest",
-  "+testing/gtest-support.h",
-]
diff --git a/test/heap-unittests/heap-unittest.h b/test/heap-unittests/heap-unittest.h
deleted file mode 100644 (file)
index 74da4e5..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef V8_HEAP_UNITTESTS_HEAP_UNITTEST_H_
-#define V8_HEAP_UNITTESTS_HEAP_UNITTEST_H_
-
-#include "src/heap/gc-idle-time-handler.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace v8 {
-namespace internal {
-
-class GCIdleTimeHandlerTest : public ::testing::Test {
- public:
-  GCIdleTimeHandlerTest() {}
-  virtual ~GCIdleTimeHandlerTest() {}
-
-  GCIdleTimeHandler* handler() { return &handler_; }
-
-  GCIdleTimeHandler::HeapState DefaultHeapState() {
-    GCIdleTimeHandler::HeapState result;
-    result.contexts_disposed = 0;
-    result.size_of_objects = kSizeOfObjects;
-    result.incremental_marking_stopped = false;
-    result.can_start_incremental_marking = true;
-    result.sweeping_in_progress = false;
-    result.mark_compact_speed_in_bytes_per_ms = kMarkCompactSpeed;
-    result.incremental_marking_speed_in_bytes_per_ms = kMarkingSpeed;
-    return result;
-  }
-
-  static const size_t kSizeOfObjects = 100 * MB;
-  static const size_t kMarkCompactSpeed = 100 * KB;
-  static const size_t kMarkingSpeed = 100 * KB;
-
- private:
-  GCIdleTimeHandler handler_;
-};
-}
-}
-#endif  // V8_HEAP_UNITTESTS_HEAP_UNITTEST_H_
diff --git a/test/heap-unittests/heap-unittests.cc b/test/heap-unittests/heap-unittests.cc
deleted file mode 100644 (file)
index e422c5e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "include/libplatform/libplatform.h"
-#include "include/v8.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-using testing::IsNull;
-using testing::NotNull;
-
-namespace {
-
-class HeapTestEnvironment V8_FINAL : public ::testing::Environment {
- public:
-  HeapTestEnvironment() : platform_(NULL) {}
-  virtual ~HeapTestEnvironment() {}
-
-  virtual void SetUp() V8_OVERRIDE {
-    EXPECT_THAT(platform_, IsNull());
-    platform_ = v8::platform::CreateDefaultPlatform();
-    v8::V8::InitializePlatform(platform_);
-    ASSERT_TRUE(v8::V8::Initialize());
-  }
-
-  virtual void TearDown() V8_OVERRIDE {
-    ASSERT_THAT(platform_, NotNull());
-    v8::V8::Dispose();
-    v8::V8::ShutdownPlatform();
-    delete platform_;
-    platform_ = NULL;
-  }
-
- private:
-  v8::Platform* platform_;
-};
-
-}  // namespace
-
-
-int main(int argc, char** argv) {
-  testing::InitGoogleMock(&argc, argv);
-  testing::AddGlobalTestEnvironment(new HeapTestEnvironment);
-  v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
-  return RUN_ALL_TESTS();
-}
diff --git a/test/heap-unittests/heap-unittests.h b/test/heap-unittests/heap-unittests.h
deleted file mode 100644 (file)
index 91266e9..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef V8_HEAP_UNITTESTS_HEAP_UNITTESTS_H_
-#define V8_HEAP_UNITTESTS_HEAP_UNITTESTS_H_
-
-#include "include/v8.h"
-#include "src/zone.h"
-#include "testing/gtest-support.h"
-
-namespace v8 {
-namespace internal {
-
-// Forward declarations.
-class Factory;
-class Heap;
-
-class RuntimeTest : public ::testing::Test {
- public:
-  RuntimeTest();
-  virtual ~RuntimeTest();
-
-  Factory* factory() const;
-  Heap* heap() const;
-  Isolate* isolate() const { return reinterpret_cast<Isolate*>(isolate_); }
-  Zone* zone() { return &zone_; }
-
-  static void SetUpTestCase();
-  static void TearDownTestCase();
-
- private:
-  static v8::Isolate* isolate_;
-  v8::Isolate::Scope isolate_scope_;
-  v8::HandleScope handle_scope_;
-  Zone zone_;
-};
-
-}  // namespace internal
-}  // namespace v8
-
-#endif  // V8_HEAP_UNITTESTS_HEAP_UNITTESTS_H_
diff --git a/test/runtime-unittests/DEPS b/test/runtime-unittests/DEPS
deleted file mode 100644 (file)
index 9cae90b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-include_rules = [
-  "+src",
-  "+testing/gmock",
-  "+testing/gmock-support.h",
-  "+testing/gtest",
-  "+testing/gtest-support.h",
-]
diff --git a/test/runtime-unittests/runtime-unittests.cc b/test/runtime-unittests/runtime-unittests.cc
deleted file mode 100644 (file)
index af06be1..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "include/libplatform/libplatform.h"
-#include "src/isolate-inl.h"
-#include "test/runtime-unittests/runtime-unittests.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-using testing::IsNull;
-using testing::NotNull;
-
-namespace v8 {
-namespace internal {
-
-// static
-v8::Isolate* RuntimeTest::isolate_ = NULL;
-
-
-RuntimeTest::RuntimeTest()
-    : isolate_scope_(isolate_), handle_scope_(isolate_), zone_(isolate()) {}
-
-
-RuntimeTest::~RuntimeTest() {}
-
-
-Factory* RuntimeTest::factory() const { return isolate()->factory(); }
-
-
-Heap* RuntimeTest::heap() const { return isolate()->heap(); }
-
-
-// static
-void RuntimeTest::SetUpTestCase() {
-  Test::SetUpTestCase();
-  EXPECT_THAT(isolate_, IsNull());
-  isolate_ = v8::Isolate::New();
-  ASSERT_THAT(isolate_, NotNull());
-}
-
-
-// static
-void RuntimeTest::TearDownTestCase() {
-  ASSERT_THAT(isolate_, NotNull());
-  isolate_->Dispose();
-  isolate_ = NULL;
-  Test::TearDownTestCase();
-}
-
-}  // namespace internal
-}  // namespace v8
-
-
-namespace {
-
-class RuntimeTestEnvironment V8_FINAL : public ::testing::Environment {
- public:
-  RuntimeTestEnvironment() : platform_(NULL) {}
-  virtual ~RuntimeTestEnvironment() {}
-
-  virtual void SetUp() V8_OVERRIDE {
-    EXPECT_THAT(platform_, IsNull());
-    platform_ = v8::platform::CreateDefaultPlatform();
-    v8::V8::InitializePlatform(platform_);
-    ASSERT_TRUE(v8::V8::Initialize());
-  }
-
-  virtual void TearDown() V8_OVERRIDE {
-    ASSERT_THAT(platform_, NotNull());
-    v8::V8::Dispose();
-    v8::V8::ShutdownPlatform();
-    delete platform_;
-    platform_ = NULL;
-  }
-
- private:
-  v8::Platform* platform_;
-};
-
-}  // namespace
-
-
-int main(int argc, char** argv) {
-  testing::InitGoogleMock(&argc, argv);
-  testing::AddGlobalTestEnvironment(new RuntimeTestEnvironment);
-  v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
-  return RUN_ALL_TESTS();
-}
diff --git a/test/runtime-unittests/runtime-unittests.gyp b/test/runtime-unittests/runtime-unittests.gyp
deleted file mode 100644 (file)
index b42e97f..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright 2014 the V8 project authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-{
-  'variables': {
-    'v8_code': 1,
-  },
-  'includes': ['../../build/toolchain.gypi', '../../build/features.gypi'],
-  'targets': [
-    {
-      'target_name': 'runtime-unittests',
-      'type': 'executable',
-      'dependencies': [
-        '../../testing/gmock.gyp:gmock',
-        '../../testing/gtest.gyp:gtest',
-        '../../tools/gyp/v8.gyp:v8_libplatform',
-      ],
-      'include_dirs': [
-        '../..',
-      ],
-      'sources': [  ### gcmole(all) ###
-        'runtime-unittests.h',
-        'runtime-unittests.cc',
-      ],
-      'conditions': [
-        ['component=="shared_library"', {
-          # runtime-unittests can't be built against a shared library, so we
-          # need to depend on the underlying static target in that case.
-          'conditions': [
-            ['v8_use_snapshot=="true"', {
-              'dependencies': ['../../tools/gyp/v8.gyp:v8_snapshot'],
-            },
-            {
-              'dependencies': [
-                '../../tools/gyp/v8.gyp:v8_nosnapshot',
-              ],
-            }],
-          ],
-        }, {
-          'dependencies': ['../../tools/gyp/v8.gyp:v8'],
-        }],
-        ['os_posix == 1', {
-          # TODO(svenpanne): This is a temporary work-around to fix the warnings
-          # that show up because we use -std=gnu++0x instead of -std=c++11.
-          'cflags!': [
-            '-pedantic',
-          ],
-        }],
-      ],
-    },
-  ],
-}
diff --git a/test/runtime-unittests/runtime-unittests.h b/test/runtime-unittests/runtime-unittests.h
deleted file mode 100644 (file)
index e484fdc..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef V8_RUNTIME_UNITTESTS_RUNTIME_UNITTESTS_H_
-#define V8_RUNTIME_UNITTESTS_RUNTIME_UNITTESTS_H_
-
-#include "include/v8.h"
-#include "src/zone.h"
-#include "testing/gtest-support.h"
-
-namespace v8 {
-namespace internal {
-
-// Forward declarations.
-class Factory;
-class Heap;
-
-class RuntimeTest : public ::testing::Test {
- public:
-  RuntimeTest();
-  virtual ~RuntimeTest();
-
-  Factory* factory() const;
-  Heap* heap() const;
-  Isolate* isolate() const { return reinterpret_cast<Isolate*>(isolate_); }
-  Zone* zone() { return &zone_; }
-
-  static void SetUpTestCase();
-  static void TearDownTestCase();
-
- private:
-  static v8::Isolate* isolate_;
-  v8::Isolate::Scope isolate_scope_;
-  v8::HandleScope handle_scope_;
-  Zone zone_;
-};
-
-}  // namespace internal
-}  // namespace v8
-
-#endif  // V8_RUNTIME_UNITTESTS_RUNTIME_UNITTESTS_H_
diff --git a/test/runtime-unittests/runtime-unittests.status b/test/runtime-unittests/runtime-unittests.status
deleted file mode 100644 (file)
index d439913..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 2014 the V8 project authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-[
-]
diff --git a/test/runtime-unittests/testcfg.py b/test/runtime-unittests/testcfg.py
deleted file mode 100644 (file)
index 0b4af6d..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2014 the V8 project authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import os
-import shutil
-
-from testrunner.local import commands
-from testrunner.local import testsuite
-from testrunner.local import utils
-from testrunner.objects import testcase
-
-
-class RuntimeUnitTestsSuite(testsuite.TestSuite):
-  def __init__(self, name, root):
-    super(RuntimeUnitTestsSuite, self).__init__(name, root)
-
-  def ListTests(self, context):
-    shell = os.path.abspath(os.path.join(context.shell_dir, self.shell()))
-    if utils.IsWindows():
-      shell += ".exe"
-    output = commands.Execute(context.command_prefix +
-                              [shell, "--gtest_list_tests"] +
-                              context.extra_flags)
-    if output.exit_code != 0:
-      print output.stdout
-      print output.stderr
-      return []
-    tests = []
-    test_case = ''
-    for line in output.stdout.splitlines():
-      test_desc = line.strip().split()[0]
-      if test_desc.endswith('.'):
-        test_case = test_desc
-      elif test_case and test_desc:
-        test = testcase.TestCase(self, test_case + test_desc, dependency=None)
-        tests.append(test)
-    tests.sort()
-    return tests
-
-  def GetFlagsForTestCase(self, testcase, context):
-    return (testcase.flags + ["--gtest_filter=" + testcase.path] +
-            ["--gtest_random_seed=%s" % context.random_seed] +
-            ["--gtest_print_time=0"] +
-            context.mode_flags)
-
-  def shell(self):
-    return "runtime-unittests"
-
-
-def GetSuite(name, root):
-  return RuntimeUnitTestsSuite(name, root)
index 75da5ba..1ef1e9c 100755 (executable)
@@ -238,9 +238,7 @@ class CppLintProcessor(SourceFileProcessor):
   def GetPathsToSearch(self):
     return ['src', 'include', 'samples',
             join('test', 'cctest'),
-            join('test', 'compiler-unittests'),
-            join('test', 'heap-unittests'),
-            join('test', 'runtime-unittests')]
+            join('test', 'compiler-unittests')]
 
   def GetCpplintScript(self, prio_path):
     for path in [prio_path] + os.environ["PATH"].split(os.pathsep):
index e7c3f7f..e1c11c3 100755 (executable)
@@ -52,8 +52,7 @@ from testrunner.objects import context
 ARCH_GUESS = utils.DefaultArch()
 DEFAULT_TESTS = ["mjsunit", "fuzz-natives", "base-unittests",
                  "cctest", "compiler-unittests", "heap-unittests",
-                 "libplatform-unittests", "runtime-unittests",
-                 "message", "preparser"]
+                 "libplatform-unittests", "message", "preparser"]
 TIMEOUT_DEFAULT = 60
 TIMEOUT_SCALEFACTOR = {"debug"   : 4,
                        "release" : 1 }