test/jdk/tools/launcher/Settings.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff test/jdk/tools/launcher

test/jdk/tools/launcher/Settings.java

Print this page




  50         createJar(testJar, tsrc.toString());
  51     }
  52 
  53     static void checkContains(TestResult tr, String str) {
  54         if (!tr.contains(str)) {
  55             System.out.println(tr);
  56             throw new RuntimeException(str + " not found");
  57         }
  58     }
  59 
  60     static void checkNotContains(TestResult tr, String str) {
  61         if (!tr.notContains(str)) {
  62             System.out.println(tr);
  63             throw new RuntimeException(str + " found");
  64         }
  65     }
  66 
  67     private static final String VM_SETTINGS = "VM settings:";
  68     private static final String PROP_SETTINGS = "Property settings:";
  69     private static final String LOCALE_SETTINGS = "Locale settings:";

  70 
  71     static void containsAllOptions(TestResult tr) {
  72         checkContains(tr, VM_SETTINGS);
  73         checkContains(tr, PROP_SETTINGS);
  74         checkContains(tr, LOCALE_SETTINGS);



  75     }
  76 
  77     static void runTestOptionDefault() throws IOException {
  78         int stackSize = 256; // in kb
  79         if (getArch().equals("ppc64") || getArch().equals("ppc64le")) {
  80             stackSize = 800;
  81         }
  82         TestResult tr;
  83         tr = doExec(javaCmd, "-Xms64m", "-Xmx512m",
  84                 "-Xss" + stackSize + "k", "-XshowSettings", "-jar", testJar.getAbsolutePath());
  85         containsAllOptions(tr);
  86         if (!tr.isOK()) {
  87             System.out.println(tr);
  88             throw new RuntimeException("test fails");
  89         }
  90         tr = doExec(javaCmd, "-Xms65536k", "-Xmx712m",
  91                 "-Xss" + (stackSize * 1024), "-XshowSettings", "-jar", testJar.getAbsolutePath());
  92         containsAllOptions(tr);
  93         if (!tr.isOK()) {
  94             System.out.println(tr);


 106         TestResult tr = doExec(javaCmd, "-XshowSettings:vm");
 107         checkContains(tr, VM_SETTINGS);
 108         checkNotContains(tr, PROP_SETTINGS);
 109         checkNotContains(tr, LOCALE_SETTINGS);
 110     }
 111 
 112     static void runTestOptionProperty() throws IOException {
 113         TestResult tr = doExec(javaCmd, "-XshowSettings:properties");
 114         checkNotContains(tr, VM_SETTINGS);
 115         checkContains(tr, PROP_SETTINGS);
 116         checkNotContains(tr, LOCALE_SETTINGS);
 117     }
 118 
 119     static void runTestOptionLocale() throws IOException {
 120         TestResult tr = doExec(javaCmd, "-XshowSettings:locale");
 121         checkNotContains(tr, VM_SETTINGS);
 122         checkNotContains(tr, PROP_SETTINGS);
 123         checkContains(tr, LOCALE_SETTINGS);
 124     }
 125 














 126     static void runTestBadOptions() throws IOException {
 127         TestResult tr = doExec(javaCmd, "-XshowSettingsBadOption");
 128         checkNotContains(tr, VM_SETTINGS);
 129         checkNotContains(tr, PROP_SETTINGS);
 130         checkNotContains(tr, LOCALE_SETTINGS);
 131         checkContains(tr, "Unrecognized option: -XshowSettingsBadOption");
 132     }
 133 
 134     static void runTest7123582() throws IOException {
 135         TestResult tr = doExec(javaCmd, "-XshowSettings", "-version");
 136         if (!tr.isOK()) {
 137             System.out.println(tr);
 138             throw new RuntimeException("test fails");
 139         }
 140         containsAllOptions(tr);
 141     }
 142 
 143     public static void main(String... args) throws IOException {
 144         runTestOptionAll();
 145         runTestOptionDefault();
 146         runTestOptionVM();
 147         runTestOptionProperty();
 148         runTestOptionLocale();

 149         runTestBadOptions();
 150         runTest7123582();
 151         if (testExitValue != 0) {
 152             throw new Error(testExitValue + " tests failed");
 153         }
 154     }
 155 }


  50         createJar(testJar, tsrc.toString());
  51     }
  52 
  53     static void checkContains(TestResult tr, String str) {
  54         if (!tr.contains(str)) {
  55             System.out.println(tr);
  56             throw new RuntimeException(str + " not found");
  57         }
  58     }
  59 
  60     static void checkNotContains(TestResult tr, String str) {
  61         if (!tr.notContains(str)) {
  62             System.out.println(tr);
  63             throw new RuntimeException(str + " found");
  64         }
  65     }
  66 
  67     private static final String VM_SETTINGS = "VM settings:";
  68     private static final String PROP_SETTINGS = "Property settings:";
  69     private static final String LOCALE_SETTINGS = "Locale settings:";
  70     private static final String SYSTEM_SETTINGS = "Operating System Metrics:";
  71 
  72     static void containsAllOptions(TestResult tr) {
  73         checkContains(tr, VM_SETTINGS);
  74         checkContains(tr, PROP_SETTINGS);
  75         checkContains(tr, LOCALE_SETTINGS);
  76         if (System.getProperty("os.name").contains("Linux")) {
  77             checkContains(tr, SYSTEM_SETTINGS);
  78         }
  79     }
  80 
  81     static void runTestOptionDefault() throws IOException {
  82         int stackSize = 256; // in kb
  83         if (getArch().equals("ppc64") || getArch().equals("ppc64le")) {
  84             stackSize = 800;
  85         }
  86         TestResult tr;
  87         tr = doExec(javaCmd, "-Xms64m", "-Xmx512m",
  88                 "-Xss" + stackSize + "k", "-XshowSettings", "-jar", testJar.getAbsolutePath());
  89         containsAllOptions(tr);
  90         if (!tr.isOK()) {
  91             System.out.println(tr);
  92             throw new RuntimeException("test fails");
  93         }
  94         tr = doExec(javaCmd, "-Xms65536k", "-Xmx712m",
  95                 "-Xss" + (stackSize * 1024), "-XshowSettings", "-jar", testJar.getAbsolutePath());
  96         containsAllOptions(tr);
  97         if (!tr.isOK()) {
  98             System.out.println(tr);


 110         TestResult tr = doExec(javaCmd, "-XshowSettings:vm");
 111         checkContains(tr, VM_SETTINGS);
 112         checkNotContains(tr, PROP_SETTINGS);
 113         checkNotContains(tr, LOCALE_SETTINGS);
 114     }
 115 
 116     static void runTestOptionProperty() throws IOException {
 117         TestResult tr = doExec(javaCmd, "-XshowSettings:properties");
 118         checkNotContains(tr, VM_SETTINGS);
 119         checkContains(tr, PROP_SETTINGS);
 120         checkNotContains(tr, LOCALE_SETTINGS);
 121     }
 122 
 123     static void runTestOptionLocale() throws IOException {
 124         TestResult tr = doExec(javaCmd, "-XshowSettings:locale");
 125         checkNotContains(tr, VM_SETTINGS);
 126         checkNotContains(tr, PROP_SETTINGS);
 127         checkContains(tr, LOCALE_SETTINGS);
 128     }
 129 
 130     static void runTestOptionSystem() throws IOException {
 131         TestResult tr = doExec(javaCmd, "-XshowSettings:system");
 132         if (System.getProperty("os.name").contains("Linux")) {
 133             checkNotContains(tr, VM_SETTINGS);
 134             checkNotContains(tr, PROP_SETTINGS);
 135             checkNotContains(tr, LOCALE_SETTINGS);
 136             checkContains(tr, SYSTEM_SETTINGS);
 137         } else {
 138             // -XshowSettings prints all available settings when
 139             // settings argument is not recognized.
 140             containsAllOptions(tr);
 141         }
 142     }
 143 
 144     static void runTestBadOptions() throws IOException {
 145         TestResult tr = doExec(javaCmd, "-XshowSettingsBadOption");
 146         checkNotContains(tr, VM_SETTINGS);
 147         checkNotContains(tr, PROP_SETTINGS);
 148         checkNotContains(tr, LOCALE_SETTINGS);
 149         checkContains(tr, "Unrecognized option: -XshowSettingsBadOption");
 150     }
 151 
 152     static void runTest7123582() throws IOException {
 153         TestResult tr = doExec(javaCmd, "-XshowSettings", "-version");
 154         if (!tr.isOK()) {
 155             System.out.println(tr);
 156             throw new RuntimeException("test fails");
 157         }
 158         containsAllOptions(tr);
 159     }
 160 
 161     public static void main(String... args) throws IOException {
 162         runTestOptionAll();
 163         runTestOptionDefault();
 164         runTestOptionVM();
 165         runTestOptionProperty();
 166         runTestOptionLocale();
 167         runTestOptionSystem();
 168         runTestBadOptions();
 169         runTest7123582();
 170         if (testExitValue != 0) {
 171             throw new Error(testExitValue + " tests failed");
 172         }
 173     }
 174 }
test/jdk/tools/launcher/Settings.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File