diff options
author | Bill Richardson <wfrichar@chromium.org> | 2011-02-17 08:56:33 -0800 |
---|---|---|
committer | Bill Richardson <wfrichar@chromium.org> | 2011-02-17 08:56:33 -0800 |
commit | f82f941b803b0c28240913eb57b34ab4c6c6b96a (patch) | |
tree | 96d0a963f1eddd80223e9566ad62fd047774168d | |
parent | 39dfafd840e81012a52919f1853417da087ecf15 (diff) | |
download | vboot-f82f941b803b0c28240913eb57b34ab4c6c6b96a.tar.gz |
Write images to the bmpblock in the order they appear in the yaml.
This ensures that equivalent yaml files produce identical bmpblock binaries.
BUG=chromium-os:12158
TEST=manual
cd src/platform/vboot_reference
make
make runbmptests
Change-Id: Ic8103ff90e57034d72fb3920a6c198c77768f162
Review URL: http://codereview.chromium.org/6533012
-rwxr-xr-x | tests/bitmaps/TestBmpBlock.py | 20 | ||||
-rw-r--r-- | tests/bitmaps/case_order1.yaml | 36 | ||||
-rw-r--r-- | tests/bitmaps/case_order2.yaml | 36 | ||||
-rw-r--r-- | utility/bmpblk_utility.cc | 12 | ||||
-rw-r--r-- | utility/include/bmpblk_utility.h | 1 |
5 files changed, 100 insertions, 5 deletions
diff --git a/tests/bitmaps/TestBmpBlock.py b/tests/bitmaps/TestBmpBlock.py index be815929..678fe319 100755 --- a/tests/bitmaps/TestBmpBlock.py +++ b/tests/bitmaps/TestBmpBlock.py @@ -115,6 +115,26 @@ class TestPackUnpack(unittest.TestCase): self.assertEqual(0, rc) +class TestReproducable(unittest.TestCase): + + def setUp(self): + rc, out, err = runprog('/bin/rm', '-f', 'ORDER1', 'ORDER2') + self.assertEqual(0, rc) + + def testReproduce(self): + """Equivalent yaml files should produce identical bmpblocks""" + rc, out, err = runprog(prog, '-c', 'case_order1.yaml', 'ORDER1') + self.assertEqual(0, rc) + rc, out, err = runprog(prog, '-c', 'case_order2.yaml', 'ORDER2') + self.assertEqual(0, rc) + rc, out, err = runprog('/usr/bin/cmp', 'ORDER1', 'ORDER2') + self.assertEqual(0, rc) + + def tearDown(self): + rc, out, err = runprog('/bin/rm', '-f', 'ORDER1', 'ORDER2') + self.assertEqual(0, rc) + + # Run these tests if __name__ == '__main__': varname = 'BMPBLK' diff --git a/tests/bitmaps/case_order1.yaml b/tests/bitmaps/case_order1.yaml new file mode 100644 index 00000000..4e1c4297 --- /dev/null +++ b/tests/bitmaps/case_order1.yaml @@ -0,0 +1,36 @@ + +bmpblock: 1.0 + +images: + image0: Background.bmp + image1: Word.bmp + +screens: + scr_a0: + - [0, 0, image0] + + scr_b0: + - [0, 0, image0] + + scr_c0: + - [0, 0, image0] + + scr_d0: + - [0, 0, image0] + + scr_a1: + - [45, 45, image1 ] + + scr_b1: + - [45, 400, image1 ] + + scr_c1: + - [400, 400, image1 ] + + scr_d1: + - [400, 45, image1 ] + +localizations: + - [ scr_a0, scr_b0, scr_c0, scr_d0 ] + - [ scr_a1, scr_b1, scr_c1, scr_d1 ] + diff --git a/tests/bitmaps/case_order2.yaml b/tests/bitmaps/case_order2.yaml new file mode 100644 index 00000000..91ac6dd7 --- /dev/null +++ b/tests/bitmaps/case_order2.yaml @@ -0,0 +1,36 @@ + +bmpblock: 1.0 + +images: + zmage0: Background.bmp + image1: Word.bmp + +screens: + scr_a4: + - [0, 0, zmage0] + + scr_b4: + - [0, 0, zmage0] + + scr_c4: + - [0, 0, zmage0] + + scr_d4: + - [0, 0, zmage0] + + scr_a1: + - [45, 45, image1 ] + + scr_b1: + - [45, 400, image1 ] + + scr_c1: + - [400, 400, image1 ] + + scr_d1: + - [400, 45, image1 ] + +localizations: + - [ scr_a4, scr_b4, scr_c4, scr_d4 ] + - [ scr_a1, scr_b1, scr_c1, scr_d1 ] + diff --git a/utility/bmpblk_utility.cc b/utility/bmpblk_utility.cc index c9188a8e..742bd9bc 100644 --- a/utility/bmpblk_utility.cc +++ b/utility/bmpblk_utility.cc @@ -189,6 +189,7 @@ void BmpBlockUtil::parse_images(yaml_parser_t *parser) { error("Syntax error in parsing images.\n"); } image_filename = (char*)event.data.scalar.value; + config_.image_names.push_back(image_name); config_.images_map[image_name] = ImageConfig(); config_.images_map[image_name].filename = image_filename; break; @@ -476,11 +477,12 @@ void BmpBlockUtil::pack_bmpblock() { /* Compute the ImageInfo offsets from start of BMPBLOCK. */ uint32_t current_offset = sizeof(BmpBlockHeader) + sizeof(ScreenLayout) * config_.screens_map.size(); - for (StrImageConfigMap::iterator it = config_.images_map.begin(); - it != config_.images_map.end(); - ++it) { - it->second.offset = current_offset; - current_offset += sizeof(ImageInfo) + it->second.data.compressed_size; + for (unsigned int i = 0; i < config_.image_names.size(); ++i) { + string image_name = config_.image_names[i]; + ImageConfig &img = config_.images_map[image_name]; + img.offset = current_offset; + current_offset += sizeof(ImageInfo) + + config_.images_map[image_name].data.compressed_size; /* Make it 4-byte aligned. */ if ((current_offset & 3) > 0) { current_offset = (current_offset & ~3) + 4; diff --git a/utility/include/bmpblk_utility.h b/utility/include/bmpblk_utility.h index 099767a5..53f135d7 100644 --- a/utility/include/bmpblk_utility.h +++ b/utility/include/bmpblk_utility.h @@ -42,6 +42,7 @@ typedef map<string, ScreenConfig> StrScreenConfigMap; typedef struct BmpBlockConfig { string config_filename; BmpBlockHeader header; + vector<string> image_names; StrImageConfigMap images_map; StrScreenConfigMap screens_map; vector<vector<string> > localizations; |