Skip to content

Commit

Permalink
Test just the assignement operator as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
schmelter-sap committed Aug 7, 2023
1 parent b2d3f0b commit cf61859
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 108 deletions.
54 changes: 54 additions & 0 deletions test/hotspot/gtest/nmt/test_nmt_reserved_region.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2023 SAP SE. All rights reserved.
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#include "precompiled.hpp"
#include "runtime/os.hpp"
#include "services/memTracker.hpp"
#include "services/virtualMemoryTracker.hpp"
#include "unittest.hpp"

// Tests the assignment operator of ReservedMemoryRegion
TEST_VM(NMT, ReservedRegionCopy) {
address dummy1 = (address)0x10000000;
ReservedMemoryRegion region1(dummy1, os::vm_page_size(), CALLER_PC);
region1.add_committed_region(dummy1, os::vm_page_size(), CALLER_PC);
region1.set_flag(mtThreadStack);
region1.set_call_stack(NativeCallStack(&dummy1, 1));
address dummy2 = (address)0x20000000;
ReservedMemoryRegion region2(dummy2, os::vm_page_size(), CALLER_PC);
region2.add_committed_region(dummy2, os::vm_page_size(), CALLER_PC);
region2.set_flag(mtCode);
region2.set_call_stack(NativeCallStack(&dummy2, 1));

region2 = region1;

CommittedRegionIterator itr = region2.iterate_committed_regions();
const CommittedMemoryRegion* rgn = itr.next();
ASSERT_EQ(rgn->base(), dummy1); // Now we should see dummy1
ASSERT_EQ(region2.flag(), mtThreadStack); // Should be correct flag
ASSERT_EQ(region2.call_stack()->get_frame(0), dummy1); // Check the stack
rgn = itr.next();
ASSERT_EQ(rgn, (const CommittedMemoryRegion*)nullptr); // and nothing else
}

108 changes: 0 additions & 108 deletions test/hotspot/gtest/nmt/test_virtualMemoryTracker.cpp

This file was deleted.

0 comments on commit cf61859

Please sign in to comment.