< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java

Print this page

 30  * @requires vm.gc == null
 31  * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
 32  * @compile test-classes/Hello.java
 33  * @run driver TestZGCWithCDS
 34  */
 35 
 36 import jdk.test.lib.Platform;
 37 import jdk.test.lib.process.OutputAnalyzer;
 38 
 39 public class TestZGCWithCDS {
 40     public final static String HELLO = "Hello World";
 41     public final static String UNABLE_TO_USE_ARCHIVE = "Unable to use shared archive.";
 42     public final static String ERR_MSG = "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled.";
 43     public static void main(String... args) throws Exception {
 44          String helloJar = JarBuilder.build("hello", "Hello");
 45          System.out.println("0. Dump with ZGC");
 46          OutputAnalyzer out = TestCommon
 47                                   .dump(helloJar,
 48                                         new String[] {"Hello"},
 49                                         "-XX:+UseZGC",


 50                                         "-Xlog:cds");
 51          out.shouldContain("Dumping shared data to file:");
 52          out.shouldHaveExitValue(0);
 53 
 54          System.out.println("1. Run with same args of dump");
 55          out = TestCommon
 56                    .exec(helloJar,
 57                          "-XX:+UseZGC",


 58                          "-Xlog:cds",
 59                          "Hello");
 60          out.shouldContain(HELLO);
 61          out.shouldHaveExitValue(0);
 62 
 63          System.out.println("2. Run with +UseCompressedOops +UseCompressedClassPointers");
 64          out = TestCommon
 65                    .exec(helloJar,
 66                          "-XX:-UseZGC",
 67                          "-XX:+UseCompressedOops",           // in case turned off by vmoptions
 68                          "-XX:+UseCompressedClassPointers",  // by jtreg


 69                          "-Xlog:cds",
 70                          "Hello");
 71          out.shouldContain(UNABLE_TO_USE_ARCHIVE);
 72          out.shouldContain(ERR_MSG);
 73          out.shouldHaveExitValue(1);
 74 
 75          System.out.println("3. Run with -UseCompressedOops -UseCompressedClassPointers");
 76          out = TestCommon
 77                    .exec(helloJar,
 78                          "-XX:+UseSerialGC",
 79                          "-XX:-UseCompressedOops",
 80                          "-XX:-UseCompressedClassPointers",


 81                          "-Xlog:cds",
 82                          "Hello");
 83          out.shouldContain(UNABLE_TO_USE_ARCHIVE);
 84          out.shouldContain(ERR_MSG);
 85          out.shouldHaveExitValue(1);
 86 
 87          System.out.println("4. Run with -UseCompressedOops +UseCompressedClassPointers");
 88          out = TestCommon
 89                    .exec(helloJar,
 90                          "-XX:+UseSerialGC",
 91                          "-XX:-UseCompressedOops",
 92                          "-XX:+UseCompressedClassPointers",


 93                          "-Xlog:cds",
 94                          "Hello");
 95          out.shouldContain(HELLO);
 96          out.shouldHaveExitValue(0);
 97 
 98          System.out.println("5. Run with +UseCompressedOops -UseCompressedClassPointers");
 99          out = TestCommon
100                    .exec(helloJar,
101                          "-XX:+UseSerialGC",
102                          "-XX:+UseCompressedOops",
103                          "-XX:-UseCompressedClassPointers",


104                          "-Xlog:cds",
105                          "Hello");
106          out.shouldContain(UNABLE_TO_USE_ARCHIVE);
107          out.shouldContain(ERR_MSG);
108          out.shouldHaveExitValue(1);
109 
110          System.out.println("6. Run with +UseCompressedOops +UseCompressedClassPointers");
111          out = TestCommon
112                    .exec(helloJar,
113                          "-XX:+UseSerialGC",
114                          "-XX:+UseCompressedOops",
115                          "-XX:+UseCompressedClassPointers",


116                          "-Xlog:cds",
117                          "Hello");
118          out.shouldContain(UNABLE_TO_USE_ARCHIVE);
119          out.shouldContain(ERR_MSG);
120          out.shouldHaveExitValue(1);
121 
122          System.out.println("7. Dump with -UseCompressedOops -UseCompressedClassPointers");
123          out = TestCommon
124                    .dump(helloJar,
125                          new String[] {"Hello"},
126                          "-XX:+UseSerialGC",
127                          "-XX:-UseCompressedOops",
128                          "-XX:+UseCompressedClassPointers",


129                          "-Xlog:cds");
130          out.shouldContain("Dumping shared data to file:");
131          out.shouldHaveExitValue(0);
132 
133          System.out.println("8. Run with ZGC");
134          out = TestCommon
135                    .exec(helloJar,
136                          "-XX:+UseZGC",


137                          "-Xlog:cds",
138                          "Hello");
139          out.shouldContain(HELLO);
140          out.shouldHaveExitValue(0);
141     }
142 }

 30  * @requires vm.gc == null
 31  * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
 32  * @compile test-classes/Hello.java
 33  * @run driver TestZGCWithCDS
 34  */
 35 
 36 import jdk.test.lib.Platform;
 37 import jdk.test.lib.process.OutputAnalyzer;
 38 
 39 public class TestZGCWithCDS {
 40     public final static String HELLO = "Hello World";
 41     public final static String UNABLE_TO_USE_ARCHIVE = "Unable to use shared archive.";
 42     public final static String ERR_MSG = "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled.";
 43     public static void main(String... args) throws Exception {
 44          String helloJar = JarBuilder.build("hello", "Hello");
 45          System.out.println("0. Dump with ZGC");
 46          OutputAnalyzer out = TestCommon
 47                                   .dump(helloJar,
 48                                         new String[] {"Hello"},
 49                                         "-XX:+UseZGC",
 50                                         "-XX:+UnlockExperimentalVMOptions",
 51                                         "-XX:-UseCompactObjectHeaders",
 52                                         "-Xlog:cds");
 53          out.shouldContain("Dumping shared data to file:");
 54          out.shouldHaveExitValue(0);
 55 
 56          System.out.println("1. Run with same args of dump");
 57          out = TestCommon
 58                    .exec(helloJar,
 59                          "-XX:+UseZGC",
 60                          "-XX:+UnlockExperimentalVMOptions",
 61                          "-XX:-UseCompactObjectHeaders",
 62                          "-Xlog:cds",
 63                          "Hello");
 64          out.shouldContain(HELLO);
 65          out.shouldHaveExitValue(0);
 66 
 67          System.out.println("2. Run with +UseCompressedOops +UseCompressedClassPointers");
 68          out = TestCommon
 69                    .exec(helloJar,
 70                          "-XX:-UseZGC",
 71                          "-XX:+UseCompressedOops",           // in case turned off by vmoptions
 72                          "-XX:+UseCompressedClassPointers",  // by jtreg
 73                          "-XX:+UnlockExperimentalVMOptions",
 74                          "-XX:-UseCompactObjectHeaders",
 75                          "-Xlog:cds",
 76                          "Hello");
 77          out.shouldContain(UNABLE_TO_USE_ARCHIVE);
 78          out.shouldContain(ERR_MSG);
 79          out.shouldHaveExitValue(1);
 80 
 81          System.out.println("3. Run with -UseCompressedOops -UseCompressedClassPointers");
 82          out = TestCommon
 83                    .exec(helloJar,
 84                          "-XX:+UseSerialGC",
 85                          "-XX:-UseCompressedOops",
 86                          "-XX:-UseCompressedClassPointers",
 87                          "-XX:+UnlockExperimentalVMOptions",
 88                          "-XX:-UseCompactObjectHeaders",
 89                          "-Xlog:cds",
 90                          "Hello");
 91          out.shouldContain(UNABLE_TO_USE_ARCHIVE);
 92          out.shouldContain(ERR_MSG);
 93          out.shouldHaveExitValue(1);
 94 
 95          System.out.println("4. Run with -UseCompressedOops +UseCompressedClassPointers");
 96          out = TestCommon
 97                    .exec(helloJar,
 98                          "-XX:+UseSerialGC",
 99                          "-XX:-UseCompressedOops",
100                          "-XX:+UseCompressedClassPointers",
101                          "-XX:+UnlockExperimentalVMOptions",
102                          "-XX:-UseCompactObjectHeaders",
103                          "-Xlog:cds",
104                          "Hello");
105          out.shouldContain(HELLO);
106          out.shouldHaveExitValue(0);
107 
108          System.out.println("5. Run with +UseCompressedOops -UseCompressedClassPointers");
109          out = TestCommon
110                    .exec(helloJar,
111                          "-XX:+UseSerialGC",
112                          "-XX:+UseCompressedOops",
113                          "-XX:-UseCompressedClassPointers",
114                          "-XX:+UnlockExperimentalVMOptions",
115                          "-XX:-UseCompactObjectHeaders",
116                          "-Xlog:cds",
117                          "Hello");
118          out.shouldContain(UNABLE_TO_USE_ARCHIVE);
119          out.shouldContain(ERR_MSG);
120          out.shouldHaveExitValue(1);
121 
122          System.out.println("6. Run with +UseCompressedOops +UseCompressedClassPointers");
123          out = TestCommon
124                    .exec(helloJar,
125                          "-XX:+UseSerialGC",
126                          "-XX:+UseCompressedOops",
127                          "-XX:+UseCompressedClassPointers",
128                          "-XX:+UnlockExperimentalVMOptions",
129                          "-XX:-UseCompactObjectHeaders",
130                          "-Xlog:cds",
131                          "Hello");
132          out.shouldContain(UNABLE_TO_USE_ARCHIVE);
133          out.shouldContain(ERR_MSG);
134          out.shouldHaveExitValue(1);
135 
136          System.out.println("7. Dump with -UseCompressedOops -UseCompressedClassPointers");
137          out = TestCommon
138                    .dump(helloJar,
139                          new String[] {"Hello"},
140                          "-XX:+UseSerialGC",
141                          "-XX:-UseCompressedOops",
142                          "-XX:+UseCompressedClassPointers",
143                          "-XX:+UnlockExperimentalVMOptions",
144                          "-XX:-UseCompactObjectHeaders",
145                          "-Xlog:cds");
146          out.shouldContain("Dumping shared data to file:");
147          out.shouldHaveExitValue(0);
148 
149          System.out.println("8. Run with ZGC");
150          out = TestCommon
151                    .exec(helloJar,
152                          "-XX:+UseZGC",
153                          "-XX:+UnlockExperimentalVMOptions",
154                          "-XX:-UseCompactObjectHeaders",
155                          "-Xlog:cds",
156                          "Hello");
157          out.shouldContain(HELLO);
158          out.shouldHaveExitValue(0);
159     }
160 }
< prev index next >