hotspot/test/runtime/logging/ClassInitializationTest.java
author rprotacio
Fri, 18 Dec 2015 14:30:13 -0500
changeset 35193 1e85994e9f56
parent 34628 6d08ec72803b
child 35858 6e704583a38f
permissions -rw-r--r--
8145445: [TESTBUG] runtime/logging tests need to properly build and import libraries Summary: Adds the proper @build and import lines to the jtreg tests in the runtime/logging directory. Reviewed-by: iklam, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     1
/*
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     4
 *
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     8
 *
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    13
 * accompanied this code).
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    14
 *
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    18
 *
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    21
 * questions.
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    22
 */
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    23
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    24
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    25
/*
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    26
 * @test ClassInitializationTest
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    27
 * @bug 8142976
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    28
 * @library /testlibrary
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    29
 * @compile BadMap50.jasm
35193
1e85994e9f56 8145445: [TESTBUG] runtime/logging tests need to properly build and import libraries
rprotacio
parents: 34628
diff changeset
    30
 * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.Platform jdk.test.lib.ProcessTools
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    31
 * @run driver ClassInitializationTest
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    32
 */
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    33
35193
1e85994e9f56 8145445: [TESTBUG] runtime/logging tests need to properly build and import libraries
rprotacio
parents: 34628
diff changeset
    34
import jdk.test.lib.OutputAnalyzer;
1e85994e9f56 8145445: [TESTBUG] runtime/logging tests need to properly build and import libraries
rprotacio
parents: 34628
diff changeset
    35
import jdk.test.lib.Platform;
1e85994e9f56 8145445: [TESTBUG] runtime/logging tests need to properly build and import libraries
rprotacio
parents: 34628
diff changeset
    36
import jdk.test.lib.ProcessTools;
34628
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    37
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    38
public class ClassInitializationTest {
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    39
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    40
    public static void main(String... args) throws Exception {
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    41
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    42
        // (1)
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    43
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:classinit=info", "-Xverify:all", "-Xmx64m", "BadMap50");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    44
        OutputAnalyzer out = new OutputAnalyzer(pb.start());
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    45
        out.shouldContain("Start class verification for:");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    46
        out.shouldContain("End class verification for:");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    47
        out.shouldContain("Initializing");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    48
        out.shouldContain("Verification for BadMap50 failed");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    49
        out.shouldContain("Fail over class verification to old verifier for: BadMap50");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    50
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    51
        // (2)
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    52
        if (Platform.isDebugBuild()) {
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    53
          pb = ProcessTools.createJavaProcessBuilder("-Xlog:classinit=info", "-Xverify:all", "-XX:+EagerInitialization", "-Xmx64m", "-version");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    54
          out = new OutputAnalyzer(pb.start());
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    55
          out.shouldContain("[Initialized").shouldContain("without side effects]");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    56
          out.shouldHaveExitValue(0);
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    57
        }
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    58
        // (3) Ensure that VerboseVerification still triggers appropriate messages.
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    59
        pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:+VerboseVerification", "-Xverify:all", "-Xmx64m", "BadMap50");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    60
        out = new OutputAnalyzer(pb.start());
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    61
        out.shouldContain("End class verification for:");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    62
        out.shouldContain("Verification for BadMap50 failed");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    63
        out.shouldContain("Fail over class verification to old verifier for: BadMap50");
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    64
    }
6d08ec72803b 8142976: Reimplement TraceClassInitialization with Unified Logging
mockner
parents:
diff changeset
    65
}