8144446: Automate the Marlin crash test

Reviewed-by: prr, flar
This commit is contained in:
Laurent Bourgès 2015-12-10 15:45:18 -08:00
parent c588dd42dd
commit bb10c3f0de
2 changed files with 38 additions and 28 deletions

View File

@ -629,6 +629,13 @@ final class Renderer implements PathConsumer2D, MarlinConst {
} }
if (edgeMinY != Float.POSITIVE_INFINITY) { if (edgeMinY != Float.POSITIVE_INFINITY) {
// if context is maked as DIRTY:
if (rdrCtx.dirty) {
// may happen if an exception if thrown in the pipeline processing:
// clear completely buckets arrays:
buckets_minY = 0;
buckets_maxY = boundsMaxY - boundsMinY;
}
// clear used part // clear used part
if (edgeBuckets == edgeBuckets_initial) { if (edgeBuckets == edgeBuckets_initial) {
// fill only used part // fill only used part

View File

@ -31,15 +31,13 @@ import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import sun.java2d.pipe.RenderingEngine;
/** /**
* Simple crash rendering test using huge GeneralPaths with marlin renderer * @test
* * @summary Simple crash rendering test using huge GeneralPaths with the Marlin renderer
* run it with large heap (2g): * @run main/othervm -mx512m CrashTest
* java -Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine marlin.CrashTest * @ignore tests that take a long time and consumes 5Gb memory
* * @run main/othervm -ms4g -mx4g CrashTest -slow
* @author bourgesl
*/ */
public class CrashTest { public class CrashTest {
@ -47,15 +45,30 @@ public class CrashTest {
static boolean USE_ROUND_CAPS_AND_JOINS = true; static boolean USE_ROUND_CAPS_AND_JOINS = true;
public static void main(String[] args) { public static void main(String[] args) {
boolean runSlowTests = (args.length != 0 && "-slow".equals(args[0]));
// First display which renderer is tested:
System.setProperty("sun.java2d.renderer.verbose", "true");
// try insane image sizes: // try insane image sizes:
// subpixel coords may overflow: // subpixel coords may overflow:
// testHugeImage((Integer.MAX_VALUE >> 3) + 1, 6); // check MAX_VALUE / (8 * 2); overflow may happen due to orientation flag
// But as it is impossible to allocate an image larger than 2Gb (byte) then
// it is also impossible to have rowAAChunk larger than 2Gb !
// Disabled test as it consumes 4GB heap + offheap (2Gb) ie > 6Gb !
if (runSlowTests) {
testHugeImage((Integer.MAX_VALUE >> 4) - 100, 16);
}
// larger than 23 bits: (RLE) // larger than 23 bits: (RLE)
testHugeImage(8388608 + 1, 10); testHugeImage(8388608 + 1, 10);
if (runSlowTests) {
test(0.1f, false, 0); test(0.1f, false, 0);
test(0.1f, true, 7f); test(0.1f, true, 7f);
}
// Exceed 2Gb OffHeap buffer for edges: // Exceed 2Gb OffHeap buffer for edges:
try { try {
@ -67,11 +80,9 @@ public class CrashTest {
if (th instanceof ArrayIndexOutOfBoundsException) { if (th instanceof ArrayIndexOutOfBoundsException) {
System.out.println("ArrayIndexOutOfBoundsException expected."); System.out.println("ArrayIndexOutOfBoundsException expected.");
} else { } else {
System.out.println("Exception occured:"); throw new RuntimeException("Unexpected exception", th);
th.printStackTrace();
} }
} }
} }
private static void test(final float lineStroke, private static void test(final float lineStroke,
@ -85,9 +96,6 @@ public class CrashTest {
+", dashMinLen=" + dashMinLen +", dashMinLen=" + dashMinLen
); );
final String renderer = RenderingEngine.getInstance().getClass().getSimpleName();
System.out.println("Testing renderer = " + renderer);
final BasicStroke stroke = createStroke(lineStroke, useDashes, dashMinLen); final BasicStroke stroke = createStroke(lineStroke, useDashes, dashMinLen);
// TODO: test Dasher.firstSegmentsBuffer resizing ? // TODO: test Dasher.firstSegmentsBuffer resizing ?
@ -135,7 +143,7 @@ public class CrashTest {
if (SAVE_IMAGE) { if (SAVE_IMAGE) {
try { try {
final File file = new File("CrashTest-" + renderer + "-dash-" + useDashes + ".bmp"); final File file = new File("CrashTest-dash-" + useDashes + ".bmp");
System.out.println("Writing file: " + file.getAbsolutePath()); System.out.println("Writing file: " + file.getAbsolutePath());
ImageIO.write(image, "BMP", file); ImageIO.write(image, "BMP", file);
@ -153,12 +161,7 @@ public class CrashTest {
throws ArrayIndexOutOfBoundsException throws ArrayIndexOutOfBoundsException
{ {
System.out.println("---\n" + "testHugeImage: " System.out.println("---\n" + "testHugeImage: "
+ "width=" + width + "width=" + width + ", height=" + height);
+ ", height=" + height
);
final String renderer = RenderingEngine.getInstance().getClass().getSimpleName();
System.out.println("Testing renderer = " + renderer);
final BasicStroke stroke = createStroke(2.5f, false, 0); final BasicStroke stroke = createStroke(2.5f, false, 0);
@ -195,8 +198,8 @@ public class CrashTest {
if (SAVE_IMAGE) { if (SAVE_IMAGE) {
try { try {
final File file = new File("CrashTest-" + renderer + final File file = new File("CrashTest-huge-"
"-huge-" + width + "x" +height + ".bmp"); + width + "x" +height + ".bmp");
System.out.println("Writing file: " + file.getAbsolutePath()); System.out.println("Writing file: " + file.getAbsolutePath());
ImageIO.write(image, "BMP", file); ImageIO.write(image, "BMP", file);