Path: blob/master/test/hotspot/jtreg/compiler/oracle/TestInvalidCompileCommand.java
41149 views
/*1* Copyright (C) 2021 THL A29 Limited, a Tencent company. 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 TestInvalidCompileCommand25* @bug 8263206 826335326* @summary Regression tests of -XX:CompileCommand27* @library /test/lib28* @requires vm.flagless29* @run driver compiler.oracle.TestInvalidCompileCommand30*/3132package compiler.oracle;3334import jdk.test.lib.process.OutputAnalyzer;35import jdk.test.lib.process.ProcessTools;3637public class TestInvalidCompileCommand {3839private static final String[][] ARGUMENTS = {40{41"-XX:CompileCommand=unknown",42"-version"43},44{45"-XX:CompileCommand=option,Test::test,CompileThresholdScaling,3.14",46"-version"47},48{49"-XX:CompileCommand=option,Test::test,RepeatCompilation,3",50"-version"51},52{53"-XX:CompileCommand=option,Test::test,VectorizeDebug,3",54"-version"55},56{57"-XX:CompileCommand=option,Test::test,ControlIntrinsic,-_maxD,-_minD",58"-version"59}60};6162private static final String[][] OUTPUTS = {63{64"Unrecognized option 'unknown'"65},66{67"Missing type 'double' before option 'CompileThresholdScaling'"68},69{70"Missing type 'intx' before option 'RepeatCompilation'"71},72{73"Missing type 'uintx' before option 'VectorizeDebug'"74},75{76"Missing type 'ccstrlist' before option 'ControlIntrinsic'"77}78};7980private static void verifyInvalidOption(String[] arguments, String[] expected_outputs) throws Exception {81ProcessBuilder pb;82OutputAnalyzer out;8384pb = ProcessTools.createJavaProcessBuilder(arguments);85out = new OutputAnalyzer(pb.start());8687for (String expected_output : expected_outputs) {88out.shouldContain(expected_output);89}9091out.shouldContain("CompileCommand: An error occurred during parsing");92out.shouldHaveExitValue(0);93}9495public static void main(String[] args) throws Exception {9697if (ARGUMENTS.length != OUTPUTS.length) {98throw new RuntimeException("Test is set up incorrectly: length of arguments and expected outputs does not match.");99}100101for (int i = 0; i < ARGUMENTS.length; i++) {102verifyInvalidOption(ARGUMENTS[i], OUTPUTS[i]);103}104}105}106107108