< prev index next >

test/hotspot/jtreg/runtime/appcds/sharedStrings/SharedStringsUtils.java

Print this page


  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 import jdk.test.lib.cds.CDSOptions;
  26 import jdk.test.lib.process.OutputAnalyzer;
  27 
  28 // A helper/utility class for testing shared strings
  29 public class SharedStringsUtils {
  30     public static final String TEST_JAR_NAME =      "test";
  31     public static final String TEST_JAR_NAME_FULL = "test.jar";
  32     public static final String WHITEBOX_JAR_NAME =  "whitebox";





  33 
  34     public static String getWbParam() {
  35         return "-Xbootclasspath/a:" + TestCommon.getTestJar(WHITEBOX_JAR_NAME + ".jar");
  36     }
  37 
  38     // build the test jar
  39     public static void buildJar(String... classes) throws Exception {
  40         JarBuilder.build(TEST_JAR_NAME, classes);
  41     }
  42 
  43     // build the test jar and a whitebox jar
  44     public static void buildJarAndWhiteBox(String... classes) throws Exception {
  45         JarBuilder.build(true, WHITEBOX_JAR_NAME, "sun/hotspot/WhiteBox");
  46         buildJar(classes);
  47     }
  48 
  49     // execute the "dump" operation, but do not check the output
  50     public static OutputAnalyzer dumpWithoutChecks(String appClasses[],
  51         String sharedDataFile, String... extraOptions) throws Exception {
  52 
  53         String appJar = TestCommon.getTestJar(TEST_JAR_NAME_FULL);
  54         String[] args =
  55             TestCommon.concat(extraOptions, "-XX:+UseCompressedOops", "-XX:+UseG1GC",
  56             "-XX:SharedArchiveConfigFile=" +
  57             TestCommon.getSourceFile(sharedDataFile));

  58 
  59         return TestCommon.dump(appJar, appClasses, args);
  60     }
  61 
  62     // execute the dump operation and check the output
  63     public static OutputAnalyzer dump(String appClasses[],
  64         String sharedDataFile, String... extraOptions) throws Exception {
  65         OutputAnalyzer output = dumpWithoutChecks(appClasses, sharedDataFile, extraOptions);
  66         checkDump(output);
  67         return output;
  68     }
  69 
  70     public static OutputAnalyzer dumpWithWhiteBox(String appClasses[],
  71         String sharedDataFile, String... extraOptions) throws Exception {
  72         return dump(appClasses, sharedDataFile,
  73             TestCommon.concat(extraOptions, getWbParam()) );
  74     }
  75 
  76     // execute/run test with shared archive
  77     public static OutputAnalyzer runWithArchiveAuto(String className,
  78         String... extraOptions) throws Exception {
  79 
  80         String appJar = TestCommon.getTestJar(TEST_JAR_NAME_FULL);
  81         String[] args = TestCommon.concat(extraOptions,
  82             "-cp", appJar, "-XX:+UseCompressedOops", "-XX:+UseG1GC", className);

  83 
  84         OutputAnalyzer output = TestCommon.execAuto(args);
  85         checkExecAuto(output);
  86         return output;
  87     }
  88 
  89     public static OutputAnalyzer runWithArchive(String className,
  90         String... extraOptions) throws Exception {
  91 
  92         return runWithArchive(new String[0], className, extraOptions);
  93     }
  94 
  95     public static OutputAnalyzer runWithArchive(String[] extraMatches,
  96         String className, String... extraOptions) throws Exception {
  97 
  98         String appJar = TestCommon.getTestJar(TEST_JAR_NAME_FULL);
  99         String[] args = TestCommon.concat(extraOptions,
 100             "-XX:+UseCompressedOops", "-XX:+UseG1GC", className);

 101 
 102         OutputAnalyzer output = TestCommon.exec(appJar, args);
 103         checkExec(output, extraMatches);
 104         return output;
 105     }
 106 
 107 
 108     // execute/run test with shared archive and white box
 109     public static OutputAnalyzer runWithArchiveAndWhiteBox(String className,
 110         String... extraOptions) throws Exception {
 111 
 112         return runWithArchive(className,
 113             TestCommon.concat(extraOptions, getWbParam(),
 114             "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI") );
 115     }
 116 
 117     public static OutputAnalyzer runWithArchiveAndWhiteBox(String[] extraMatches,
 118         String className, String... extraOptions) throws Exception {
 119 
 120         return runWithArchive(extraMatches, className,




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 import jdk.test.lib.cds.CDSOptions;
  26 import jdk.test.lib.process.OutputAnalyzer;
  27 
  28 // A helper/utility class for testing shared strings
  29 public class SharedStringsUtils {
  30     public static final String TEST_JAR_NAME =      "test";
  31     public static final String TEST_JAR_NAME_FULL = "test.jar";
  32     public static final String WHITEBOX_JAR_NAME =  "whitebox";
  33     private static String vmOptionsPrefix[] = {};
  34 
  35     static void setVMOptionsPrefix(String[] opts) {
  36         vmOptionsPrefix = opts;
  37     }
  38 
  39     public static String getWbParam() {
  40         return "-Xbootclasspath/a:" + TestCommon.getTestJar(WHITEBOX_JAR_NAME + ".jar");
  41     }
  42 
  43     // build the test jar
  44     public static void buildJar(String... classes) throws Exception {
  45         JarBuilder.build(TEST_JAR_NAME, classes);
  46     }
  47 
  48     // build the test jar and a whitebox jar
  49     public static void buildJarAndWhiteBox(String... classes) throws Exception {
  50         JarBuilder.build(true, WHITEBOX_JAR_NAME, "sun/hotspot/WhiteBox");
  51         buildJar(classes);
  52     }
  53 
  54     // execute the "dump" operation, but do not check the output
  55     public static OutputAnalyzer dumpWithoutChecks(String appClasses[],
  56         String sharedDataFile, String... extraOptions) throws Exception {
  57 
  58         String appJar = TestCommon.getTestJar(TEST_JAR_NAME_FULL);
  59         String[] args =
  60             TestCommon.concat(extraOptions, "-XX:+UseCompressedOops", "-XX:+UseG1GC",
  61             "-XX:SharedArchiveConfigFile=" +
  62             TestCommon.getSourceFile(sharedDataFile));
  63         args = TestCommon.concat(vmOptionsPrefix, args);
  64 
  65         return TestCommon.dump(appJar, appClasses, args);
  66     }
  67 
  68     // execute the dump operation and check the output
  69     public static OutputAnalyzer dump(String appClasses[],
  70         String sharedDataFile, String... extraOptions) throws Exception {
  71         OutputAnalyzer output = dumpWithoutChecks(appClasses, sharedDataFile, extraOptions);
  72         checkDump(output);
  73         return output;
  74     }
  75 
  76     public static OutputAnalyzer dumpWithWhiteBox(String appClasses[],
  77         String sharedDataFile, String... extraOptions) throws Exception {
  78         return dump(appClasses, sharedDataFile,
  79             TestCommon.concat(extraOptions, getWbParam()) );
  80     }
  81 
  82     // execute/run test with shared archive
  83     public static OutputAnalyzer runWithArchiveAuto(String className,
  84         String... extraOptions) throws Exception {
  85 
  86         String appJar = TestCommon.getTestJar(TEST_JAR_NAME_FULL);
  87         String[] args = TestCommon.concat(extraOptions,
  88             "-cp", appJar, "-XX:+UseCompressedOops", "-XX:+UseG1GC", className);
  89         args = TestCommon.concat(vmOptionsPrefix, args);
  90 
  91         OutputAnalyzer output = TestCommon.execAuto(args);
  92         checkExecAuto(output);
  93         return output;
  94     }
  95 
  96     public static OutputAnalyzer runWithArchive(String className,
  97         String... extraOptions) throws Exception {
  98 
  99         return runWithArchive(new String[0], className, extraOptions);
 100     }
 101 
 102     public static OutputAnalyzer runWithArchive(String[] extraMatches,
 103         String className, String... extraOptions) throws Exception {
 104 
 105         String appJar = TestCommon.getTestJar(TEST_JAR_NAME_FULL);
 106         String[] args = TestCommon.concat(extraOptions,
 107             "-XX:+UseCompressedOops", "-XX:+UseG1GC", className);
 108         args = TestCommon.concat(vmOptionsPrefix, args);
 109 
 110         OutputAnalyzer output = TestCommon.exec(appJar, args);
 111         checkExec(output, extraMatches);
 112         return output;
 113     }
 114 
 115 
 116     // execute/run test with shared archive and white box
 117     public static OutputAnalyzer runWithArchiveAndWhiteBox(String className,
 118         String... extraOptions) throws Exception {
 119 
 120         return runWithArchive(className,
 121             TestCommon.concat(extraOptions, getWbParam(),
 122             "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI") );
 123     }
 124 
 125     public static OutputAnalyzer runWithArchiveAndWhiteBox(String[] extraMatches,
 126         String className, String... extraOptions) throws Exception {
 127 
 128         return runWithArchive(extraMatches, className,


< prev index next >