~raharper/qa-regression-testing/scripts-test-qemu-fixups

« back to all changes in this revision

Viewing changes to scripts/test-sdl-image1.2.py

  • Committer: Kees Cook
  • Date: 2008-03-25 21:56:23 UTC
  • Revision ID: kees.cook@canonical.com-20080325215623-kmm0lvsq014ngv3r
sdl-image1.2 tests, with "well formed" images

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
#
 
3
#    test-sdl-image1.2.py quality assurance test script
 
4
#    Copyright (C) 2008 Canonical Ltd.
 
5
#    Author: Kees Cook <kees@canonical.com>
 
6
#
 
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.
 
10
#
 
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.
 
15
#
 
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/>.
 
18
#
 
19
 
 
20
'''
 
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'
 
23
'''
 
24
 
 
25
import unittest, subprocess, glob, os.path
 
26
import testlib
 
27
 
 
28
class SDLImageTest(testlib.TestlibCase):
 
29
    '''Test SDL image.'''
 
30
 
 
31
    def setUp(self):
 
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))
 
35
 
 
36
    def tearDown(self):
 
37
        '''Clean up after each test_* function'''
 
38
 
 
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))
 
43
 
 
44
    def test_image_loading(self):
 
45
        '''Test loading known-good images'''
 
46
        for img in glob.glob('../data/well-formed.*'):
 
47
            self._load_image(img)
 
48
 
 
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)
 
52
        
 
53
        
 
54
 
 
55
if __name__ == '__main__':
 
56
    unittest.main()