hotspot/test/runtime/logging/ModulesTest.java
changeset 44993 f61bcd80ec1f
parent 41705 332239c052cc
equal deleted inserted replaced
44741:c5de7263722b 44993:f61bcd80ec1f
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2017, 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.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @summary modules=debug should have logging from statements in the code
    26  * @summary -Xlog:module should emit logging output
    27  * @library /test/lib
    27  * @library /test/lib
    28  * @modules java.base/jdk.internal.misc
    28  * @modules java.base/jdk.internal.misc
    29  *          java.management
    29  *          java.management
    30  * @run main ModulesTest
    30  * @run main ModulesTest
    31  */
    31  */
    33 import jdk.test.lib.process.OutputAnalyzer;
    33 import jdk.test.lib.process.OutputAnalyzer;
    34 import jdk.test.lib.process.ProcessTools;
    34 import jdk.test.lib.process.ProcessTools;
    35 
    35 
    36 public class ModulesTest {
    36 public class ModulesTest {
    37     public static void main(String[] args) throws Exception {
    37     public static void main(String[] args) throws Exception {
    38         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    38         testModuleTrace("-Xlog:module=trace", "-version");
    39             "-Xlog:modules=trace", "-version");
    39         testModuleLoad("-Xlog:module+load", "-version");
    40         OutputAnalyzer output = new OutputAnalyzer(pb.start());
    40         testModuleUnload("-Xlog:module+unload", "-version");
       
    41 
       
    42         // same as -Xlog:module+load -Xlog:module+unload
       
    43         testModuleLoad("-verbose:module", "-version");
       
    44     }
       
    45 
       
    46     static void testModuleTrace(String... args) throws Exception {
       
    47         OutputAnalyzer output = run(args);
    41         output.shouldContain("define_javabase_module(): Definition of module:");
    48         output.shouldContain("define_javabase_module(): Definition of module:");
    42         output.shouldContain("define_javabase_module(): creation of package");
    49         output.shouldContain("define_javabase_module(): creation of package");
    43         output.shouldContain("define_module(): creation of module");
    50         output.shouldContain("define_module(): creation of module");
    44         output.shouldContain("define_module(): creation of package");
    51         output.shouldContain("define_module(): creation of package");
    45         output.shouldContain("set_bootloader_unnamed_module(): recording unnamed");
    52         output.shouldContain("set_bootloader_unnamed_module(): recording unnamed");
    46         output.shouldContain("add_module_exports(): package");
    53         output.shouldContain("add_module_exports(): package");
    47         output.shouldContain("add_reads_module(): Adding read from module");
    54         output.shouldContain("add_reads_module(): Adding read from module");
    48         output.shouldContain("Setting package: class:");
    55         output.shouldContain("Setting package: class:");
    49         output.shouldHaveExitValue(0);
    56         output.shouldHaveExitValue(0);
    50     }
    57     }
       
    58 
       
    59     static void testModuleLoad(String... args) throws Exception {
       
    60         OutputAnalyzer output = run(args);
       
    61         output.shouldContain("java.base location:");
       
    62         output.shouldContain("java.management location:");
       
    63         output.shouldHaveExitValue(0);
       
    64     }
       
    65 
       
    66     static void testModuleUnload(String... args) throws Exception {
       
    67         OutputAnalyzer output = run(args);
       
    68         output.shouldHaveExitValue(0);
       
    69     }
       
    70 
       
    71     static OutputAnalyzer run(String... args) throws Exception {
       
    72         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
       
    73         return new OutputAnalyzer(pb.start());
       
    74     }
    51 }
    75 }
    52 
    76