230 // For CDS tests specifying prefix makes more sense than specifying suffix, since
231 // normally there are no classes or arguments to classes, just "-version"
232 // To specify suffix explicitly use CDSOptions.addSuffix()
233 public static OutputAnalyzer createArchive(String... cliPrefix)
234 throws Exception {
235 return createArchive((new CDSOptions()).addPrefix(cliPrefix));
236 }
237
238 // Create bootstrap CDS archive
239 public static OutputAnalyzer createArchive(CDSOptions opts)
240 throws Exception {
241
242 startNewArchiveName();
243
244 ArrayList<String> cmd = new ArrayList<String>();
245
246 for (String p : opts.prefix) cmd.add(p);
247
248 cmd.add("-Xshare:dump");
249 cmd.add("-Xlog:cds,cds+hashtables");
250 cmd.add("-XX:+UnlockDiagnosticVMOptions");
251 if (opts.archiveName == null)
252 opts.archiveName = getDefaultArchiveName();
253 cmd.add("-XX:SharedArchiveFile=./" + opts.archiveName);
254
255 for (String s : opts.suffix) cmd.add(s);
256
257 String[] cmdLine = cmd.toArray(new String[cmd.size()]);
258 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
259 return executeAndLog(pb, "dump");
260 }
261
262
263 // check result of 'dump-the-archive' operation, that is "-Xshare:dump"
264 public static OutputAnalyzer checkDump(OutputAnalyzer output, String... extraMatches)
265 throws Exception {
266
267 output.shouldContain("Loading classes to share");
268 output.shouldHaveExitValue(0);
269
270 for (String match : extraMatches) {
368
369 // Execute JVM with CDS archive, specify command line args suffix
370 public static OutputAnalyzer runWithArchive(String... cliPrefix)
371 throws Exception {
372
373 return runWithArchive( (new CDSOptions())
374 .setArchiveName(getDefaultArchiveName())
375 .addPrefix(cliPrefix) );
376 }
377
378
379 // Execute JVM with CDS archive, specify CDSOptions
380 public static OutputAnalyzer runWithArchive(CDSOptions opts)
381 throws Exception {
382
383 ArrayList<String> cmd = new ArrayList<String>();
384
385 for (String p : opts.prefix) cmd.add(p);
386
387 cmd.add("-Xshare:" + opts.xShareMode);
388 cmd.add("-XX:+UnlockDiagnosticVMOptions");
389 cmd.add("-Dtest.timeout.factor=" + TestTimeoutFactor);
390
391 if (opts.archiveName == null)
392 opts.archiveName = getDefaultArchiveName();
393 cmd.add("-XX:SharedArchiveFile=" + opts.archiveName);
394
395 if (opts.useVersion)
396 cmd.add("-version");
397
398 for (String s : opts.suffix) cmd.add(s);
399
400 String[] cmdLine = cmd.toArray(new String[cmd.size()]);
401 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
402 return executeAndLog(pb, "exec");
403 }
404
405
406 // A commonly used convenience methods to create an archive and check the results
407 // Creates an archive and checks for errors
408 public static OutputAnalyzer runWithArchiveAndCheck(CDSOptions opts) throws Exception {
|
230 // For CDS tests specifying prefix makes more sense than specifying suffix, since
231 // normally there are no classes or arguments to classes, just "-version"
232 // To specify suffix explicitly use CDSOptions.addSuffix()
233 public static OutputAnalyzer createArchive(String... cliPrefix)
234 throws Exception {
235 return createArchive((new CDSOptions()).addPrefix(cliPrefix));
236 }
237
238 // Create bootstrap CDS archive
239 public static OutputAnalyzer createArchive(CDSOptions opts)
240 throws Exception {
241
242 startNewArchiveName();
243
244 ArrayList<String> cmd = new ArrayList<String>();
245
246 for (String p : opts.prefix) cmd.add(p);
247
248 cmd.add("-Xshare:dump");
249 cmd.add("-Xlog:cds,cds+hashtables");
250 if (opts.archiveName == null)
251 opts.archiveName = getDefaultArchiveName();
252 cmd.add("-XX:SharedArchiveFile=./" + opts.archiveName);
253
254 for (String s : opts.suffix) cmd.add(s);
255
256 String[] cmdLine = cmd.toArray(new String[cmd.size()]);
257 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
258 return executeAndLog(pb, "dump");
259 }
260
261
262 // check result of 'dump-the-archive' operation, that is "-Xshare:dump"
263 public static OutputAnalyzer checkDump(OutputAnalyzer output, String... extraMatches)
264 throws Exception {
265
266 output.shouldContain("Loading classes to share");
267 output.shouldHaveExitValue(0);
268
269 for (String match : extraMatches) {
367
368 // Execute JVM with CDS archive, specify command line args suffix
369 public static OutputAnalyzer runWithArchive(String... cliPrefix)
370 throws Exception {
371
372 return runWithArchive( (new CDSOptions())
373 .setArchiveName(getDefaultArchiveName())
374 .addPrefix(cliPrefix) );
375 }
376
377
378 // Execute JVM with CDS archive, specify CDSOptions
379 public static OutputAnalyzer runWithArchive(CDSOptions opts)
380 throws Exception {
381
382 ArrayList<String> cmd = new ArrayList<String>();
383
384 for (String p : opts.prefix) cmd.add(p);
385
386 cmd.add("-Xshare:" + opts.xShareMode);
387 cmd.add("-Dtest.timeout.factor=" + TestTimeoutFactor);
388
389 if (opts.archiveName == null)
390 opts.archiveName = getDefaultArchiveName();
391 cmd.add("-XX:SharedArchiveFile=" + opts.archiveName);
392
393 if (opts.useVersion)
394 cmd.add("-version");
395
396 for (String s : opts.suffix) cmd.add(s);
397
398 String[] cmdLine = cmd.toArray(new String[cmd.size()]);
399 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
400 return executeAndLog(pb, "exec");
401 }
402
403
404 // A commonly used convenience methods to create an archive and check the results
405 // Creates an archive and checks for errors
406 public static OutputAnalyzer runWithArchiveAndCheck(CDSOptions opts) throws Exception {
|