Merge lp:~lool/linaro-image-tools/chs-align-tests into lp:linaro-image-tools/11.11

Proposed by Loïc Minier
Status: Merged
Merged at revision: 299
Proposed branch: lp:~lool/linaro-image-tools/chs-align-tests
Merge into: lp:linaro-image-tools/11.11
Diff against target: 136 lines (+20/-17)
1 file modified
linaro_media_create/tests/test_media_create.py (+20/-17)
To merge this branch: bzr merge lp:~lool/linaro-image-tools/chs-align-tests
Reviewer Review Type Date Requested Status
Guilherme Salgado (community) Approve
Review via email: mp+53874@code.launchpad.net

Description of the change

Use HEADS and SECTORS from partitions.py in the tests instead of hardcoding 128/32.

To post a comment you must log in.
Revision history for this message
Loïc Minier (lool) wrote :

I didn't change the expected values to be computed from BOOT_MIN_SIZE_S etc. as I didn't want to duplicate all the logic to align partitions as this would basically be duplicating the bugs too I guess.

Revision history for this message
Guilherme Salgado (salgado) wrote :

On Thu, 2011-03-17 at 18:33 +0000, Loïc Minier wrote:
> I didn't change the expected values to be computed from BOOT_MIN_SIZE_S etc. as I didn't want to duplicate all the logic to align partitions as this would basically be duplicating the bugs too I guess.

I don't see what you mean here, but the changes look good. Thanks!

 review approve

review: Approve
Revision history for this message
Loïc Minier (lool) wrote :

For instance, we could compute the expected offsets from constants such as PART_ALIGN, BOOT_MIN_SIZE etc. in tests which look at the sfdisk commands, but this would duplicate logic

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro_media_create/tests/test_media_create.py'
2--- linaro_media_create/tests/test_media_create.py 2011-03-12 09:31:11 +0000
3+++ linaro_media_create/tests/test_media_create.py 2011-03-17 18:32:33 +0000
4@@ -67,6 +67,8 @@
5 temporarily_overwrite_file_on_dir,
6 )
7 from linaro_media_create.partitions import (
8+ HEADS,
9+ SECTORS,
10 calculate_partition_size_and_offset,
11 convert_size_to_bytes,
12 create_partitions,
13@@ -770,7 +772,7 @@
14 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
15 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
16
17- create_partitions(boards.Mx5Config, self.media, 128, 32, '')
18+ create_partitions(boards.Mx5Config, self.media, HEADS, SECTORS, '')
19
20 self.assertEqual(
21 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
22@@ -780,8 +782,8 @@
23 # every time we run sfdisk it actually repartitions the device,
24 # erasing any partitions created previously.
25 self.assertEqual(
26- [('1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', 128, 32, '',
27- self.media.path)],
28+ [('1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', HEADS, SECTORS,
29+ '', self.media.path)],
30 sfdisk_fixture.mock.calls)
31
32 def test_create_partitions_for_smdkv310(self):
33@@ -790,7 +792,7 @@
34 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
35
36 create_partitions(
37- board_configs['smdkv310'], self.media, 128, 32, '')
38+ board_configs['smdkv310'], self.media, HEADS, SECTORS, '')
39
40 self.assertEqual(
41 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
42@@ -800,22 +802,23 @@
43 # every time we run sfdisk it actually repartitions the device,
44 # erasing any partitions created previously.
45 self.assertEqual(
46- [('1,221183,0xDA\n221184,106496,0x0C,*\n327680,,,-', 128, 32, '',
47- self.media.path)], sfdisk_fixture.mock.calls)
48+ [('1,221183,0xDA\n221184,106496,0x0C,*\n327680,,,-', HEADS,
49+ SECTORS, '', self.media.path)], sfdisk_fixture.mock.calls)
50
51 def test_create_partitions_for_beagle(self):
52 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
53 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
54
55 create_partitions(
56- board_configs['beagle'], self.media, 128, 32, '')
57+ board_configs['beagle'], self.media, HEADS, SECTORS, '')
58
59 self.assertEqual(
60 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
61 'sync'],
62 popen_fixture.mock.commands_executed)
63 self.assertEqual(
64- [('63,106432,0x0C,*\n106496,,,-', 128, 32, '', self.media.path)],
65+ [('63,106432,0x0C,*\n106496,,,-', HEADS, SECTORS, '',
66+ self.media.path)],
67 sfdisk_fixture.mock.calls)
68
69 def test_create_partitions_with_img_file(self):
70@@ -824,7 +827,7 @@
71
72 tmpfile = self.createTempFileAsFixture()
73 create_partitions(
74- board_configs['beagle'], Media(tmpfile), 128, 32, '')
75+ board_configs['beagle'], Media(tmpfile), HEADS, SECTORS, '')
76
77 # Unlike the test for partitioning of a regular block device, in this
78 # case parted was not called as there's no existing partition table
79@@ -832,7 +835,7 @@
80 self.assertEqual(['sync'], popen_fixture.mock.commands_executed)
81
82 self.assertEqual(
83- [('63,106432,0x0C,*\n106496,,,-', 128, 32, '', tmpfile)],
84+ [('63,106432,0x0C,*\n106496,,,-', HEADS, SECTORS, '', tmpfile)],
85 sfdisk_fixture.mock.calls)
86
87 def test_run_sfdisk_commands(self):
88@@ -842,7 +845,7 @@
89 stdout=subprocess.PIPE)
90 proc.communicate()
91 stdout, stderr = run_sfdisk_commands(
92- '2,16063,0xDA', 128, 32, '', tmpfile, as_root=False,
93+ '2,16063,0xDA', HEADS, SECTORS, '', tmpfile, as_root=False,
94 stderr=subprocess.PIPE)
95 self.assertIn('Successfully wrote the new partition table', stdout)
96
97@@ -851,7 +854,7 @@
98 self.assertRaises(
99 cmd_runner.SubcommandNonZeroReturnValue,
100 run_sfdisk_commands,
101- ',1,0xDA', 128, 32, '', tmpfile, as_root=False,
102+ ',1,0xDA', HEADS, SECTORS, '', tmpfile, as_root=False,
103 stderr=subprocess.PIPE)
104
105
106@@ -929,7 +932,7 @@
107 stdout=subprocess.PIPE)
108 proc.communicate()
109 stdout, stderr = run_sfdisk_commands(
110- sfdisk_commands, 128, 32, '', tmpfile, as_root=False,
111+ sfdisk_commands, HEADS, SECTORS, '', tmpfile, as_root=False,
112 # Throw away stderr as sfdisk complains a lot when operating on a
113 # qemu image.
114 stderr=subprocess.PIPE)
115@@ -1009,8 +1012,8 @@
116 # This is the call that would create a 2 GiB image file.
117 ['qemu-img create -f raw %s 2147483648' % tmpfile,
118 # This call would partition the image file.
119- '%s sfdisk --force -D -uS -H 128 -S 32 -C 1024 %s' % (
120- sudo_args, tmpfile),
121+ '%s sfdisk --force -D -uS -H %s -S %s -C 1024 %s' % (
122+ sudo_args, HEADS, SECTORS, tmpfile),
123 # Make sure changes are written to disk.
124 'sync',
125 '%s mkfs.vfat -F 32 %s -n boot' % (sudo_args, bootfs_dev),
126@@ -1036,8 +1039,8 @@
127 True, True, True)
128 self.assertEqual(
129 ['%s parted -s %s mklabel msdos' % (sudo_args, tmpfile),
130- '%s sfdisk --force -D -uS -H 128 -S 32 %s' % (
131- sudo_args, tmpfile),
132+ '%s sfdisk --force -D -uS -H %s -S %s %s' % (
133+ sudo_args, HEADS, SECTORS, tmpfile),
134 'sync',
135 # Since the partitions are mounted, setup_partitions will umount
136 # them before running mkfs.

Subscribers

People subscribed via source and target branches