node/deps/v8/test/unittests/diagnostics/gdb-jit-unittest.cc
Michaël Zasso 62719c5fd2
deps: update V8 to 9.5.172.19
PR-URL: https://github.com/nodejs/node/pull/40178
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2021-10-12 08:07:50 +02:00

59 lines
1.6 KiB
C++

// Copyright 2021 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 "src/diagnostics/gdb-jit.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
namespace internal {
namespace GDBJITInterface {
#ifdef ENABLE_GDB_JIT_INTERFACE
TEST(GDBJITTest, OverlapEntries) {
ClearCodeMapForTesting();
base::AddressRegion ar{10, 10};
AddRegionForTesting(ar);
// Full containment.
ASSERT_EQ(1u, NumOverlapEntriesForTesting({11, 2}));
// Overlap start.
ASSERT_EQ(1u, NumOverlapEntriesForTesting({5, 10}));
// Overlap end.
ASSERT_EQ(1u, NumOverlapEntriesForTesting({15, 10}));
// No overlap.
// Completely smaller.
ASSERT_EQ(0u, NumOverlapEntriesForTesting({5, 5}));
// Completely bigger.
ASSERT_EQ(0u, NumOverlapEntriesForTesting({20, 10}));
AddRegionForTesting({20, 10});
// Now we have 2 code entries that don't overlap:
// [ entry 1 ][entry 2]
// ^ 10 ^ 20
// Overlap none.
ASSERT_EQ(0u, NumOverlapEntriesForTesting({0, 5}));
ASSERT_EQ(0u, NumOverlapEntriesForTesting({30, 5}));
// Overlap one.
ASSERT_EQ(1u, NumOverlapEntriesForTesting({15, 5}));
ASSERT_EQ(1u, NumOverlapEntriesForTesting({20, 5}));
// Overlap both.
ASSERT_EQ(2u, NumOverlapEntriesForTesting({15, 10}));
ASSERT_EQ(2u, NumOverlapEntriesForTesting({5, 20}));
ASSERT_EQ(2u, NumOverlapEntriesForTesting({15, 20}));
ASSERT_EQ(2u, NumOverlapEntriesForTesting({0, 40}));
ClearCodeMapForTesting();
}
#endif
} // namespace GDBJITInterface
} // namespace internal
} // namespace v8