mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 18:25:10 +00:00
BUG=chromium-os:11742 TEST=manual Check out sources, run: cd src/platform/vboot_reference make make runbmptests It should pass. Change-Id: I50ebdef26662e7446828315a3f5e2786624508b9 Review URL: http://codereview.chromium.org/6246150
50 lines
1.4 KiB
Python
Executable File
50 lines
1.4 KiB
Python
Executable File
#!/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 bmpblk_utility in the $%s '
|
|
'environment variable.' % varname)
|
|
sys.exit(1)
|
|
prog = os.environ[varname]
|
|
print "Testing prog...", prog
|
|
unittest.main()
|
|
|