test/jdk/jdk/jfr/startupargs/TestFlushInterval.java
author egahlin
Fri, 23 Aug 2019 15:34:18 +0200
branchJEP-349-branch
changeset 57860 588a3f63efff
child 58076 ca625d28c580
permissions -rw-r--r--
Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57860
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
     1
/*
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
     2
 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
     4
 *
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    10
 *
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    15
 * accompanied this code).
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    16
 *
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    20
 *
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    23
 * questions.
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    24
 */
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    25
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    26
package jdk.jfr.startupargs;
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    27
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    28
import java.time.Duration;
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    29
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    30
import jdk.jfr.FlightRecorder;
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    31
import jdk.jfr.Recording;
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    32
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    33
/**
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    34
 * @test
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    35
 * @summary Start a recording with a flush interval
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    36
 * @key jfr
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    37
 * @requires vm.hasJFR
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    38
 * @library /test/lib /test/jdk
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    39
 * @run main/othervm -XX:StartFlightRecording=flush-interval=1s jdk.jfr.startupargs.TestFlushInterval
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    40
 */
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    41
public class TestFlushInterval {
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    42
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    43
    public static void main(String[] args) throws Exception {
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    44
        for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    45
            Duration d = r.getFlushInterval();
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    46
            if (d.equals(Duration.ofSeconds(1))) {
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    47
                return; //OK
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    48
            } else {
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    49
                throw new Exception("Unexpected flush-interval " + d);
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    50
            }
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    51
        }
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    52
        throw new Exception("No recording found");
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    53
    }
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    54
588a3f63efff Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
egahlin
parents:
diff changeset
    55
}