3
# test-sdl-image1.2.py quality assurance test script
4
# Copyright (C) 2008 Canonical Ltd.
5
# Author: Kees Cook <kees@canonical.com>
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License version 3,
9
# as published by the Free Software Foundation.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
How to run against a clean schroot named 'gutsy':
22
schroot -c gutsy -u root -- sh -c 'apt-get -y install python-unit libsdl-image1.2 libjpeg62 libtiff4 && ./test-sdl-image1.2.py -v'
25
import unittest, subprocess, glob, os.path
28
class SDLImageTest(testlib.TestlibCase):
32
'''Set up prior to each test_* function'''
33
self.loader = 'sdl-image1.2/sdl-image-load'
34
self.assertTrue(os.path.exists(self.loader))
37
'''Clean up after each test_* function'''
39
def _load_image(self,filename,expected=0):
40
self.assertTrue(os.path.exists(filename))
41
rc, out = testlib.cmd([self.loader, filename])
42
self.assertEqual(rc,expected,"Loading: %s\nError: %s\n"%(filename,out))
44
def test_image_loading(self):
45
'''Test loading known-good images'''
46
for img in glob.glob('../data/well-formed.*'):
49
def test_z_bad_gif(self):
50
'''Test fixes for CVE-2007-6697'''
51
self._load_image('sdl-image1.2/CVE-2007-6697.gif',1)
55
if __name__ == '__main__':