Commit add25d73 authored by Feng Yu's avatar Feng Yu Committed by V8 LUCI CQ

[test] Migrate cctest/test-local-handles to unittests/

Bug: v8:12781
Change-Id: I759024fb18ee596ecb678e5b70c95235ea91e520
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3827126Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82464}
parent 585ca904
...@@ -191,7 +191,6 @@ v8_source_set("cctest_sources") { ...@@ -191,7 +191,6 @@ v8_source_set("cctest_sources") {
"test-inspector.cc", "test-inspector.cc",
"test-js-weak-refs.cc", "test-js-weak-refs.cc",
"test-liveedit.cc", "test-liveedit.cc",
"test-local-handles.cc",
"test-lockers.cc", "test-lockers.cc",
"test-mementos.cc", "test-mementos.cc",
"test-orderedhashtable.cc", "test-orderedhashtable.cc",
......
...@@ -100,9 +100,6 @@ ...@@ -100,9 +100,6 @@
'test-code-stub-assembler/PopAndReturnFromJSBuiltinWithStackParameters' : [FAIL], 'test-code-stub-assembler/PopAndReturnFromJSBuiltinWithStackParameters' : [FAIL],
'test-code-stub-assembler/PopAndReturnFromTFCBuiltinWithStackParameters' : [FAIL], 'test-code-stub-assembler/PopAndReturnFromTFCBuiltinWithStackParameters' : [FAIL],
# These tests are supposed to fail in a slow DCHECK, skip them otherwise.
'test-local-handles/DereferenceLocalHandleFailsWhenDisallowed': [SKIP, ['mode == debug', FAIL]],
# Slow tests. # Slow tests.
'test-api/InternalFieldsSubclassing': [PASS, SLOW], 'test-api/InternalFieldsSubclassing': [PASS, SLOW],
'test-debug/CallFunctionInDebugger': [PASS, ['mode == debug', SLOW]], 'test-debug/CallFunctionInDebugger': [PASS, ['mode == debug', SLOW]],
......
...@@ -380,6 +380,7 @@ v8_source_set("unittests_sources") { ...@@ -380,6 +380,7 @@ v8_source_set("unittests_sources") {
"heap/lab-unittest.cc", "heap/lab-unittest.cc",
"heap/list-unittest.cc", "heap/list-unittest.cc",
"heap/local-factory-unittest.cc", "heap/local-factory-unittest.cc",
"heap/local-handles-unittest.cc",
"heap/local-heap-unittest.cc", "heap/local-heap-unittest.cc",
"heap/marking-inner-pointer-resolution-unittest.cc", "heap/marking-inner-pointer-resolution-unittest.cc",
"heap/marking-unittest.cc", "heap/marking-unittest.cc",
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "src/handles/local-handles.h"
#include <memory> #include <memory>
#include "src/api/api.h" #include "src/api/api.h"
...@@ -10,16 +12,17 @@ ...@@ -10,16 +12,17 @@
#include "src/common/globals.h" #include "src/common/globals.h"
#include "src/handles/handles-inl.h" #include "src/handles/handles-inl.h"
#include "src/handles/local-handles-inl.h" #include "src/handles/local-handles-inl.h"
#include "src/handles/local-handles.h"
#include "src/heap/heap.h" #include "src/heap/heap.h"
#include "src/heap/local-heap.h" #include "src/heap/local-heap.h"
#include "src/heap/parked-scope.h" #include "src/heap/parked-scope.h"
#include "src/objects/heap-number.h" #include "src/objects/heap-number.h"
#include "test/cctest/cctest.h" #include "test/unittests/test-utils.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
using LocalHandlesTest = TestWithIsolate;
namespace { namespace {
class LocalHandlesThread final : public v8::base::Thread { class LocalHandlesThread final : public v8::base::Thread {
...@@ -67,9 +70,8 @@ class LocalHandlesThread final : public v8::base::Thread { ...@@ -67,9 +70,8 @@ class LocalHandlesThread final : public v8::base::Thread {
base::Semaphore* sema_gc_finished_; base::Semaphore* sema_gc_finished_;
}; };
TEST(CreateLocalHandles) { TEST_F(LocalHandlesTest, CreateLocalHandles) {
CcTest::InitializeVM(); Isolate* isolate = i_isolate();
Isolate* isolate = CcTest::i_isolate();
Address object = kNullAddress; Address object = kNullAddress;
...@@ -88,23 +90,21 @@ TEST(CreateLocalHandles) { ...@@ -88,23 +90,21 @@ TEST(CreateLocalHandles) {
sema_started.Wait(); sema_started.Wait();
CcTest::CollectAllGarbage(); CollectAllGarbage();
sema_gc_finished.Signal(); sema_gc_finished.Signal();
thread->Join(); thread->Join();
} }
TEST(CreateLocalHandlesWithoutLocalHandleScope) { TEST_F(LocalHandlesTest, CreateLocalHandlesWithoutLocalHandleScope) {
CcTest::InitializeVM(); Isolate* isolate = i_isolate();
Isolate* isolate = CcTest::i_isolate();
HandleScope handle_scope(isolate); HandleScope handle_scope(isolate);
handle(Smi::FromInt(17), isolate->main_thread_local_heap()); handle(Smi::FromInt(17), isolate->main_thread_local_heap());
} }
TEST(DereferenceLocalHandle) { TEST_F(LocalHandlesTest, DereferenceLocalHandle) {
CcTest::InitializeVM(); Isolate* isolate = i_isolate();
Isolate* isolate = CcTest::i_isolate();
// Create a PersistentHandle to create the LocalHandle, and thus not have a // Create a PersistentHandle to create the LocalHandle, and thus not have a
// HandleScope present to override the LocalHandleScope. // HandleScope present to override the LocalHandleScope.
...@@ -125,9 +125,8 @@ TEST(DereferenceLocalHandle) { ...@@ -125,9 +125,8 @@ TEST(DereferenceLocalHandle) {
} }
} }
TEST(DereferenceLocalHandleFailsWhenDisallowed) { TEST_F(LocalHandlesTest, DereferenceLocalHandleFailsWhenDisallowed) {
CcTest::InitializeVM(); Isolate* isolate = i_isolate();
Isolate* isolate = CcTest::i_isolate();
// Create a PersistentHandle to create the LocalHandle, and thus not have a // Create a PersistentHandle to create the LocalHandle, and thus not have a
// HandleScope present to override the LocalHandleScope. // HandleScope present to override the LocalHandleScope.
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
'PlatformTest.StackAlignment': [PASS, ['not is_clang', SKIP]], 'PlatformTest.StackAlignment': [PASS, ['not is_clang', SKIP]],
# These tests are supposed to fail in a slow DCHECK, skip them otherwise. # These tests are supposed to fail in a slow DCHECK, skip them otherwise.
'LocalHandlesTest.DereferenceLocalHandleFailsWhenDisallowed': [SKIP, ['mode == debug', FAIL]],
'PersistentHandlesTest.DereferencePersistentHandleFailsWhenDisallowed': [SKIP, ['mode == debug', FAIL]], 'PersistentHandlesTest.DereferencePersistentHandleFailsWhenDisallowed': [SKIP, ['mode == debug', FAIL]],
'IntlTest.StringLocaleCompareFastPath': [['mode != release', SKIP], SLOW, NO_VARIANTS], 'IntlTest.StringLocaleCompareFastPath': [['mode != release', SKIP], SLOW, NO_VARIANTS],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment