CpuSamplesTest.java revision 2362
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk/*
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * This code is free software; you can redistribute it and/or modify it
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * under the terms of the GNU General Public License version 2 only, as
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * published by the Free Software Foundation.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * This code is distributed in the hope that it will be useful, but WITHOUT
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * version 2 for more details (a copy is included in the LICENSE file that
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * accompanied this code).
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * You should have received a copy of the GNU General Public License version
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk * 2 along with this work; if not, write to the Free Software Foundation,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * or visit www.oracle.com if you need additional information or have any
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * questions.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk */
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk/* @test
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @bug 5012882
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk * @summary Test jvmti hprof
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @compile -g:lines HelloWorld.java ../DemoRun.java
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @build CpuSamplesTest
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @run main CpuSamplesTest HelloWorld
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkpublic class CpuSamplesTest {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public static void main(String args[]) throws Exception {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk DemoRun hprof;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /* Run JVMTI hprof agent with cpu=samples */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk hprof = new DemoRun("hprof", "cpu=samples");
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk hprof.runit(args[0]);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /* Make sure patterns in output look ok */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk if (hprof.output_contains("ERROR")) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk throw new RuntimeException("Test failed - ERROR seen in output");
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /* Must be a pass. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk System.out.println("Test passed - cleanly terminated");
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk}
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk