Setup heap-unittests and runtime-unittests.
authorbmeurer@chromium.org <bmeurer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 19 Aug 2014 10:54:54 +0000 (10:54 +0000)
committerbmeurer@chromium.org <bmeurer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 19 Aug 2014 10:54:54 +0000 (10:54 +0000)
Initial import of empty unit test suites for Toon and Hannes.

R=hpayer@chromium.org

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

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

15 files changed:
build/all.gyp
test/heap-unittests/DEPS [new file with mode: 0644]
test/heap-unittests/heap-unittest.cc [new file with mode: 0644]
test/heap-unittests/heap-unittests.cc [new file with mode: 0644]
test/heap-unittests/heap-unittests.gyp [new file with mode: 0644]
test/heap-unittests/heap-unittests.h [new file with mode: 0644]
test/heap-unittests/heap-unittests.status [new file with mode: 0644]
test/heap-unittests/testcfg.py [new file with mode: 0644]
test/runtime-unittests/DEPS [new file with mode: 0644]
test/runtime-unittests/runtime-unittests.cc [new file with mode: 0644]
test/runtime-unittests/runtime-unittests.gyp [new file with mode: 0644]
test/runtime-unittests/runtime-unittests.h [new file with mode: 0644]
test/runtime-unittests/runtime-unittests.status [new file with mode: 0644]
test/runtime-unittests/testcfg.py [new file with mode: 0644]
tools/run-tests.py

index 5e410a3..29fcb17 100644 (file)
@@ -13,6 +13,8 @@
         '../test/base-unittests/base-unittests.gyp:*',
         '../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"', {
diff --git a/test/heap-unittests/DEPS b/test/heap-unittests/DEPS
new file mode 100644 (file)
index 0000000..9cae90b
--- /dev/null
@@ -0,0 +1,7 @@
+include_rules = [
+  "+src",
+  "+testing/gmock",
+  "+testing/gmock-support.h",
+  "+testing/gtest",
+  "+testing/gtest-support.h",
+]
diff --git a/test/heap-unittests/heap-unittest.cc b/test/heap-unittests/heap-unittest.cc
new file mode 100644 (file)
index 0000000..ee1dcbc
--- /dev/null
@@ -0,0 +1,16 @@
+// 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 "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace internal {
+
+TEST(HeapTest, Dummy) {
+  EXPECT_FALSE(false);
+  EXPECT_TRUE(true);
+}
+
+}  // namespace internal
+}  // namespace v8
diff --git a/test/heap-unittests/heap-unittests.cc b/test/heap-unittests/heap-unittests.cc
new file mode 100644 (file)
index 0000000..e422c5e
--- /dev/null
@@ -0,0 +1,46 @@
+// 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.gyp b/test/heap-unittests/heap-unittests.gyp
new file mode 100644 (file)
index 0000000..99e638a
--- /dev/null
@@ -0,0 +1,53 @@
+# 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': 'heap-unittests',
+      'type': 'executable',
+      'dependencies': [
+        '../../testing/gmock.gyp:gmock',
+        '../../testing/gtest.gyp:gtest',
+        '../../tools/gyp/v8.gyp:v8_libplatform',
+      ],
+      'include_dirs': [
+        '../..',
+      ],
+      'sources': [  ### gcmole(all) ###
+        'heap-unittest.cc',
+        'heap-unittests.cc',
+      ],
+      'conditions': [
+        ['component=="shared_library"', {
+          # heap-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/heap-unittests/heap-unittests.h b/test/heap-unittests/heap-unittests.h
new file mode 100644 (file)
index 0000000..91266e9
--- /dev/null
@@ -0,0 +1,42 @@
+// 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/heap-unittests/heap-unittests.status b/test/heap-unittests/heap-unittests.status
new file mode 100644 (file)
index 0000000..d439913
--- /dev/null
@@ -0,0 +1,6 @@
+# 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/heap-unittests/testcfg.py b/test/heap-unittests/testcfg.py
new file mode 100644 (file)
index 0000000..7c80a75
--- /dev/null
@@ -0,0 +1,51 @@
+# 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 HeapUnitTestsSuite(testsuite.TestSuite):
+  def __init__(self, name, root):
+    super(HeapUnitTestsSuite, 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 test_desc in output.stdout.strip().split():
+      if test_desc.endswith('.'):
+        test_case = test_desc
+      else:
+        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 "heap-unittests"
+
+
+def GetSuite(name, root):
+  return HeapUnitTestsSuite(name, root)
diff --git a/test/runtime-unittests/DEPS b/test/runtime-unittests/DEPS
new file mode 100644 (file)
index 0000000..9cae90b
--- /dev/null
@@ -0,0 +1,7 @@
+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
new file mode 100644 (file)
index 0000000..af06be1
--- /dev/null
@@ -0,0 +1,88 @@
+// 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
new file mode 100644 (file)
index 0000000..b42e97f
--- /dev/null
@@ -0,0 +1,53 @@
+# 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
new file mode 100644 (file)
index 0000000..e484fdc
--- /dev/null
@@ -0,0 +1,42 @@
+// 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
new file mode 100644 (file)
index 0000000..d439913
--- /dev/null
@@ -0,0 +1,6 @@
+# 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
new file mode 100644 (file)
index 0000000..f89fadc
--- /dev/null
@@ -0,0 +1,51 @@
+# 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 test_desc in output.stdout.strip().split():
+      if test_desc.endswith('.'):
+        test_case = test_desc
+      else:
+        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 6e9f554..c3c2a09 100755 (executable)
@@ -51,7 +51,8 @@ from testrunner.objects import context
 
 ARCH_GUESS = utils.DefaultArch()
 DEFAULT_TESTS = ["mjsunit", "fuzz-natives", "base-unittests",
-                 "cctest", "compiler-unittests", "message", "preparser"]
+                 "cctest", "compiler-unittests", "heap-unittests",
+                 "runtime-unittests", "message", "preparser"]
 TIMEOUT_DEFAULT = 60
 TIMEOUT_SCALEFACTOR = {"debug"   : 4,
                        "release" : 1 }