test/hotspot/gtest/utilities/test_chunkedList.cpp
author dfuchs
Fri, 06 Sep 2019 14:04:44 +0100
changeset 58031 5aaf53d4fe63
parent 47216 71c04702a3d5
permissions -rw-r--r--
8230694: http.keepAlive system property is inconsistently/incorrectly documented Summary: trivially fixed the net-properties.html file Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
     1
/*
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
     4
 *
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
     7
 * published by the Free Software Foundation.
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
     8
 *
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    13
 * accompanied this code).
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    14
 *
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    18
 *
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    21
 * questions.
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    22
 */
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    23
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    24
#include "precompiled.hpp"
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    25
#include "unittest.hpp"
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    26
#include "utilities/chunkedList.hpp"
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    27
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    28
class Metadata;
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    29
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    30
template <typename T>
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    31
class TestChunkedList {
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    32
  typedef ChunkedList<T, mtOther> ChunkedListT;
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    33
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    34
 public:
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    35
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    36
  static void testEmpty() {
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    37
    ChunkedListT buffer;
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    38
    ASSERT_EQ((size_t) 0, buffer.size());
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    39
  }
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    40
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    41
  static void testFull() {
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    42
    ChunkedListT buffer;
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    43
    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    44
      buffer.push((T) i);
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    45
    }
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    46
    ASSERT_EQ((size_t) ChunkedListT::BufferSize, buffer.size());
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    47
    ASSERT_TRUE(buffer.is_full());
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    48
  }
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    49
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    50
  static void testSize() {
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    51
    ChunkedListT buffer;
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    52
    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    53
      ASSERT_EQ((size_t) i, buffer.size());
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    54
      buffer.push((T) i);
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    55
      ASSERT_EQ((size_t) (i + 1), buffer.size());
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    56
    }
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    57
  }
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    58
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    59
  static void testClear() {
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    60
    ChunkedListT buffer;
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    61
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    62
    buffer.clear();
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    63
    ASSERT_EQ((size_t) 0, buffer.size());
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    64
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    65
    for (uintptr_t i = 0; i < ChunkedListT::BufferSize / 2; i++) {
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    66
      buffer.push((T) i);
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    67
    }
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    68
    buffer.clear();
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    69
    ASSERT_EQ((size_t) 0, buffer.size());
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    70
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    71
    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    72
      buffer.push((T) i);
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    73
    }
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    74
    buffer.clear();
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    75
    ASSERT_EQ((size_t) 0, buffer.size());
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    76
  }
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    77
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    78
  static void testAt() {
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    79
    ChunkedListT buffer;
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    80
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    81
    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    82
      buffer.push((T) i);
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    83
      ASSERT_EQ((T) i, buffer.at(i));
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    84
    }
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    85
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    86
    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    87
      ASSERT_EQ((T) i, buffer.at(i));
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    88
    }
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    89
  }
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    90
};
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    91
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    92
TEST(ChunkedList, metadata_empty) {
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    93
  TestChunkedList<Metadata*>::testEmpty();
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    94
}
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    95
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    96
TEST(ChunkedList, metadata_full) {
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    97
  TestChunkedList<Metadata*>::testFull();
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
    98
}
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
    99
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   100
TEST(ChunkedList, metadata_size) {
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   101
  TestChunkedList<Metadata*>::testSize();
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   102
}
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   103
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   104
TEST(ChunkedList, metadata_clear) {
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   105
  TestChunkedList<Metadata*>::testSize();
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   106
}
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   107
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   108
TEST(ChunkedList, metadata_at) {
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   109
  TestChunkedList<Metadata*>::testAt();
27247
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
   110
}
99db666dbe8e 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff changeset
   111
41312
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   112
TEST(ChunkedList, size_t_empty) {
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   113
  TestChunkedList<size_t>::testEmpty();
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   114
}
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   115
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   116
TEST(ChunkedList, size_t_full) {
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   117
  TestChunkedList<size_t>::testFull();
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   118
}
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   119
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   120
TEST(ChunkedList, size_t_size) {
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   121
  TestChunkedList<size_t>::testSize();
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   122
}
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   123
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   124
TEST(ChunkedList, size_t_clear) {
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   125
  TestChunkedList<size_t>::testSize();
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   126
}
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   127
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   128
TEST(ChunkedList, size_t_at) {
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   129
  TestChunkedList<size_t>::testAt();
90c5e4348212 8165602: Convert TestChunkedList_test to GTest
kzhaldyb
parents: 27247
diff changeset
   130
}