From 77008c0b622bf021b45b929af3b7150cdc036f13 Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Fri, 13 Dec 2013 21:02:27 -0800 Subject: [PATCH] test for 2gb numpy image segfault --- Tests/large_memory_numpy_test.py | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Tests/large_memory_numpy_test.py diff --git a/Tests/large_memory_numpy_test.py b/Tests/large_memory_numpy_test.py new file mode 100644 index 000000000..eb9b8aa01 --- /dev/null +++ b/Tests/large_memory_numpy_test.py @@ -0,0 +1,37 @@ +from tester import * + +# This test is not run automatically. +# +# It requires > 2gb memory for the >2 gigapixel image generated in the +# second test. Running this automatically would amount to a denial of +# service on our testing infrastructure. I expect this test to fail +# on any 32 bit machine, as well as any smallish things (like +# raspberrypis). + +from PIL import Image +try: + import numpy as np +except: + skip() + +ydim = 32769 +xdim = 48000 +f = tempfile('temp.png') + +def _write_png(xdim,ydim): + dtype = np.uint8 + a = np.zeros((xdim, ydim), dtype=dtype) + im = Image.fromarray(a, 'L') + im.save(f) + success() + +def test_large(): + """ succeeded prepatch""" + _write_png(xdim,ydim) +def test_2gpx(): + """failed prepatch""" + _write_png(xdim,xdim) + + + +