< prev index next >

test/gc/shenandoah/options/TestArgumentRanges.java

Print this page
rev 10789 : [backport] Drop Shenandoah from test names
   1 /*
   2  * Copyright (c) 2016 Red Hat, Inc. and/or its affiliates.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 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 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 /*
  25  * @test TestShenandoahArgumentRanges
  26  * @summary Test that Shenandoah arguments are checked for ranges where applicable
  27  * @key gc
  28  * @library /testlibrary
  29  * @modules java.base/jdk.internal.misc
  30  *          java.management
  31  * @run driver TestShenandoahArgumentRanges
  32  */
  33 
  34 import com.oracle.java.testlibrary.*;
  35 
  36 public class TestShenandoahArgumentRanges {
  37     public static void main(String[] args) throws Exception {
  38         testRange("ShenandoahGarbageThreshold", 0, 100);
  39         testRange("ShenandoahFreeThreshold", 0, 100);
  40         testRange("ShenandoahAllocationThreshold", 0, 100);
  41         testHeuristics();
  42     }
  43 
  44     private static void testHeuristics() throws Exception {
  45 
  46         {
  47             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseShenandoahGC",
  48                                                                       "-XX:+UnlockDiagnosticVMOptions",
  49                                                                       "-XX:+UnlockExperimentalVMOptions",

  50                                                                       "-XX:ShenandoahGCHeuristics=aggressive",
  51                                                                       "-version");
  52             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  53             output.shouldHaveExitValue(0);
  54         }
  55         {
  56             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseShenandoahGC",
  57                                                                       "-XX:+UnlockDiagnosticVMOptions",
  58                                                                       "-XX:+UnlockExperimentalVMOptions",

  59                                                                       "-XX:ShenandoahGCHeuristics=static",
  60                                                                       "-version");
  61             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  62             output.shouldHaveExitValue(0);
  63         }
  64         {
  65             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseShenandoahGC",
  66                                                                       "-XX:+UnlockDiagnosticVMOptions",
  67                                                                       "-XX:+UnlockExperimentalVMOptions",

  68                                                                       "-XX:ShenandoahGCHeuristics=fluff",
  69                                                                       "-version");
  70             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  71             output.shouldMatch("Unknown -XX:ShenandoahGCHeuristics option");
  72             output.shouldHaveExitValue(1);
  73         }
  74     }
  75 
  76     private static void testRange(String option, int min, int max) throws Exception {
  77         {
  78             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseShenandoahGC",


  79                                                                       "-XX:" + option + "=" + (max + 1),
  80                                                                       "-version");
  81             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  82             output.shouldHaveExitValue(1);
  83         }
  84         {
  85             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseShenandoahGC",


  86                                                                       "-XX:" + option + "=" + max,
  87                                                                       "-version");
  88             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  89             output.shouldHaveExitValue(0);
  90         }
  91         {
  92             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseShenandoahGC",


  93                                                                       "-XX:" + option + "=" + (min - 1),
  94                                                                       "-version");
  95             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  96             output.shouldHaveExitValue(1);
  97         }
  98         {
  99             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseShenandoahGC",


 100                                                                       "-XX:" + option + "=" + min,
 101                                                                       "-version");
 102             OutputAnalyzer output = new OutputAnalyzer(pb.start());
 103             output.shouldHaveExitValue(0);
 104         }
 105     }
 106 }
   1 /*
   2  * Copyright (c) 2016, 2018, Red Hat, Inc. All rights reserved.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 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 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 /*
  25  * @test TestArgumentRanges
  26  * @summary Test that Shenandoah arguments are checked for ranges where applicable
  27  * @key gc
  28  * @library /testlibrary
  29  *
  30  * @run driver TestArgumentRanges

  31  */
  32 
  33 import com.oracle.java.testlibrary.*;
  34 
  35 public class TestArgumentRanges {
  36     public static void main(String[] args) throws Exception {
  37         testRange("ShenandoahGarbageThreshold", 0, 100);
  38         testRange("ShenandoahFreeThreshold", 0, 100);
  39         testRange("ShenandoahAllocationThreshold", 0, 100);
  40         testHeuristics();
  41     }
  42 
  43     private static void testHeuristics() throws Exception {
  44 
  45         {
  46             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",

  47                     "-XX:+UnlockExperimentalVMOptions",
  48                     "-XX:+UseShenandoahGC",
  49                     "-XX:ShenandoahGCHeuristics=aggressive",
  50                     "-version");
  51             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  52             output.shouldHaveExitValue(0);
  53         }
  54         {
  55             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",

  56                     "-XX:+UnlockExperimentalVMOptions",
  57                     "-XX:+UseShenandoahGC",
  58                     "-XX:ShenandoahGCHeuristics=static",
  59                     "-version");
  60             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  61             output.shouldHaveExitValue(0);
  62         }
  63         {
  64             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",

  65                     "-XX:+UnlockExperimentalVMOptions",
  66                     "-XX:+UseShenandoahGC",
  67                     "-XX:ShenandoahGCHeuristics=fluff",
  68                     "-version");
  69             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  70             output.shouldMatch("Unknown -XX:ShenandoahGCHeuristics option");
  71             output.shouldHaveExitValue(1);
  72         }
  73     }
  74 
  75     private static void testRange(String option, int min, int max) throws Exception {
  76         {
  77             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
  78                     "-XX:+UnlockExperimentalVMOptions",
  79                     "-XX:+UseShenandoahGC",
  80                     "-XX:" + option + "=" + (max + 1),
  81                     "-version");
  82             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  83             output.shouldHaveExitValue(1);
  84         }
  85         {
  86             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
  87                     "-XX:+UnlockExperimentalVMOptions",
  88                     "-XX:+UseShenandoahGC",
  89                     "-XX:" + option + "=" + max,
  90                     "-version");
  91             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  92             output.shouldHaveExitValue(0);
  93         }
  94         {
  95             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
  96                     "-XX:+UnlockExperimentalVMOptions",
  97                     "-XX:+UseShenandoahGC",
  98                     "-XX:" + option + "=" + (min - 1),
  99                     "-version");
 100             OutputAnalyzer output = new OutputAnalyzer(pb.start());
 101             output.shouldHaveExitValue(1);
 102         }
 103         {
 104             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
 105                     "-XX:+UnlockExperimentalVMOptions",
 106                     "-XX:+UseShenandoahGC",
 107                     "-XX:" + option + "=" + min,
 108                     "-version");
 109             OutputAnalyzer output = new OutputAnalyzer(pb.start());
 110             output.shouldHaveExitValue(0);
 111         }
 112     }
 113 }
< prev index next >