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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/bitmaps/NotReallyA.bmp ('k') | tests/bitmaps/case_badbmp.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/bitmaps/TestBmpBlock.py
diff --git a/tests/bitmaps/TestBmpBlock.py b/tests/bitmaps/TestBmpBlock.py
new file mode 100755
index 0000000000000000000000000000000000000000..2b91970d23faa0664b907465cfee146170dd42f5
--- /dev/null
+++ b/tests/bitmaps/TestBmpBlock.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python -tt
+
+"""Unit tests for bmpblk_utility.
+"""
+
+import os
+import sys
+import subprocess
+import unittest
+
+def runprog(*args):
+ """Runs specified program and args, returns (exitcode, stdout, stderr)."""
+ p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = p.communicate()
+ return (p.returncode, out, err)
+
+
+class TestBmpBlock(unittest.TestCase):
+
+ def testNoArgs(self):
+ """Running with no args should print usage and fail."""
+ rc, out, err = runprog(prog)
+ self.assertNotEqual(0, rc)
+ self.assertTrue(out.count("Usage:"))
+
+ def testMissingBmp(self):
+ """Missing a bmp specified in the yaml is an error."""
+ rc, out, err = runprog(prog, '-c', '-C', 'case_nobmp.yaml', 'FOO')
+ self.assertNotEqual(0, rc)
+ self.assertTrue(err.count("No such file or directory"))
+
+ def testInvalidBmp(self):
+ """A .bmp file that isn't really a BMP should fail."""
+ rc, out, err = runprog(prog, '-c', '-C', 'case_badbmp.yaml', 'FOO')
+ self.assertNotEqual(0, rc)
+ self.assertTrue(err.count("Unsupported image format"))
+
+
+# Run these tests
+if __name__ == '__main__':
+ varname = 'BMPBLK'
+ if varname not in os.environ:
+ print('You must specify the path to bmpbpk_utility in the $%s '
Randall Spangler 2011/02/07 23:38:35 bmpblk?
+ 'environment variable.' % varname)
+ sys.exit(1)
+ prog = os.environ[varname]
+ print "Testing prog...", prog
+ unittest.main()
+
« 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