2015-07-27 11:44:07 +00:00
/ *
2023-10-27 08:47:26 +00:00
* Copyright ( c ) 2015 , 2023 , Oracle and / or its affiliates . All rights reserved .
2015-07-27 11:44:07 +00:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
*
* This code is free software ; you can redistribute it and / or modify it
* under the terms of the GNU General Public License version 2 only , as
* published by the Free Software Foundation .
*
* This code is distributed in the hope that it will be useful , but WITHOUT
* ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE . See the GNU General Public License
* version 2 for more details ( a copy is included in the LICENSE file that
* accompanied this code ) .
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work ; if not , write to the Free Software Foundation ,
* Inc . , 51 Franklin St , Fifth Floor , Boston , MA 02110 - 1301 USA .
*
* Please contact Oracle , 500 Oracle Parkway , Redwood Shores , CA 94065 USA
* or visit www . oracle . com if you need additional information or have any
* questions .
* /
/ *
* @test CheckCheckCICompilerCount
2016-08-04 06:58:22 +00:00
* @bug 8130858 8132525 8162881
2015-07-27 11:44:07 +00:00
* @summary Check that correct range of values for CICompilerCount are allowed depending on whether tiered is enabled or not
2016-08-19 14:06:30 +00:00
* @library / test / lib /
2021-04-27 23:54:45 +00:00
* @requires vm . flagless
2016-04-09 22:03:39 +00:00
* @modules java . base / jdk . internal . misc
2015-07-27 11:44:07 +00:00
* java . management
2016-07-12 15:24:48 +00:00
* @run driver compiler . arguments . CheckCICompilerCount
2015-07-27 11:44:07 +00:00
* /
2016-07-12 15:24:48 +00:00
package compiler.arguments ;
2016-08-19 14:06:30 +00:00
import jdk.test.lib.process.OutputAnalyzer ;
import jdk.test.lib.process.ProcessTools ;
2016-07-12 15:24:48 +00:00
2015-07-27 11:44:07 +00:00
public class CheckCICompilerCount {
private static final String [ ] [ ] NON_TIERED_ARGUMENTS = {
{
2015-07-29 10:33:48 +00:00
" -server " ,
2015-07-27 11:44:07 +00:00
" -XX:-TieredCompilation " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=0 " ,
" -version "
} ,
{
2015-07-29 10:33:48 +00:00
" -server " ,
" -XX:-TieredCompilation " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=1 " ,
" -version "
} ,
2016-08-04 06:58:22 +00:00
{
" -server " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=1 " ,
" -XX:-TieredCompilation " ,
" -version "
} ,
2015-07-29 10:33:48 +00:00
{
" -client " ,
" -XX:-TieredCompilation " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=0 " ,
" -version "
} ,
{
" -client " ,
2015-07-27 11:44:07 +00:00
" -XX:-TieredCompilation " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=1 " ,
" -version "
2016-08-04 06:58:22 +00:00
} ,
{
" -client " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=1 " ,
" -XX:-TieredCompilation " ,
" -version "
2015-07-27 11:44:07 +00:00
}
} ;
2016-08-04 06:58:22 +00:00
private static final String [ ] NON_TIERED_EXPECTED_OUTPUTS = {
2015-08-16 14:33:52 +00:00
" CICompilerCount (0) must be at least 1 " ,
2018-03-19 18:37:57 +00:00
" intx CICompilerCount = 1 {product} {command line} " ,
" intx CICompilerCount = 1 {product} {command line} " ,
2015-08-24 21:17:15 +00:00
" CICompilerCount (0) must be at least 1 " ,
2018-03-19 18:37:57 +00:00
" intx CICompilerCount = 1 {product} {command line} " ,
" intx CICompilerCount = 1 {product} {command line} "
2015-07-27 11:44:07 +00:00
} ;
private static final int [ ] NON_TIERED_EXIT = {
2015-07-29 10:33:48 +00:00
1 ,
0 ,
2016-08-04 06:58:22 +00:00
0 ,
2015-07-27 11:44:07 +00:00
1 ,
2016-08-04 06:58:22 +00:00
0 ,
2015-07-27 11:44:07 +00:00
0
} ;
private static final String [ ] [ ] TIERED_ARGUMENTS = {
{
2015-07-29 10:33:48 +00:00
" -server " ,
2015-07-27 11:44:07 +00:00
" -XX:+TieredCompilation " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=1 " ,
" -version "
} ,
{
2015-07-29 10:33:48 +00:00
" -server " ,
" -XX:+TieredCompilation " ,
2016-08-04 06:58:22 +00:00
" -XX:TieredStopAtLevel=1 " ,
2015-07-29 10:33:48 +00:00
" -XX:+PrintFlagsFinal " ,
2016-08-04 06:58:22 +00:00
" -XX:CICompilerCount=1 " ,
2015-07-29 10:33:48 +00:00
" -version "
} ,
{
2016-08-04 06:58:22 +00:00
" -server " ,
2015-07-29 10:33:48 +00:00
" -XX:+TieredCompilation " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=1 " ,
2016-08-04 06:58:22 +00:00
" -XX:TieredStopAtLevel=1 " ,
2015-07-29 10:33:48 +00:00
" -version "
} ,
{
2016-08-04 06:58:22 +00:00
" -server " ,
2015-07-27 11:44:07 +00:00
" -XX:+TieredCompilation " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=2 " ,
" -version "
2016-08-04 06:58:22 +00:00
} ,
2015-07-29 10:33:48 +00:00
{
2016-08-04 06:58:22 +00:00
" -client " ,
" -XX:+TieredCompilation " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=1 " ,
" -version "
2015-07-29 10:33:48 +00:00
} ,
{
2016-08-04 06:58:22 +00:00
" -client " ,
" -XX:+TieredCompilation " ,
" -XX:TieredStopAtLevel=1 " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=1 " ,
" -version "
2015-07-29 10:33:48 +00:00
} ,
2015-07-27 11:44:07 +00:00
{
2016-08-04 06:58:22 +00:00
" -client " ,
" -XX:+TieredCompilation " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=1 " ,
" -XX:TieredStopAtLevel=1 " ,
" -version "
2015-07-27 11:44:07 +00:00
} ,
{
2016-08-04 06:58:22 +00:00
" -client " ,
" -XX:+TieredCompilation " ,
" -XX:+PrintFlagsFinal " ,
" -XX:CICompilerCount=2 " ,
" -version "
2015-07-27 11:44:07 +00:00
}
} ;
2016-08-04 06:58:22 +00:00
private static final String [ ] TIERED_EXPECTED_OUTPUTS = {
" CICompilerCount (1) must be at least 2 " ,
2018-03-19 18:37:57 +00:00
" intx CICompilerCount = 1 {product} {command line} " ,
" intx CICompilerCount = 1 {product} {command line} " ,
" intx CICompilerCount = 2 {product} {command line} " ,
2016-08-04 06:58:22 +00:00
" CICompilerCount (1) must be at least 2 " ,
2018-03-19 18:37:57 +00:00
" intx CICompilerCount = 1 {product} {command line} " ,
" intx CICompilerCount = 1 {product} {command line} " ,
" intx CICompilerCount = 2 {product} {command line} " ,
2016-08-04 06:58:22 +00:00
} ;
2015-07-27 11:44:07 +00:00
private static final int [ ] TIERED_EXIT = {
2015-07-29 10:33:48 +00:00
1 ,
0 ,
2016-08-04 06:58:22 +00:00
0 ,
0 ,
2015-07-27 11:44:07 +00:00
1 ,
2016-08-04 06:58:22 +00:00
0 ,
0 ,
2015-07-27 11:44:07 +00:00
0
} ;
2016-08-04 06:58:22 +00:00
private static void verifyValidOption ( String [ ] arguments , String expected_output , int exit , boolean tiered ) throws Exception {
2015-07-27 11:44:07 +00:00
ProcessBuilder pb ;
OutputAnalyzer out ;
2023-10-27 08:47:26 +00:00
pb = ProcessTools . createLimitedTestJavaProcessBuilder ( arguments ) ;
2015-07-27 11:44:07 +00:00
out = new OutputAnalyzer ( pb . start ( ) ) ;
try {
out . shouldHaveExitValue ( exit ) ;
2016-08-04 06:58:22 +00:00
out . shouldContain ( expected_output ) ;
2015-07-27 11:44:07 +00:00
} catch ( RuntimeException e ) {
// Check if tiered compilation is available in this JVM
// Version. Throw exception only if it is available.
2016-04-05 07:05:19 +00:00
if ( ! ( tiered & & out . getOutput ( ) . contains ( " -XX:+TieredCompilation not supported in this VM " ) ) ) {
2015-07-27 11:44:07 +00:00
throw new RuntimeException ( e ) ;
}
}
}
public static void main ( String [ ] args ) throws Exception {
if ( NON_TIERED_ARGUMENTS . length ! = NON_TIERED_EXPECTED_OUTPUTS . length | | NON_TIERED_ARGUMENTS . length ! = NON_TIERED_EXIT . length ) {
throw new RuntimeException ( " Test is set up incorrectly: length of arguments, expected outputs and exit codes in non-tiered mode of operation do not match. " ) ;
}
if ( TIERED_ARGUMENTS . length ! = TIERED_EXPECTED_OUTPUTS . length | | TIERED_ARGUMENTS . length ! = TIERED_EXIT . length ) {
throw new RuntimeException ( " Test is set up incorrectly: length of arguments, expected outputs and exit codes in tiered mode of operation do not match. " ) ;
}
for ( int i = 0 ; i < NON_TIERED_ARGUMENTS . length ; i + + ) {
verifyValidOption ( NON_TIERED_ARGUMENTS [ i ] , NON_TIERED_EXPECTED_OUTPUTS [ i ] , NON_TIERED_EXIT [ i ] , false ) ;
}
for ( int i = 0 ; i < TIERED_ARGUMENTS . length ; i + + ) {
verifyValidOption ( TIERED_ARGUMENTS [ i ] , TIERED_EXPECTED_OUTPUTS [ i ] , TIERED_EXIT [ i ] , true ) ;
}
}
}