test/hotspot/jtreg/runtime/cds/appcds/CDSandJFR.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54927 1512d88b24c6
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
       
     1 /*
       
     2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  *
       
    23  */
       
    24 
       
    25 /**
       
    26  * @test
       
    27  * @summary Make sure CDS and JFR work together.
       
    28  * @requires vm.hasJFR & vm.cds
       
    29  * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes test-classes
       
    30  * @build Hello GetFlightRecorder
       
    31  * @run driver ClassFileInstaller -jar CDSandJFR.jar Hello GetFlightRecorder GetFlightRecorder$TestEvent GetFlightRecorder$SimpleEvent
       
    32  * @run main/othervm/timeout=500 CDSandJFR
       
    33  */
       
    34 
       
    35 import jdk.test.lib.BuildHelper;
       
    36 import jdk.test.lib.process.OutputAnalyzer;
       
    37 
       
    38 public class CDSandJFR {
       
    39     static String[] classes = {
       
    40         "jdk/jfr/Event",
       
    41         "jdk/jfr/events/FileReadEvent",
       
    42         "jdk/jfr/events/FileWriteEvent",
       
    43         "jdk/jfr/events/SocketReadEvent",
       
    44         "jdk/jfr/events/SocketWriteEvent",
       
    45         "jdk/jfr/events/ExceptionThrownEvent",
       
    46         "jdk/jfr/events/ExceptionStatisticsEvent",
       
    47         "jdk/jfr/events/ErrorThrownEvent",
       
    48         "jdk/jfr/events/ActiveSettingEvent",
       
    49         "jdk/jfr/events/ActiveRecordingEvent",
       
    50         "Hello",
       
    51         "GetFlightRecorder",
       
    52         "GetFlightRecorder$TestEvent",
       
    53     };
       
    54 
       
    55     public static void main(String[] args) throws Exception {
       
    56         test(classes);
       
    57     }
       
    58 
       
    59     static void test(String[] classes) throws Exception {
       
    60         String appJar = ClassFileInstaller.getJarPath("CDSandJFR.jar");
       
    61         OutputAnalyzer output;
       
    62         output = TestCommon.testDump(appJar, TestCommon.list(classes));
       
    63         TestCommon.checkDump(output, "Skipping jdk/jfr/Event: JFR event class");
       
    64 
       
    65         output = TestCommon.exec(appJar,
       
    66                                  "-XX:StartFlightRecording=dumponexit=true",
       
    67                                  "Hello");
       
    68         TestCommon.checkExec(output, "Hello World");
       
    69 
       
    70         TestCommon.checkExec(TestCommon.exec(appJar,
       
    71                                              "-XX:FlightRecorderOptions=retransform=true",
       
    72                                              "GetFlightRecorder"));
       
    73         TestCommon.checkExec(TestCommon.exec(appJar,
       
    74                                              "-XX:FlightRecorderOptions=retransform=false",
       
    75                                              "GetFlightRecorder"));
       
    76 
       
    77         // Test dumping with flight recorder enabled.
       
    78         output = TestCommon.testDump(appJar, TestCommon.list(classes),
       
    79                                      "-XX:StartFlightRecording=dumponexit=true");
       
    80         TestCommon.checkDump(output, "warning: JFR will be disabled during CDS dumping");
       
    81     }
       
    82 }