jdk/test/sun/tools/jmap/BasicJMapTest.java
changeset 38360 fb63be22ffa6
parent 34327 50693d25f4a7
child 40686 1b855fa5c9c5
equal deleted inserted replaced
38359:fd9b36598481 38360:fb63be22ffa6
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    32 import jdk.testlibrary.OutputAnalyzer;
    32 import jdk.testlibrary.OutputAnalyzer;
    33 import jdk.testlibrary.ProcessTools;
    33 import jdk.testlibrary.ProcessTools;
    34 
    34 
    35 /*
    35 /*
    36  * @test
    36  * @test
    37  * @bug 6321286
       
    38  * @summary Unit test for jmap utility
    37  * @summary Unit test for jmap utility
    39  * @key intermittent
    38  * @key intermittent
    40  * @library /lib/testlibrary
    39  * @library /lib/testlibrary
    41  * @library /test/lib/share/classes
    40  * @library /test/lib/share/classes
    42  * @modules java.management
       
    43  * @build jdk.testlibrary.*
    41  * @build jdk.testlibrary.*
    44  * @build jdk.test.lib.hprof.*
    42  * @build jdk.test.lib.hprof.*
    45  * @build jdk.test.lib.hprof.model.*
    43  * @build jdk.test.lib.hprof.model.*
    46  * @build jdk.test.lib.hprof.parser.*
    44  * @build jdk.test.lib.hprof.parser.*
    47  * @build jdk.test.lib.hprof.util.*
    45  * @build jdk.test.lib.hprof.util.*
    52     private static ProcessBuilder processBuilder = new ProcessBuilder();
    50     private static ProcessBuilder processBuilder = new ProcessBuilder();
    53 
    51 
    54     public static void main(String[] args) throws Exception {
    52     public static void main(String[] args) throws Exception {
    55         testHisto();
    53         testHisto();
    56         testHistoLive();
    54         testHistoLive();
       
    55         testFinalizerInfo();
       
    56         testClstats();
    57         testDump();
    57         testDump();
    58         testDumpLive();
    58         testDumpLive();
    59     }
    59     }
    60 
    60 
    61     private static void testHisto() throws Exception {
    61     private static void testHisto() throws Exception {
    63         output.shouldHaveExitValue(0);
    63         output.shouldHaveExitValue(0);
    64     }
    64     }
    65 
    65 
    66     private static void testHistoLive() throws Exception {
    66     private static void testHistoLive() throws Exception {
    67         OutputAnalyzer output = jmap("-histo:live");
    67         OutputAnalyzer output = jmap("-histo:live");
       
    68         output.shouldHaveExitValue(0);
       
    69     }
       
    70 
       
    71     private static void testFinalizerInfo() throws Exception {
       
    72         OutputAnalyzer output = jmap("-finalizerinfo");
       
    73         output.shouldHaveExitValue(0);
       
    74     }
       
    75 
       
    76     private static void testClstats() throws Exception {
       
    77         OutputAnalyzer output = jmap("-clstats");
    68         output.shouldHaveExitValue(0);
    78         output.shouldHaveExitValue(0);
    69     }
    79     }
    70 
    80 
    71     private static void testDump() throws Exception {
    81     private static void testDump() throws Exception {
    72         dump(false);
    82         dump(false);
   103         }
   113         }
   104     }
   114     }
   105 
   115 
   106     private static OutputAnalyzer jmap(String... toolArgs) throws Exception {
   116     private static OutputAnalyzer jmap(String... toolArgs) throws Exception {
   107         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jmap");
   117         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jmap");
   108         launcher.addVMArg("-XX:+UsePerfData");
       
   109         if (toolArgs != null) {
   118         if (toolArgs != null) {
   110             for (String toolArg : toolArgs) {
   119             for (String toolArg : toolArgs) {
   111                 launcher.addToolArg(toolArg);
   120                 launcher.addToolArg(toolArg);
   112             }
   121             }
   113         }
   122         }