Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: tests/bitmaps/TestBmpBlock.py

Issue 6246150: Add test framework for bmpblk_utility. (Closed) Base URL: http://git.chromium.org/git/vboot_reference.git@master
Patch Set: Done. PTAL. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/bitmaps/NotReallyA.bmp ('k') | tests/bitmaps/case_badbmp.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python -tt
2
3 """Unit tests for bmpblk_utility.
4 """
5
6 import os
7 import sys
8 import subprocess
9 import unittest
10
11 def runprog(*args):
12 """Runs specified program and args, returns (exitcode, stdout, stderr)."""
13 p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
14 out, err = p.communicate()
15 return (p.returncode, out, err)
16
17
18 class TestBmpBlock(unittest.TestCase):
19
20 def testNoArgs(self):
21 """Running with no args should print usage and fail."""
22 rc, out, err = runprog(prog)
23 self.assertNotEqual(0, rc)
24 self.assertTrue(out.count("Usage:"))
25
26 def testMissingBmp(self):
27 """Missing a bmp specified in the yaml is an error."""
28 rc, out, err = runprog(prog, '-c', '-C', 'case_nobmp.yaml', 'FOO')
29 self.assertNotEqual(0, rc)
30 self.assertTrue(err.count("No such file or directory"))
31
32 def testInvalidBmp(self):
33 """A .bmp file that isn't really a BMP should fail."""
34 rc, out, err = runprog(prog, '-c', '-C', 'case_badbmp.yaml', 'FOO')
35 self.assertNotEqual(0, rc)
36 self.assertTrue(err.count("Unsupported image format"))
37
38
39 # Run these tests
40 if __name__ == '__main__':
41 varname = 'BMPBLK'
42 if varname not in os.environ:
43 print('You must specify the path to bmpbpk_utility in the $%s '
Randall Spangler 2011/02/07 23:38:35 bmpblk?
44 'environment variable.' % varname)
45 sys.exit(1)
46 prog = os.environ[varname]
47 print "Testing prog...", prog
48 unittest.main()
49
OLDNEW
« no previous file with comments | « tests/bitmaps/NotReallyA.bmp ('k') | tests/bitmaps/case_badbmp.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698