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 Result runWithModules(String prefix[], String upgrademodulepath, String modulepath, 204 String mid, String... testClassArgs) throws Exception { 205 AppCDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath, 206 mid, testClassArgs); 207 return new Result(opts, runWithArchive(opts)); 208 } 209 210 public static OutputAnalyzer exec(String appJar, String... suffix) throws Exception { 211 AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar); 212 opts.addSuffix(suffix); 213 return runWithArchive(opts); 214 } 215 216 217 public static OutputAnalyzer execAuto(String... suffix) throws Exception { 218 AppCDSOptions opts = (new AppCDSOptions()); 219 opts.addSuffix(suffix).setXShareMode("auto"); 220 return runWithArchive(opts); 221 } 222 223 public static OutputAnalyzer execOff(String... suffix) throws Exception { 224 AppCDSOptions opts = (new AppCDSOptions()); 225 opts.addSuffix(suffix).setXShareMode("off"); 226 return runWithArchive(opts); 227 } 228 229 230 private static AppCDSOptions makeModuleOptions(String prefix[], String upgrademodulepath, String modulepath, 231 String mid, String testClassArgs[]) { 232 AppCDSOptions opts = (new AppCDSOptions()); 233 234 opts.addPrefix(prefix); 235 if (upgrademodulepath == null) { 236 opts.addSuffix("-p", modulepath, "-m", mid); 237 } else { 238 opts.addSuffix("--upgrade-module-path", upgrademodulepath, 239 "-p", modulepath, "-m", mid); 240 } 241 opts.addSuffix(testClassArgs); 242 return opts; 243 } 244 245 public static OutputAnalyzer execModule(String prefix[], String upgrademodulepath, String modulepath, 246 String mid, String... testClassArgs) 247 throws Exception { 248 AppCDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath, 249 mid, testClassArgs); 250 return runWithArchive(opts); 251 } 252 253 254 // A common operation: dump, then check results 255 public static OutputAnalyzer testDump(String appJar, String appClasses[], 256 String... suffix) throws Exception { 257 OutputAnalyzer output = dump(appJar, appClasses, suffix); 258 output.shouldContain("Loading classes to share"); 259 output.shouldHaveExitValue(0); 260 return output; 261 } 262 263 264 /** 265 * Simple test -- dump and execute appJar with the given appClasses in classlist. 266 */ 267 public static OutputAnalyzer test(String appJar, String appClasses[], String... args) 268 throws Exception { 269 testDump(appJar, appClasses); |