test/hotspot/jtreg/serviceability/sa/TestIntConstant.java
author lkorinth
Wed, 13 Nov 2019 11:37:29 +0100
changeset 59053 ba6c248cae19
parent 53635 247e5ca412f5
permissions -rw-r--r--
8232365: Implementation for JEP 363: Remove the Concurrent Mark Sweep (CMS) Garbage Collector Reviewed-by: kbarrett, tschatzl, erikj, coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47900
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
     1
/*
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
     2
 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
47900
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
     4
 *
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
     7
 * published by the Free Software Foundation.
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
     8
 *
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    13
 * accompanied this code).
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    14
 *
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    18
 *
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    21
 * questions.
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    22
 */
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    23
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    24
import java.util.ArrayList;
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    25
import java.util.List;
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    26
import jdk.test.lib.apps.LingeredApp;
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    27
import jdk.test.lib.Utils;
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    28
import java.util.Map;
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    29
import java.util.HashMap;
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    30
import jtreg.SkippedException;
47900
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    31
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 49629
diff changeset
    32
/**
47900
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    33
 * @test
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    34
 * @summary Test the 'intConstant' command of jhsdb clhsdb.
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    35
 * @bug 8190307
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 49629
diff changeset
    36
 * @requires vm.hasSAandCanAttach
47900
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    37
 * @library /test/lib
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    38
 * @build jdk.test.lib.apps.*
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    39
 * @run main/othervm TestIntConstant
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    40
 */
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    41
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    42
public class TestIntConstant {
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    43
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    44
    public static void main (String... args) throws Exception {
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    45
        System.out.println("Starting TestIntConstant test");
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    46
        LingeredApp app = null;
47900
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    47
        try {
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    48
            ClhsdbLauncher test = new ClhsdbLauncher();
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    49
            List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
47900
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    50
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    51
            app = LingeredApp.startApp(vmArgs);
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    52
47900
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    53
            System.out.println ("Started LingeredApp with pid " + app.getPid());
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    54
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    55
            List<String> cmds = List.of("intConstant",
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    56
                                        "intConstant _temp_constant 45",
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    57
                                        "intConstant _temp_constant");
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    58
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    59
            Map<String, List<String>> expStrMap = new HashMap<>();
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    60
47900
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    61
            // Strings to check for in the output of 'intConstant'. The
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    62
            // 'intConstant' command prints out entries from the
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    63
            // 'gHotSpotVMIntConstants', which is a table of integer constants,
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    64
            // with names and the values derived from enums and #define preprocessor
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    65
            // macros in hotspot.
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    66
            expStrMap.put("intConstant", List.of(
59053
ba6c248cae19 8232365: Implementation for JEP 363: Remove the Concurrent Mark Sweep (CMS) Garbage Collector
lkorinth
parents: 53635
diff changeset
    67
                 "CollectedHeap::G1 3",
47900
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    68
                 "RUNNABLE 2",
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    69
                 "Deoptimization::Reason_class_check 4",
51444
3e5d28e6de32 8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents: 50791
diff changeset
    70
                 "InstanceKlass::_misc_is_unsafe_anonymous 32",
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    71
                 "_thread_uninitialized 0"));
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    72
            expStrMap.put("intConstant _temp_constant", List.of(
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    73
                 "intConstant _temp_constant 45"));
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    74
            test.run(app.getPid(), cmds, expStrMap, null);
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    75
        } catch (SkippedException se) {
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    76
            throw se;
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    77
        } catch (Exception ex) {
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    78
            throw new RuntimeException("Test ERROR " + ex, ex);
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    79
        } finally {
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    80
            LingeredApp.stopApp(app);
47900
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    81
        }
53635
247e5ca412f5 8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents: 51444
diff changeset
    82
        System.out.println("Test PASSED");
47900
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    83
    }
75d365bfc2e6 8190307: SA tests for the clhsdb commands: universe, intconstant, type
jgeorge
parents:
diff changeset
    84
}