< prev index next >

test/runtime/Thread/TooSmallStackSize.java

Print this page




 153 
 154         OutputAnalyzer output = new OutputAnalyzer(pb.start());
 155         output.shouldHaveExitValue(0);
 156 
 157         System.out.println("PASSED: VM launched with " + stackOption + stackSize);
 158     }
 159 
 160     public static void main(String... args) throws Exception {
 161         /*
 162          * The result of a 16k stack size should be a quick exit with a complaint
 163          * that the stack size is too small. However, for some win32 builds, the
 164          * stack is always at least 64k, and this also sometimes is the minimum
 165          * allowed size, so we won't see an error in this case.
 166          *
 167          * This test case will also produce a crash on some platforms if the fix
 168          * for 6762191 is not yet in place.
 169          */
 170         checkStack("-XX:ThreadStackSize=", ThreadStackSizeString, "16");
 171 
 172         /*
 173          * Try with a 32k stack size, which is the size that the launcher will
 174          * set to if you try setting to anything smaller. This should produce the same
 175          * result as setting to 16k if the fix for 6762191 is in place.
 176          */
 177         String min_stack_allowed = checkStack("-XX:ThreadStackSize=", ThreadStackSizeString, "32");
 178 
 179         /*
 180          * Try again with a the minimum stack size that was given in the error message
 181          */
 182         checkMinStackAllowed("-XX:ThreadStackSize=", ThreadStackSizeString, min_stack_allowed);
 183 
 184         /*
 185          * Now try with a stack size that is not page aligned.
 186          */
 187         checkMinStackAllowed("-XX:ThreadStackSize=", ThreadStackSizeString, "513");
 188 
 189         /*
 190          * Now redo the same tests with the compiler thread stack size:
 191          */
 192         checkStack("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "16");
 193         min_stack_allowed = checkStack("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "32");
 194         checkMinStackAllowed("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, min_stack_allowed);
 195         checkMinStackAllowed("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "513");
 196 
 197         /*
 198          * Now redo the same tests with the VM thread stack size:
 199          */
 200         checkStack("-XX:VMThreadStackSize=", VMThreadStackSizeString, "16");
 201         min_stack_allowed = checkStack("-XX:VMThreadStackSize=", VMThreadStackSizeString, "32");
 202         checkMinStackAllowed("-XX:VMThreadStackSize=", VMThreadStackSizeString, min_stack_allowed);
 203         checkMinStackAllowed("-XX:VMThreadStackSize=", VMThreadStackSizeString, "513");
 204     }
 205 }


 153 
 154         OutputAnalyzer output = new OutputAnalyzer(pb.start());
 155         output.shouldHaveExitValue(0);
 156 
 157         System.out.println("PASSED: VM launched with " + stackOption + stackSize);
 158     }
 159 
 160     public static void main(String... args) throws Exception {
 161         /*
 162          * The result of a 16k stack size should be a quick exit with a complaint
 163          * that the stack size is too small. However, for some win32 builds, the
 164          * stack is always at least 64k, and this also sometimes is the minimum
 165          * allowed size, so we won't see an error in this case.
 166          *
 167          * This test case will also produce a crash on some platforms if the fix
 168          * for 6762191 is not yet in place.
 169          */
 170         checkStack("-XX:ThreadStackSize=", ThreadStackSizeString, "16");
 171 
 172         /*
 173          * Try with a 64k stack size, which is the size that the launcher will
 174          * set to if you try setting to anything smaller. This should produce the same
 175          * result as setting to 16k if the fix for 6762191 is in place.
 176          */
 177         String min_stack_allowed = checkStack("-XX:ThreadStackSize=", ThreadStackSizeString, "64");
 178 
 179         /*
 180          * Try again with a the minimum stack size that was given in the error message
 181          */
 182         checkMinStackAllowed("-XX:ThreadStackSize=", ThreadStackSizeString, min_stack_allowed);
 183 
 184         /*
 185          * Now try with a stack size that is not page aligned.
 186          */
 187         checkMinStackAllowed("-XX:ThreadStackSize=", ThreadStackSizeString, "513");
 188 
 189         /*
 190          * Now redo the same tests with the compiler thread stack size:
 191          */
 192         checkStack("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "16");
 193         min_stack_allowed = checkStack("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "64");
 194         checkMinStackAllowed("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, min_stack_allowed);
 195         checkMinStackAllowed("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "513");
 196 
 197         /*
 198          * Now redo the same tests with the VM thread stack size:
 199          */
 200         checkStack("-XX:VMThreadStackSize=", VMThreadStackSizeString, "16");
 201         min_stack_allowed = checkStack("-XX:VMThreadStackSize=", VMThreadStackSizeString, "64");
 202         checkMinStackAllowed("-XX:VMThreadStackSize=", VMThreadStackSizeString, min_stack_allowed);
 203         checkMinStackAllowed("-XX:VMThreadStackSize=", VMThreadStackSizeString, "513");
 204     }
 205 }
< prev index next >