Path: blob/master/test/hotspot/jtreg/serviceability/logging/TestMultipleXlogArgs.java
41149 views
/*1* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test TestMultipleXlogArgs25* @summary Ensure multiple -Xlog arguments aggregate the logging options.26* @modules java.base/jdk.internal.misc27* @library /test/lib28* @run driver TestMultipleXlogArgs29*/3031import jdk.test.lib.process.ProcessTools;32import jdk.test.lib.process.OutputAnalyzer;3334public class TestMultipleXlogArgs {3536public static void main(String[] args) throws Exception {37ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:logging=debug",38"-Xlog:logging=trace",39"-Xlog:defaultmethods=trace",40"-Xlog:defaultmethods=warning",41"-Xlog:safepoint=info",42"-Xlog:safepoint=info",43"-version");44OutputAnalyzer output = new OutputAnalyzer(pb.start());45// -Xlog:logging=trace means that the log configuration will be printed.46String stdoutConfigLine = "\\[logging *\\] #0: stdout .*";47// Ensure logging=trace has overwritten logging=debug48output.shouldMatch(stdoutConfigLine + "logging=trace").shouldNotMatch(stdoutConfigLine + "logging=debug");49// Make sure safepoint=info is printed exactly once even though we're setting it twice50output.shouldMatch(stdoutConfigLine + "safepoint=info").shouldNotMatch(stdoutConfigLine + "safepoint=info.*safepoint=info");51// Shouldn't see defaultmethods at all, because it should be covered by the initial 'all=warning' config52output.shouldNotMatch(stdoutConfigLine + "defaultmethods");53output.shouldHaveExitValue(0);54}55}56575859