mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 18:26:17 +03:00
test for 2gb numpy image segfault
This commit is contained in:
parent
ec6fd4d672
commit
77008c0b62
37
Tests/large_memory_numpy_test.py
Normal file
37
Tests/large_memory_numpy_test.py
Normal file
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user