hotspot/test/native/runtime/test_os.cpp
author ehelin
Mon, 13 Jun 2016 13:48:37 +0200
changeset 39394 044a0eb96215
parent 38255 5784bccf53b0
child 41705 332239c052cc
permissions -rw-r--r--
8159364: Gtest unit tests does not support PCH Reviewed-by: erikj, jwilhelm, gtriantafill
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38255
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
     1
/*
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
     4
 *
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
     8
 *
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    14
 *
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    18
 *
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    21
 * questions.
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    22
 *
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    23
 */
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    24
39394
044a0eb96215 8159364: Gtest unit tests does not support PCH
ehelin
parents: 38255
diff changeset
    25
#include "precompiled.hpp"
38255
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    26
#include "runtime/os.hpp"
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    27
#include "unittest.hpp"
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    28
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    29
TEST_VM(os, page_size_for_region) {
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    30
  size_t large_page_example = 4 * M;
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    31
  size_t large_page = os::page_size_for_region_aligned(large_page_example, 1);
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    32
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    33
  size_t small_page = os::vm_page_size();
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    34
  if (large_page > small_page) {
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    35
    size_t num_small_in_large = large_page / small_page;
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    36
    size_t page = os::page_size_for_region_aligned(large_page, num_small_in_large);
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    37
    ASSERT_EQ(page, small_page) << "Did not get a small page";
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    38
  }
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    39
}
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    40
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    41
#ifdef ASSERT
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    42
TEST_VM_ASSERT_MSG(os, page_size_for_region_with_zero_min_pages, "sanity") {
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    43
  size_t region_size = 16 * os::vm_page_size();
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    44
  os::page_size_for_region_aligned(region_size, 0); // should assert
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    45
}
5784bccf53b0 8148244: Finalize and integrate GTest implementation
iignatyev
parents:
diff changeset
    46
#endif