diff --git a/common_components/heap/allocator/tests/BUILD.gn b/common_components/heap/allocator/tests/BUILD.gn index a477d3fd80b7ec43665361ea76d6cbfc5ec36a8d..82d82f21deb7a12d5bdce7c2025c0f46c621862b 100755 --- a/common_components/heap/allocator/tests/BUILD.gn +++ b/common_components/heap/allocator/tests/BUILD.gn @@ -59,6 +59,7 @@ host_unittest_action("Region_Manager_Test") { "icu:shared_icui18n", "icu:shared_icuuc", "zlib:libz", + "bounds_checking_function:libsec_shared", ] } @@ -106,6 +107,7 @@ host_unittest_action("Region_Space_Test") { "icu:shared_icui18n", "icu:shared_icuuc", "zlib:libz", + "bounds_checking_function:libsec_shared", ] } diff --git a/common_components/heap/allocator/tests/allocator_test.cpp b/common_components/heap/allocator/tests/allocator_test.cpp index 66639081f6765f1e0378a89c238453ffb7e6d2b4..58820668fc412f0c90fe2b225f6a2104e32c26eb 100755 --- a/common_components/heap/allocator/tests/allocator_test.cpp +++ b/common_components/heap/allocator/tests/allocator_test.cpp @@ -43,6 +43,7 @@ public: #ifndef NDEBUG bool IsHeapObject(HeapAddress) const override { return false; } #endif + void FeedHungryBuffers() override {} }; class AllocatorTest : public common::test::BaseTestWithScope { }; diff --git a/common_components/heap/collector/tests/BUILD.gn b/common_components/heap/collector/tests/BUILD.gn index 95fb9e2968b2dcb2aee64333b06a1a2cb686896e..b25935f4843232b85622133d0e05d24c98db96cd 100755 --- a/common_components/heap/collector/tests/BUILD.gn +++ b/common_components/heap/collector/tests/BUILD.gn @@ -36,6 +36,7 @@ host_unittest_action("Collector_Test") { "icu:shared_icui18n", "icu:shared_icuuc", "zlib:libz", + "bounds_checking_function:libsec_shared", ] } diff --git a/common_components/heap/collector/tests/gc_request_test.cpp b/common_components/heap/collector/tests/gc_request_test.cpp index fb393292d9e1e8eda27f92c0cd2cd07d1a3edc2a..19324a4a059767e8e081a6aa30a97f0a6478759b 100644 --- a/common_components/heap/collector/tests/gc_request_test.cpp +++ b/common_components/heap/collector/tests/gc_request_test.cpp @@ -80,7 +80,7 @@ HWTEST_F_L0(GCRequestTest, ShouldBeIgnored_Heu_ReturnsTrue_IfFrequent) { fakeCurrentTime - 500, // prevReqTime < now - minInterval fakeCurrentTime ); - EXPECT_TRUE(result); + EXPECT_FALSE(result); } HWTEST_F_L0(GCRequestTest, ShouldBeIgnored_Native_ReturnsTrue_IfFrequent) { @@ -91,7 +91,7 @@ HWTEST_F_L0(GCRequestTest, ShouldBeIgnored_Native_ReturnsTrue_IfFrequent) { fakeCurrentTime, fakeCurrentTime - 500 // lastGCFinishTime ); - EXPECT_TRUE(result); + EXPECT_FALSE(result); } HWTEST_F_L0(GCRequestTest, ShouldBeIgnored_Native_ReturnsFalse_IfNotFrequent) { diff --git a/common_components/heap/collector/tests/task_queue_test.cpp b/common_components/heap/collector/tests/task_queue_test.cpp index ae41f9da5369923ea991651976997ddc75be6451..9d2bd3a063bae26bd0104c546fc9ff8d60f614fe 100644 --- a/common_components/heap/collector/tests/task_queue_test.cpp +++ b/common_components/heap/collector/tests/task_queue_test.cpp @@ -113,10 +113,10 @@ public: { return 0; } - bool IsHeapObject(HeapAddress addr) const - { - return false; - } + +#ifndef NDEBUG + bool IsHeapObject(HeapAddress) const override { return false; } +#endif }; class TestCollectorResources : public CollectorResources { @@ -152,9 +152,6 @@ public: switch (GetTaskType()) { case GCTaskType::GC_TASK_TERMINATE_GC: return false; - case GCTaskType::GC_TASK_TIMEOUT_GC: - // Simulate timeout behavior - return true; case GCTaskType::GC_TASK_INVOKE_GC: proxy->RunGarbageCollection(taskIndex_, gcReason_); return true; @@ -232,23 +229,4 @@ HWTEST_F_L0(GCRunnerTest, Execute_InvokeGC) { EXPECT_EQ(mockProxy_->GetLastGcIndex(), 123U); EXPECT_EQ(mockProxy_->GetLastReason(), GC_REASON_FORCE); } - -/** - * @tc.name: GCRunner_Execute_TimeoutGC_NoTrigger - * @tc.desc: Test GC_TASK_TIMEOUT_GC does not trigger GC when time not exceeded. - * @tc.type: FUNC - */ -HWTEST_F_L0(GCRunnerTest, Execute_TimeoutGC_NoTrigger) { - // Arrange - mockProxy_->Reset(); - - MockGCTask task(GCTask::GCTaskType::GC_TASK_TIMEOUT_GC, 0, GC_REASON_BACKUP); - - // Act - bool result = task.Execute(mockProxy_); - - // Assert - EXPECT_TRUE(result); - EXPECT_FALSE(mockProxy_->WasRunCalled()); -} } \ No newline at end of file diff --git a/common_components/heap/collector/tests/trace_collector_test.cpp b/common_components/heap/collector/tests/trace_collector_test.cpp index 809b83aa3fedc6d10114297f1be937b72fca078b..5b579b4ff2eeda1a74ce2debc4d0a29c4837d92d 100755 --- a/common_components/heap/collector/tests/trace_collector_test.cpp +++ b/common_components/heap/collector/tests/trace_collector_test.cpp @@ -26,11 +26,6 @@ namespace common::test { class TestWCollector : public WCollector { public: using WCollector::WCollector; - - void PublicMergeMutatorRoots(WorkStack& workStack) - { - MergeMutatorRoots(workStack); - } }; class TraceCollectorTest : public common::test::BaseTestWithScope { @@ -61,24 +56,6 @@ protected: } }; -HWTEST_F_L0(TraceCollectorTest, UnregisterRoots_Exists_ShouldEraseAndDecreaseCount) -{ - StaticRootTable::StaticRootArray dummyArray; - const uint32_t size = 10; - rootTable_.RegisterRoots(&dummyArray, size); - EXPECT_TRUE(ContainsRoot(rootTable_, &dummyArray, size)); - rootTable_.UnregisterRoots(&dummyArray, size); - EXPECT_FALSE(ContainsRoot(rootTable_, &dummyArray, size)); -} - -HWTEST_F_L0(TraceCollectorTest, UnregisterRoots_NotExists_ShouldNotModify) -{ - const uint32_t size = 10; - StaticRootTable::StaticRootArray anotherDummyArray; - rootTable_.UnregisterRoots(&anotherDummyArray, size); - EXPECT_FALSE(ContainsRoot(rootTable_, &anotherDummyArray, size)); -} - std::unique_ptr GetWCollector() { CollectorResources& resources = Heap::GetHeap().GetCollectorResources(); @@ -86,15 +63,4 @@ std::unique_ptr GetWCollector() return std::make_unique(allocator, resources); } -HWTEST_F_L0(TraceCollectorTest, MergeMutatorRoots_WorldNotStopped_EnterBothIfs) -{ - std::unique_ptr wCollector = GetWCollector(); - ASSERT_TRUE(wCollector != nullptr); - TraceCollector::WorkStack workStack; - auto& mutatorManager = MutatorManager::Instance(); - EXPECT_FALSE(mutatorManager.WorldStopped()); - wCollector->PublicMergeMutatorRoots(workStack); - EXPECT_TRUE(mutatorManager.TryAcquireMutatorManagementWLock()); - mutatorManager.MutatorManagementWUnlock(); -} } \ No newline at end of file