< prev index next >

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

Print this page

 29  * @requires vm.gc == "null"
 30  * @requires vm.bits == 64
 31  * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
 32  * @compile test-classes/Hello.java
 33  * @modules java.base/jdk.internal.misc
 34  * @run driver TestCombinedCompressedFlags
 35  */
 36 
 37 import jdk.test.lib.process.OutputAnalyzer;
 38 import java.util.List;
 39 import java.util.ArrayList;
 40 
 41 public class TestCombinedCompressedFlags {
 42     public static String HELLO_STRING = "Hello World";
 43     public static String EXEC_ABNORMAL_MSG = "Unable to use shared archive.";
 44     public static final int PASS = 0;
 45     public static final int FAIL = 1;
 46 
 47     static class ConfArg {
 48         public boolean useCompressedOops;            // UseCompressedOops
 49         public boolean useCompressedClassPointers;   // UseCompressedClassPointers
 50         public String  msg;
 51         public int code;
 52         public ConfArg(boolean useCompressedOops, boolean useCompressedClassPointers, String msg, int code) {
 53             this.useCompressedOops = useCompressedOops;
 54             this.useCompressedClassPointers = useCompressedClassPointers;
 55             this.msg  = msg;
 56             this.code = code;
 57         }
 58     }
 59 
 60     static class RunArg {
 61         public ConfArg dumpArg;
 62         public List<ConfArg> execArgs;
 63         public RunArg(ConfArg arg) {
 64             dumpArg = arg;
 65             initExecArgs();
 66         }
 67         private void initExecArgs() {
 68            /* The combinations have four cases.
 69             *          UseCompressedOops   UseCompressedClassPointers  Result
 70             *    1.
 71             *    dump: on                  on
 72             *    test: on                  on                          Pass
 73             *          on                  off                         Fail
 74             *          off                 on                          Fail
 75             *          off                 off                         Fail
 76             *    2.
 77             *    dump: on                  off
 78             *    test: on                  off                         Pass
 79             *          on                  on                          Fail
 80             *          off                 on                          Pass
 81             *          off                 off                         Fail
 82             *    3.
 83             *    dump: off                 on
 84             *    test: off                 on                          Pass
 85             *          on                  on                          Fail
 86             *          on                  off                         Fail
 87             *    4.
 88             *    dump: off                 off
 89             *    test: off                 off                         Pass
 90             *          on                  on                          Fail
 91             *          on                  off                         Fail
 92             **/
 93             execArgs = new ArrayList<ConfArg>();
 94             if (dumpArg.useCompressedOops && dumpArg.useCompressedClassPointers) {
 95                 execArgs
 96                     .add(new ConfArg(true, true, HELLO_STRING, PASS));
 97                 execArgs
 98                     .add(new ConfArg(true, false, EXEC_ABNORMAL_MSG, FAIL));
 99                 execArgs
100                     .add(new ConfArg(false, true, EXEC_ABNORMAL_MSG, FAIL));
101                 execArgs
102                     .add(new ConfArg(false, false, EXEC_ABNORMAL_MSG, FAIL));
103 
104             }  else if(dumpArg.useCompressedOops && !dumpArg.useCompressedClassPointers) {
105                 execArgs
106                     .add(new ConfArg(true, false, HELLO_STRING, PASS));
107                 execArgs
108                     .add(new ConfArg(true, true, EXEC_ABNORMAL_MSG, FAIL));
109                 execArgs
110                     .add(new ConfArg(false, true, EXEC_ABNORMAL_MSG, FAIL));
111                 execArgs
112                     .add(new ConfArg(false, false, EXEC_ABNORMAL_MSG, FAIL));
113 
114             } else if (!dumpArg.useCompressedOops && dumpArg.useCompressedClassPointers) {
115                 execArgs
116                     .add(new ConfArg(false, true, HELLO_STRING, PASS));
117                 execArgs
118                     .add(new ConfArg(true, true, EXEC_ABNORMAL_MSG, FAIL));
119                 execArgs
120                     .add(new ConfArg(true, false, EXEC_ABNORMAL_MSG, FAIL));
121             } else if (!dumpArg.useCompressedOops && !dumpArg.useCompressedClassPointers) {
122                 execArgs
123                     .add(new ConfArg(false, false, HELLO_STRING, PASS));
124                 execArgs
125                     .add(new ConfArg(true, true, EXEC_ABNORMAL_MSG, FAIL));
126                 execArgs
127                     .add(new ConfArg(true, false, EXEC_ABNORMAL_MSG, FAIL));
128             }
129         }
130     }
131 
132     public static String getCompressedOopsArg(boolean on) {
133         if (on) return "-XX:+UseCompressedOops";
134         else    return "-XX:-UseCompressedOops";
135     }
136 
137     public static String getCompressedClassPointersArg(boolean on) {
138         if (on) return "-XX:+UseCompressedClassPointers";
139         else    return "-XX:-UseCompressedClassPointers";
140     }
141 
142     public static List<RunArg> runList;
143 
144     public static void configureRunArgs() {
145         runList = new ArrayList<RunArg>();
146         runList
147             .add(new RunArg(new ConfArg(true, true, null, PASS)));
148         runList
149             .add(new RunArg(new ConfArg(true, false, null, PASS)));
150         runList
151             .add(new RunArg(new ConfArg(false, true, null, PASS)));
152         runList
153             .add(new RunArg(new ConfArg(false, false, null, PASS)));
154     }
155 
156     public static void main(String[] args) throws Exception {
157         String helloJar = JarBuilder.build("hello", "Hello");
158         configureRunArgs();
159         OutputAnalyzer out;
160         for (RunArg t: runList) {
161             out = TestCommon
162                 .dump(helloJar,
163                       new String[] {"Hello"},
164                       getCompressedOopsArg(t.dumpArg.useCompressedOops),
165                       getCompressedClassPointersArg(t.dumpArg.useCompressedClassPointers),
166                       "-Xlog:cds",
167                       "-XX:NativeMemoryTracking=detail");
168             out.shouldContain("Dumping shared data to file:");
169             out.shouldHaveExitValue(0);
170 
171             for (ConfArg c : t.execArgs) {
172                 out = TestCommon.exec(helloJar,
173                                       "-cp",
174                                       helloJar,
175                                       "-Xlog:cds",
176                                       "-XX:NativeMemoryTracking=detail",
177                                       getCompressedOopsArg(c.useCompressedOops),
178                                       getCompressedClassPointersArg(c.useCompressedClassPointers),
179                                       "Hello");
180                 out.shouldContain(c.msg);
181                 out.shouldHaveExitValue(c.code);
182             }
183         }
184     }
185 }

 29  * @requires vm.gc == "null"
 30  * @requires vm.bits == 64
 31  * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
 32  * @compile test-classes/Hello.java
 33  * @modules java.base/jdk.internal.misc
 34  * @run driver TestCombinedCompressedFlags
 35  */
 36 
 37 import jdk.test.lib.process.OutputAnalyzer;
 38 import java.util.List;
 39 import java.util.ArrayList;
 40 
 41 public class TestCombinedCompressedFlags {
 42     public static String HELLO_STRING = "Hello World";
 43     public static String EXEC_ABNORMAL_MSG = "Unable to use shared archive.";
 44     public static final int PASS = 0;
 45     public static final int FAIL = 1;
 46 
 47     static class ConfArg {
 48         public boolean useCompressedOops;            // UseCompressedOops

 49         public String  msg;
 50         public int code;
 51         public ConfArg(boolean useCompressedOops, String msg, int code) {
 52             this.useCompressedOops = useCompressedOops;

 53             this.msg  = msg;
 54             this.code = code;
 55         }
 56     }
 57 
 58     static class RunArg {
 59         public ConfArg dumpArg;
 60         public List<ConfArg> execArgs;
 61         public RunArg(ConfArg arg) {
 62             dumpArg = arg;
 63             initExecArgs();
 64         }
 65         private void initExecArgs() {
 66            /* The combinations have four cases.
 67             *          UseCompressedOops   Result
 68             *    1.
 69             *    dump: on
 70             *    test: on                  Pass
 71             *          off                 Fail


 72             *    2.
 73             *    dump: off
 74             *    test: off                 Pass
 75             *          on                  Fail












 76             **/
 77             execArgs = new ArrayList<ConfArg>();
 78             if (dumpArg.useCompressedOops) {
 79                 execArgs
 80                     .add(new ConfArg(true, HELLO_STRING, PASS));
 81                 execArgs
 82                     .add(new ConfArg(false, EXEC_ABNORMAL_MSG, FAIL));














 83 
 84             } else if (!dumpArg.useCompressedOops) {


 85                 execArgs
 86                     .add(new ConfArg(false, HELLO_STRING, PASS));
 87                 execArgs
 88                     .add(new ConfArg(true, EXEC_ABNORMAL_MSG, FAIL));







 89             }
 90         }
 91     }
 92 
 93     public static String getCompressedOopsArg(boolean on) {
 94         if (on) return "-XX:+UseCompressedOops";
 95         else    return "-XX:-UseCompressedOops";
 96     }
 97 





 98     public static List<RunArg> runList;
 99 
100     public static void configureRunArgs() {
101         runList = new ArrayList<RunArg>();
102         runList
103             .add(new RunArg(new ConfArg(true, null, PASS)));




104         runList
105             .add(new RunArg(new ConfArg(false, null, PASS)));
106     }
107 
108     public static void main(String[] args) throws Exception {
109         String helloJar = JarBuilder.build("hello", "Hello");
110         configureRunArgs();
111         OutputAnalyzer out;
112         for (RunArg t: runList) {
113             out = TestCommon
114                 .dump(helloJar,
115                       new String[] {"Hello"},
116                       getCompressedOopsArg(t.dumpArg.useCompressedOops),

117                       "-Xlog:cds",
118                       "-XX:NativeMemoryTracking=detail");
119             out.shouldContain("Dumping shared data to file:");
120             out.shouldHaveExitValue(0);
121 
122             for (ConfArg c : t.execArgs) {
123                 out = TestCommon.exec(helloJar,
124                                       "-cp",
125                                       helloJar,
126                                       "-Xlog:cds",
127                                       "-XX:NativeMemoryTracking=detail",
128                                       getCompressedOopsArg(c.useCompressedOops),

129                                       "Hello");
130                 out.shouldContain(c.msg);
131                 out.shouldHaveExitValue(c.code);
132             }
133         }
134     }
135 }
< prev index next >