Enable EFIv1 compression in bmpbklk_utility.
This lets bmpbklk_utility generate BMPBLOCKs with EFIv1-compressed bitmaps.
It also adds the ability to display or unpack BMPBLOCK blobs.
The compression/decompression routines come from the tianocore EDK on
sourceforge and are written in C, so now there's a mix of C and C++, but it
works just fine.
BUG=chromium-os:11491
TEST=manual
cd src/platform/vboot_reference
make
make runbmptests
Review URL: http://codereview.chromium.org/6508006
Change-Id: Ie05e1a3fd42f4694447c8c440b2432af4ac0f601
diff --git a/tests/bitmaps/Background.bmp b/tests/bitmaps/Background.bmp
new file mode 100644
index 0000000..a83c995
--- /dev/null
+++ b/tests/bitmaps/Background.bmp
Binary files differ
diff --git a/tests/bitmaps/TestBmpBlock.py b/tests/bitmaps/TestBmpBlock.py
index 77ef419..ced270e 100755
--- a/tests/bitmaps/TestBmpBlock.py
+++ b/tests/bitmaps/TestBmpBlock.py
@@ -19,7 +19,7 @@
return (p.returncode, out, err)
-class TestBmpBlock(unittest.TestCase):
+class TestFailures(unittest.TestCase):
def testNoArgs(self):
"""Running with no args should print usage and fail."""
@@ -40,6 +40,72 @@
self.assertNotEqual(0, rc)
self.assertTrue(err.count("Unsupported image format"))
+ def testBadCompression(self):
+ """Wrong compression types should fail."""
+ rc, out, err = runprog(prog, '-z', '99', '-c', 'case_simple.yaml', 'FOO')
+ self.assertNotEqual(0, rc)
+ self.assertTrue(err.count("compression type"))
+
+
+class TestOverWrite(unittest.TestCase):
+
+ def setUp(self):
+ rc, out, err = runprog('/bin/rm', '-rf', './FOO_DIR', 'FOO')
+ self.assertEqual(0, rc)
+
+ def testOverwrite(self):
+ """Create, unpack, unpack again, with and without -f"""
+ rc, out, err = runprog(prog, '-c', 'case_simple.yaml', 'FOO')
+ self.assertEqual(0, rc)
+ rc, out, err = runprog(prog, '-x', '-d', './FOO_DIR', 'FOO')
+ self.assertEqual(0, rc)
+ rc, out, err = runprog(prog, '-x', '-d', './FOO_DIR', 'FOO')
+ self.assertNotEqual(0, rc)
+ self.assertTrue(err.count("File exists"))
+ rc, out, err = runprog(prog, '-x', '-d', './FOO_DIR', '-f', 'FOO')
+ self.assertEqual(0, rc)
+
+ def tearDown(self):
+ rc, out, err = runprog('/bin/rm', '-rf', './FOO_DIR', 'FOO')
+ self.assertEqual(0, rc)
+
+
+class TestPackUnpack(unittest.TestCase):
+
+ def setUp(self):
+ rc, out, err = runprog('/bin/rm', '-rf', './FOO_DIR', 'FOO')
+ self.assertEqual(0, rc)
+
+ def testPackUnpack(self):
+ """Create, unpack, recreate without compression"""
+ rc, out, err = runprog(prog, '-c', 'case_simple.yaml', 'FOO')
+ self.assertEqual(0, rc)
+ rc, out, err = runprog(prog, '-x', '-d', './FOO_DIR', 'FOO')
+ self.assertEqual(0, rc)
+ os.chdir('./FOO_DIR')
+ rc, out, err = runprog(prog, '-c', 'config.yaml', 'BAR')
+ self.assertEqual(0, rc)
+ rc, out, err = runprog('/usr/bin/cmp', '../FOO', 'BAR')
+ self.assertEqual(0, rc)
+ os.chdir('..')
+
+ def testPackUnpackZ(self):
+ """Create, unpack, recreate with explicit compression"""
+ rc, out, err = runprog(prog, '-z', '1', '-c', 'case_simple.yaml', 'FOO')
+ self.assertEqual(0, rc)
+ rc, out, err = runprog(prog, '-x', '-d', './FOO_DIR', 'FOO')
+ self.assertEqual(0, rc)
+ os.chdir('./FOO_DIR')
+ rc, out, err = runprog(prog, '-z', '1', '-c', 'config.yaml', 'BAR')
+ self.assertEqual(0, rc)
+ rc, out, err = runprog('/usr/bin/cmp', '../FOO', 'BAR')
+ self.assertEqual(0, rc)
+ os.chdir('..')
+
+ def tearDown(self):
+ rc, out, err = runprog('/bin/rm', '-rf', './FOO_DIR', 'FOO')
+ self.assertEqual(0, rc)
+
# Run these tests
if __name__ == '__main__':
diff --git a/tests/bitmaps/Word.bmp b/tests/bitmaps/Word.bmp
new file mode 100644
index 0000000..ba4a0e0
--- /dev/null
+++ b/tests/bitmaps/Word.bmp
Binary files differ
diff --git a/tests/bitmaps/case_simple.yaml b/tests/bitmaps/case_simple.yaml
new file mode 100644
index 0000000..5c8590d
--- /dev/null
+++ b/tests/bitmaps/case_simple.yaml
@@ -0,0 +1,27 @@
+
+bmpblock: 1.0
+
+images:
+ background: Background.bmp
+ text: Word.bmp
+
+screens:
+ scr_1:
+ - [0, 0, background]
+ - [45, 45, text ]
+
+ scr_2:
+ - [0, 0, background]
+ - [45, 400, text ]
+
+ scr_3:
+ - [0, 0, background]
+ - [400, 400, text ]
+
+ scr_4:
+ - [0, 0, background]
+ - [400, 45, text ]
+
+
+localizations:
+ - [ scr_1, scr_2, scr_3, scr_4 ]