183 String[] cmdLine = cmd.toArray(new String[cmd.size()]); 184 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine)); 185 return executeAndLog(pb, "exec"); 186 } 187 188 189 public static OutputAnalyzer execCommon(String... suffix) throws Exception { 190 AppCDSOptions opts = (new AppCDSOptions()); 191 opts.addSuffix(suffix); 192 return runWithArchive(opts); 193 } 194 195 // This is the new API for running a Java process with CDS enabled. 196 // See comments in the CDSTestUtils.Result class for how to use this method. 197 public static Result run(String... suffix) throws Exception { 198 AppCDSOptions opts = (new AppCDSOptions()); 199 opts.addSuffix(suffix); 200 return new Result(opts, runWithArchive(opts)); 201 } 202 203 204 public static OutputAnalyzer exec(String appJar, String... suffix) throws Exception { 205 AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar); 206 opts.addSuffix(suffix); 207 return runWithArchive(opts); 208 } 209 210 211 public static OutputAnalyzer execAuto(String... suffix) throws Exception { 212 AppCDSOptions opts = (new AppCDSOptions()); 213 opts.addSuffix(suffix).setXShareMode("auto"); 214 return runWithArchive(opts); 215 } 216 217 public static OutputAnalyzer execOff(String... suffix) throws Exception { 218 AppCDSOptions opts = (new AppCDSOptions()); 219 opts.addSuffix(suffix).setXShareMode("off"); 220 return runWithArchive(opts); 221 } 222 223 public static OutputAnalyzer execModule(String prefix[], String upgrademodulepath, String modulepath, 224 String mid, String... testClassArgs) 225 throws Exception { 226 227 AppCDSOptions opts = (new AppCDSOptions()); 228 229 opts.addPrefix(prefix); 230 if (upgrademodulepath == null) { 231 opts.addSuffix("-p", modulepath, "-m", mid); 232 } else { 233 opts.addSuffix("--upgrade-module-path", upgrademodulepath, 234 "-p", modulepath, "-m", mid); 235 } 236 opts.addSuffix(testClassArgs); 237 238 return runWithArchive(opts); 239 } 240 241 242 // A common operation: dump, then check results 243 public static OutputAnalyzer testDump(String appJar, String appClasses[], 244 String... suffix) throws Exception { 245 OutputAnalyzer output = dump(appJar, appClasses, suffix); 246 output.shouldContain("Loading classes to share"); 247 output.shouldHaveExitValue(0); 248 return output; 249 } 250 251 252 /** 253 * Simple test -- dump and execute appJar with the given appClasses in classlist. 254 */ 255 public static OutputAnalyzer test(String appJar, String appClasses[], String... args) 256 throws Exception { 257 testDump(appJar, appClasses); | 183 String[] cmdLine = cmd.toArray(new String[cmd.size()]); 184 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine)); 185 return executeAndLog(pb, "exec"); 186 } 187 188 189 public static OutputAnalyzer execCommon(String... suffix) throws Exception { 190 AppCDSOptions opts = (new AppCDSOptions()); 191 opts.addSuffix(suffix); 192 return runWithArchive(opts); 193 } 194 195 // This is the new API for running a Java process with CDS enabled. 196 // See comments in the CDSTestUtils.Result class for how to use this method. 197 public static Result run(String... suffix) throws Exception { 198 AppCDSOptions opts = (new AppCDSOptions()); 199 opts.addSuffix(suffix); 200 return new Result(opts, runWithArchive(opts)); 201 } 202 203 public static OutputAnalyzer exec(String appJar, String... suffix) throws Exception { 204 AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar); 205 opts.addSuffix(suffix); 206 return runWithArchive(opts); 207 } 208 209 public static Result runWithModules(String prefix[], String upgrademodulepath, String modulepath, 210 String mid, String... testClassArgs) throws Exception { 211 AppCDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath, 212 mid, testClassArgs); 213 return new Result(opts, runWithArchive(opts)); 214 } 215 216 public static OutputAnalyzer execAuto(String... suffix) throws Exception { 217 AppCDSOptions opts = (new AppCDSOptions()); 218 opts.addSuffix(suffix).setXShareMode("auto"); 219 return runWithArchive(opts); 220 } 221 222 public static OutputAnalyzer execOff(String... suffix) throws Exception { 223 AppCDSOptions opts = (new AppCDSOptions()); 224 opts.addSuffix(suffix).setXShareMode("off"); 225 return runWithArchive(opts); 226 } 227 228 229 private static AppCDSOptions makeModuleOptions(String prefix[], String upgrademodulepath, String modulepath, 230 String mid, String testClassArgs[]) { 231 AppCDSOptions opts = (new AppCDSOptions()); 232 233 opts.addPrefix(prefix); 234 if (upgrademodulepath == null) { 235 opts.addSuffix("-p", modulepath, "-m", mid); 236 } else { 237 opts.addSuffix("--upgrade-module-path", upgrademodulepath, 238 "-p", modulepath, "-m", mid); 239 } 240 opts.addSuffix(testClassArgs); 241 return opts; 242 } 243 244 public static OutputAnalyzer execModule(String prefix[], String upgrademodulepath, String modulepath, 245 String mid, String... testClassArgs) 246 throws Exception { 247 AppCDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath, 248 mid, testClassArgs); 249 return runWithArchive(opts); 250 } 251 252 253 // A common operation: dump, then check results 254 public static OutputAnalyzer testDump(String appJar, String appClasses[], 255 String... suffix) throws Exception { 256 OutputAnalyzer output = dump(appJar, appClasses, suffix); 257 output.shouldContain("Loading classes to share"); 258 output.shouldHaveExitValue(0); 259 return output; 260 } 261 262 263 /** 264 * Simple test -- dump and execute appJar with the given appClasses in classlist. 265 */ 266 public static OutputAnalyzer test(String appJar, String appClasses[], String... args) 267 throws Exception { 268 testDump(appJar, appClasses); |