Merge lp:~salgado/linaro-image-tools/bug-673570 into lp:linaro-image-tools/11.11

Proposed by Guilherme Salgado
Status: Merged
Approved by: James Westby
Approved revision: 295
Merged at revision: 296
Proposed branch: lp:~salgado/linaro-image-tools/bug-673570
Merge into: lp:linaro-image-tools/11.11
Diff against target: 498 lines (+133/-124)
2 files modified
linaro_media_create/cmd_runner.py (+1/-4)
linaro_media_create/tests/test_media_create.py (+132/-120)
To merge this branch: bzr merge lp:~salgado/linaro-image-tools/bug-673570
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+52696@code.launchpad.net

Description of the change

Change cmd_runner.run() to always pass -E to sudo. (fixes bug 673570)

Also, since I'd have to change lots of tests to reflect the change, I decided
to update them to use MockCmdRunnerPopenFixture.commands_executed instead of
.calls as the former makes for more readable tests.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro_media_create/cmd_runner.py'
2--- linaro_media_create/cmd_runner.py 2011-01-29 16:33:38 +0000
3+++ linaro_media_create/cmd_runner.py 2011-03-09 15:16:18 +0000
4@@ -38,10 +38,7 @@
5 assert isinstance(args, (list, tuple)), (
6 "The command to run must be a list or tuple, found: %s" % type(args))
7 if as_root and os.getuid() != 0:
8- args = args[:]
9- # TODO: We might want to always use 'sudo -E' here to avoid problems
10- # like https://launchpad.net/bugs/673570
11- args.insert(0, 'sudo')
12+ args = ['sudo', '-E'] + args
13 return Popen(args, stdin=stdin, stdout=stdout, stderr=stderr)
14
15
16
17=== modified file 'linaro_media_create/tests/test_media_create.py'
18--- linaro_media_create/tests/test_media_create.py 2011-03-03 13:44:11 +0000
19+++ linaro_media_create/tests/test_media_create.py 2011-03-09 15:16:18 +0000
20@@ -101,6 +101,9 @@
21 )
22
23
24+sudo_args = 'sudo -E'
25+
26+
27 def preferred_tools_dir():
28 prefer_dir = None
29 # running from bzr checkout?
30@@ -169,7 +172,7 @@
31 fixture = self.useFixture(MockCmdRunnerPopenFixture())
32 install_package_providing('mkfs.vfat')
33 self.assertEqual(
34- ['sudo apt-get install dosfstools'],
35+ ['%s apt-get install dosfstools' % sudo_args],
36 fixture.mock.commands_executed)
37
38 def test_not_found_package(self):
39@@ -495,10 +498,8 @@
40 self.useFixture(fixture)
41 get_uuid("/dev/rootfs")
42 self.assertEquals(
43- [[
44- "sudo", "blkid", "-o", "udev", "-p", "-c", "/dev/null",
45- "/dev/rootfs"]],
46- fixture.mock.calls)
47+ ["%s blkid -o udev -p -c /dev/null /dev/rootfs" % sudo_args],
48+ fixture.mock.commands_executed)
49
50 def test_parse_blkid_output(self):
51 output = (
52@@ -524,7 +525,8 @@
53 fixture = self.useFixture(MockCmdRunnerPopenFixture())
54 self.useFixture(MockSomethingFixture(os, 'getuid', lambda: 1000))
55 cmd_runner.run(['foo', 'bar'], as_root=True).wait()
56- self.assertEqual([['sudo', 'foo', 'bar']], fixture.mock.calls)
57+ self.assertEqual(
58+ ['%s foo bar' % sudo_args], fixture.mock.commands_executed)
59
60 def test_run_as_root_as_root(self):
61 fixture = self.useFixture(MockCmdRunnerPopenFixture())
62@@ -571,28 +573,28 @@
63 fixture = self._mock_Popen()
64 make_uImage('load_addr', 'parts_dir', 'sub_arch', 'boot_disk')
65 expected = [
66- 'sudo', 'mkimage', '-A', 'arm', '-O', 'linux', '-T', 'kernel',
67- '-C', 'none', '-a', 'load_addr', '-e', 'load_addr', '-n', 'Linux',
68- '-d', 'parts_dir/vmlinuz-*-sub_arch', 'boot_disk/uImage']
69- self.assertEqual([expected], fixture.mock.calls)
70+ '%s mkimage -A arm -O linux -T kernel -C none -a load_addr '
71+ '-e load_addr -n Linux -d parts_dir/vmlinuz-*-sub_arch '
72+ 'boot_disk/uImage' % sudo_args]
73+ self.assertEqual(expected, fixture.mock.commands_executed)
74
75 def test_make_uInitrd(self):
76 self._mock_get_file_matching()
77 fixture = self._mock_Popen()
78 make_uInitrd('parts_dir', 'sub_arch', 'boot_disk')
79 expected = [
80- 'sudo', 'mkimage', '-A', 'arm', '-O', 'linux', '-T', 'ramdisk',
81- '-C', 'none', '-a', '0', '-e', '0', '-n', 'initramfs',
82- '-d', 'parts_dir/initrd.img-*-sub_arch', 'boot_disk/uInitrd']
83- self.assertEqual([expected], fixture.mock.calls)
84+ '%s mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 '
85+ '-n initramfs -d parts_dir/initrd.img-*-sub_arch '
86+ 'boot_disk/uInitrd' % sudo_args]
87+ self.assertEqual(expected, fixture.mock.commands_executed)
88
89 def test_install_mx5_boot_loader(self):
90 fixture = self._mock_Popen()
91 install_mx5_boot_loader("imx_file", "boot_device_or_file")
92 expected = [
93- 'sudo', 'dd', 'if=imx_file', 'of=boot_device_or_file', 'bs=1024',
94- 'seek=1', 'conv=notrunc']
95- self.assertEqual([expected], fixture.mock.calls)
96+ '%s dd if=imx_file of=boot_device_or_file bs=1024 '
97+ 'seek=1 conv=notrunc' % sudo_args]
98+ self.assertEqual(expected, fixture.mock.commands_executed)
99
100 def test_install_omap_boot_loader(self):
101 fixture = self._mock_Popen()
102@@ -601,9 +603,8 @@
103 lambda chroot_dir: "%s/MLO" % chroot_dir))
104 install_omap_boot_loader("chroot_dir", "boot_disk")
105 expected = [
106- ['sudo', 'cp', '-v', 'chroot_dir/MLO', 'boot_disk'],
107- ['sync']]
108- self.assertEqual(expected, fixture.mock.calls)
109+ '%s cp -v chroot_dir/MLO boot_disk' % sudo_args, 'sync']
110+ self.assertEqual(expected, fixture.mock.commands_executed)
111
112 def test_make_boot_script(self):
113 self.useFixture(MockSomethingFixture(
114@@ -615,11 +616,12 @@
115 plain_boot_script_path = os.path.join(tempdir, 'boot.txt')
116 make_boot_script('boot script data', boot_script_path)
117 expected = [
118- ['sudo', 'cp', '/tmp/random-abxzr', plain_boot_script_path],
119- ['sudo', 'mkimage', '-A', 'arm', '-O', 'linux', '-T', 'script',
120- '-C', 'none', '-a', '0', '-e', '0', '-n', 'boot script',
121- '-d', plain_boot_script_path, boot_script_path]]
122- self.assertEqual(expected, fixture.mock.calls)
123+ '%s cp /tmp/random-abxzr %s' % (
124+ sudo_args, plain_boot_script_path),
125+ '%s mkimage -A arm -O linux -T script -C none -a 0 -e 0 '
126+ '-n boot script -d %s %s' % (
127+ sudo_args, plain_boot_script_path, boot_script_path)]
128+ self.assertEqual(expected, fixture.mock.commands_executed)
129
130 def test_get_file_matching(self):
131 prefix = ''.join(
132@@ -682,9 +684,9 @@
133 create_partitions(boards.Mx5Config, self.media, 255, 63, '')
134
135 self.assertEqual(
136- [['sudo', 'parted', '-s', self.media.path, 'mklabel', 'msdos'],
137- ['sync']],
138- popen_fixture.mock.calls)
139+ ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
140+ 'sync'],
141+ popen_fixture.mock.commands_executed)
142 # Notice that we create all partitions in a single sfdisk run because
143 # every time we run sfdisk it actually repartitions the device,
144 # erasing any partitions created previously.
145@@ -700,9 +702,9 @@
146 board_configs['beagle'], self.media, 255, 63, '')
147
148 self.assertEqual(
149- [['sudo', 'parted', '-s', self.media.path, 'mklabel', 'msdos'],
150- ['sync']],
151- popen_fixture.mock.calls)
152+ ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
153+ 'sync'],
154+ popen_fixture.mock.commands_executed)
155 self.assertEqual(
156 [('63,106432,0x0C,*\n106496,,,-', 255, 63, '', self.media.path)],
157 sfdisk_fixture.mock.calls)
158@@ -718,7 +720,7 @@
159 # Unlike the test for partitioning of a regular block device, in this
160 # case parted was not called as there's no existing partition table
161 # for us to overwrite on the image file.
162- self.assertEqual([['sync']], popen_fixture.mock.calls)
163+ self.assertEqual(['sync'], popen_fixture.mock.commands_executed)
164
165 self.assertEqual(
166 [('63,106432,0x0C,*\n106496,,,-', 255, 63, '', tempfile)],
167@@ -831,7 +833,8 @@
168 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
169 ensure_partition_is_not_mounted('/dev/whatever')
170 self.assertEqual(
171- [['sudo', 'umount', '/dev/whatever']], popen_fixture.mock.calls)
172+ ['%s umount /dev/whatever' % sudo_args],
173+ popen_fixture.mock.commands_executed)
174
175 def test_ensure_partition_is_not_mounted_for_umounted_partition(self):
176 self.useFixture(MockSomethingFixture(
177@@ -850,11 +853,11 @@
178 # it calls losetup correctly.
179 get_boot_and_root_loopback_devices(tempfile)
180 self.assertEqual(
181- [['sudo', 'losetup', '-f', '--show', tempfile, '--offset',
182- '8388608', '--sizelimit', '8061952'],
183- ['sudo', 'losetup', '-f', '--show', tempfile, '--offset',
184- '16777216', '--sizelimit', '14680064']],
185- popen_fixture.mock.calls)
186+ ['%s losetup -f --show %s --offset 8388608 --sizelimit 8061952'
187+ % (sudo_args, tempfile),
188+ '%s losetup -f --show %s --offset 16777216 --sizelimit 14680064'
189+ % (sudo_args, tempfile)],
190+ popen_fixture.mock.commands_executed)
191
192 # get_boot_and_root_loopback_devices will also setup two exit handlers
193 # to de-register the loopback devices set up above.
194@@ -865,8 +868,9 @@
195 # don't have a device to pass to 'losetup -d', but when a device is
196 # setup it is passed to the atexit handler.
197 self.assertEquals(
198- [['sudo', 'losetup', '-d', ''], ['sudo', 'losetup', '-d', '']],
199- popen_fixture.mock.calls)
200+ ['%s losetup -d ' % sudo_args,
201+ '%s losetup -d ' % sudo_args],
202+ popen_fixture.mock.commands_executed)
203
204 def test_setup_partitions_for_image_file(self):
205 # In practice we could pass an empty image file to setup_partitions,
206@@ -894,15 +898,15 @@
207 'root', 'ext3', True, True, True)
208 self.assertEqual(
209 # This is the call that would create a 2 GiB image file.
210- [['qemu-img', 'create', '-f', 'raw', tempfile, '2147483648'],
211+ ['qemu-img create -f raw %s 2147483648' % tempfile,
212 # This call would partition the image file.
213- ['sudo', 'sfdisk', '--force', '-D', '-uS', '-H', '255', '-S',
214- '63', '-C', '261', tempfile],
215+ '%s sfdisk --force -D -uS -H 255 -S 63 -C 261 %s' % (
216+ sudo_args, tempfile),
217 # Make sure changes are written to disk.
218- ['sync'],
219- ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'],
220- ['sudo', 'mkfs.ext3', rootfs_dev, '-L', 'root']],
221- popen_fixture.mock.calls)
222+ 'sync',
223+ '%s mkfs.vfat -F 32 %s -n boot' % (sudo_args, bootfs_dev),
224+ '%s mkfs.ext3 %s -L root' % (sudo_args, rootfs_dev)],
225+ popen_fixture.mock.commands_executed)
226
227 def test_setup_partitions_for_block_device(self):
228 self.useFixture(MockSomethingFixture(
229@@ -922,17 +926,17 @@
230 board_configs['beagle'], media, '2G', 'boot', 'root', 'ext3',
231 True, True, True)
232 self.assertEqual(
233- [['sudo', 'parted', '-s', tempfile, 'mklabel', 'msdos'],
234- ['sudo', 'sfdisk', '--force', '-D', '-uS', '-H', '255', '-S',
235- '63', tempfile],
236- ['sync'],
237+ ['%s parted -s %s mklabel msdos' % (sudo_args, tempfile),
238+ '%s sfdisk --force -D -uS -H 255 -S 63 %s' % (
239+ sudo_args, tempfile),
240+ 'sync',
241 # Since the partitions are mounted, setup_partitions will umount
242 # them before running mkfs.
243- ['sudo', 'umount', bootfs_dev],
244- ['sudo', 'umount', rootfs_dev],
245- ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'],
246- ['sudo', 'mkfs.ext3', rootfs_dev, '-L', 'root']],
247- popen_fixture.mock.calls)
248+ '%s umount %s' % (sudo_args, bootfs_dev),
249+ '%s umount %s' % (sudo_args, rootfs_dev),
250+ '%s mkfs.vfat -F 32 %s -n boot' % (sudo_args, bootfs_dev),
251+ '%s mkfs.ext3 %s -L root' % (sudo_args, rootfs_dev)],
252+ popen_fixture.mock.commands_executed)
253
254
255 class TestPopulateBoot(TestCaseWithFixtures):
256@@ -944,10 +948,10 @@
257 'chroot_dir/casper', True, False, [], 'chroot_dir', 'rootfs_uuid',
258 'boot_disk', 'boot_disk/boot_script', 'boot_device_or_file')
259 expected_calls = [
260- ["mkdir", "-p", "boot_disk"],
261- ["sudo", "mount", "boot_partition", "boot_disk"],
262- ["sync"],
263- ["sudo", "umount", "boot_disk"]]
264+ 'mkdir -p boot_disk',
265+ '%s mount boot_partition boot_disk' % sudo_args,
266+ 'sync',
267+ '%s umount boot_disk' % sudo_args]
268
269 def save_args(self, *args):
270 self.saved_args = args
271@@ -970,20 +974,23 @@
272 def test_populate_boot_live(self):
273 self.prepare_config(boards.BoardConfig)
274 self.call_populate_boot(self.config, is_live=True)
275- self.assertEquals(self.expected_calls, self.popen_fixture.mock.calls)
276+ self.assertEquals(
277+ self.expected_calls, self.popen_fixture.mock.commands_executed)
278 self.assertEquals(self.expected_args_live, self.saved_args)
279
280 def test_populate_boot_regular(self):
281 self.prepare_config(boards.BoardConfig)
282 self.call_populate_boot(self.config)
283- self.assertEquals(self.expected_calls, self.popen_fixture.mock.calls)
284+ self.assertEquals(
285+ self.expected_calls, self.popen_fixture.mock.commands_executed)
286 self.assertEquals(self.expected_args, self.saved_args)
287
288 def test_populate_boot_uboot_flavor(self):
289 self.prepare_config(boards.BoardConfig)
290 self.config.uboot_flavor = "uboot_flavor"
291 self.call_populate_boot(self.config)
292- self.assertEquals(self.expected_calls, self.popen_fixture.mock.calls)
293+ self.assertEquals(
294+ self.expected_calls, self.popen_fixture.mock.commands_executed)
295 self.assertEquals(self.expected_args, self.saved_args)
296
297 def test_populate_boot_uboot_in_boot_part(self):
298@@ -992,10 +999,11 @@
299 self.config.uboot_in_boot_part = True
300 self.call_populate_boot(self.config)
301 expected_calls = self.expected_calls[:]
302- expected_calls.insert(2, [
303- "sudo", "cp", "-v",
304- "chroot_dir/usr/lib/u-boot/uboot_flavor/u-boot.bin", "boot_disk"])
305- self.assertEquals(expected_calls, self.popen_fixture.mock.calls)
306+ expected_calls.insert(2,
307+ '%s cp -v chroot_dir/usr/lib/u-boot/uboot_flavor/u-boot.bin '
308+ 'boot_disk' % sudo_args)
309+ self.assertEquals(
310+ expected_calls, self.popen_fixture.mock.commands_executed)
311 self.assertEquals(self.expected_args, self.saved_args)
312
313 def test_populate_boot_no_uboot_flavor(self):
314@@ -1047,14 +1055,15 @@
315 self.assertEqual(True, self.create_flash_kernel_config_called)
316 swap_file = os.path.join(root_disk, 'SWAP.swap')
317 expected = [
318- ['sudo', 'mount', '/dev/rootfs', root_disk],
319- ['sudo', 'mv', contents_bin, contents_etc, root_disk],
320- ['sudo', 'dd', 'if=/dev/zero', 'of=%s' % swap_file, 'bs=1M',
321- 'count=100'],
322- ['sudo', 'mkswap', swap_file],
323- ['sync'],
324- ['sudo', 'umount', root_disk]]
325- self.assertEqual(expected, popen_fixture.mock.calls)
326+ '%s mount /dev/rootfs %s' % (sudo_args, root_disk),
327+ '%s mv %s %s %s' % (
328+ sudo_args, contents_bin, contents_etc, root_disk),
329+ '%s dd if=/dev/zero of=%s bs=1M count=100' % (
330+ sudo_args, swap_file),
331+ '%s mkswap %s' % (sudo_args, swap_file),
332+ 'sync',
333+ '%s umount %s' % (sudo_args, root_disk)]
334+ self.assertEqual(expected, popen_fixture.mock.commands_executed)
335
336 def test_create_flash_kernel_config(self):
337 fixture = self.useFixture(MockCmdRunnerPopenFixture())
338@@ -1070,9 +1079,9 @@
339 # list of arguments stored.
340 tmpfile = call[-2]
341 self.assertEqual(
342- ['sudo', 'mv', '-f', tmpfile,
343- '%s/etc/flash-kernel.conf' % tempdir],
344- call)
345+ '%s mv -f %s %s/etc/flash-kernel.conf' % (
346+ sudo_args, tmpfile, tempdir),
347+ fixture.mock.commands_executed[0])
348 self.assertEqual('UBOOT_PART=/dev/mmcblk0p1', open(tmpfile).read())
349
350 def test_move_contents(self):
351@@ -1082,8 +1091,8 @@
352
353 move_contents(tempdir, '/tmp/')
354
355- self.assertEqual([['sudo', 'mv', file1, '/tmp/']],
356- popen_fixture.mock.calls)
357+ self.assertEqual(['%s mv %s /tmp/' % (sudo_args, file1)],
358+ popen_fixture.mock.commands_executed)
359
360 def test_has_space_left_for_swap(self):
361 statvfs = os.statvfs('/')
362@@ -1112,7 +1121,8 @@
363 # The call moves tmpfile to the given path, so tmpfile is the next to
364 # last in the list of arguments stored.
365 tmpfile = call[-2]
366- self.assertEqual(['sudo', 'mv', '-f', tmpfile, path], call)
367+ self.assertEqual(['%s mv -f %s %s' % (sudo_args, tmpfile, path)],
368+ fixture.mock.commands_executed)
369 self.assertEqual(data, open(tmpfile).read())
370
371
372@@ -1200,39 +1210,41 @@
373 fixture = self.useFixture(MockCmdRunnerPopenFixture())
374 temporarily_overwrite_file_on_dir('/path/to/file', '/dir', '/tmp/dir')
375 self.assertEquals(
376- [['sudo', 'mv', '-f', '/dir/file', '/tmp/dir/file'],
377- ['sudo', 'cp', '/path/to/file', '/dir']],
378- fixture.mock.calls)
379+ ['%s mv -f /dir/file /tmp/dir/file' % sudo_args,
380+ '%s cp /path/to/file /dir' % sudo_args],
381+ fixture.mock.commands_executed)
382
383 fixture.mock.calls = []
384 run_local_atexit_funcs()
385 self.assertEquals(
386- [['sudo', 'mv', '-f', '/tmp/dir/file', '/dir']],
387- fixture.mock.calls)
388+ ['%s mv -f /tmp/dir/file /dir' % sudo_args],
389+ fixture.mock.commands_executed)
390
391 def test_copy_file(self):
392 fixture = self.useFixture(MockCmdRunnerPopenFixture())
393 copy_file('/path/to/file', '/dir')
394 self.assertEquals(
395- [['sudo', 'cp', '/path/to/file', '/dir']],
396- fixture.mock.calls)
397+ ['%s cp /path/to/file /dir' % sudo_args],
398+ fixture.mock.commands_executed)
399
400 fixture.mock.calls = []
401 run_local_atexit_funcs()
402 self.assertEquals(
403- [['sudo', 'rm', '-f', '/dir/file']], fixture.mock.calls)
404+ ['%s rm -f /dir/file' % sudo_args],
405+ fixture.mock.commands_executed)
406
407 def test_mount_chroot_proc(self):
408 fixture = self.useFixture(MockCmdRunnerPopenFixture())
409 mount_chroot_proc('chroot')
410 self.assertEquals(
411- [['sudo', 'mount', 'proc', 'chroot/proc', '-t', 'proc']],
412- fixture.mock.calls)
413+ ['%s mount proc chroot/proc -t proc' % sudo_args],
414+ fixture.mock.commands_executed)
415
416 fixture.mock.calls = []
417 run_local_atexit_funcs()
418 self.assertEquals(
419- [['sudo', 'umount', '-v', 'chroot/proc']], fixture.mock.calls)
420+ ['%s umount -v chroot/proc' % sudo_args],
421+ fixture.mock.commands_executed)
422
423 def test_install_hwpack(self):
424 self.useFixture(MockSomethingFixture(
425@@ -1241,15 +1253,16 @@
426 force_yes = False
427 install_hwpack('chroot', 'hwpack.tgz', force_yes)
428 self.assertEquals(
429- [['sudo', 'cp', 'hwpack.tgz', 'chroot'],
430- ['sudo', 'chroot', 'chroot', 'linaro-hwpack-install',
431- '/hwpack.tgz']],
432- fixture.mock.calls)
433+ ['%s cp hwpack.tgz chroot' % sudo_args,
434+ '%s chroot chroot linaro-hwpack-install /hwpack.tgz'
435+ % sudo_args],
436+ fixture.mock.commands_executed)
437
438 fixture.mock.calls = []
439 run_local_atexit_funcs()
440 self.assertEquals(
441- [['sudo', 'rm', '-f', 'chroot/hwpack.tgz']], fixture.mock.calls)
442+ ['%s rm -f chroot/hwpack.tgz' % sudo_args],
443+ fixture.mock.commands_executed)
444
445 def test_install_hwpacks(self):
446 self.useFixture(MockSomethingFixture(
447@@ -1264,29 +1277,28 @@
448 'hwpack2.tgz')
449 linaro_hwpack_install = find_command(
450 'linaro-hwpack-install', prefer_dir=prefer_dir)
451- self.assertEquals(
452- [['sudo', 'mv', '-f', 'chroot/etc/resolv.conf',
453- '/tmp/dir/resolv.conf'],
454- ['sudo', 'cp', '/etc/resolv.conf', 'chroot/etc'],
455- ['sudo', 'mv', '-f', 'chroot/etc/hosts', '/tmp/dir/hosts'],
456- ['sudo', 'cp', '/etc/hosts', 'chroot/etc'],
457- ['sudo', 'cp', '/usr/bin/qemu-arm-static', 'chroot/usr/bin'],
458- ['sudo', 'cp', linaro_hwpack_install, 'chroot/usr/bin'],
459- ['sudo', 'mount', 'proc', 'chroot/proc', '-t', 'proc'],
460- ['sudo', 'cp', 'hwpack1.tgz', 'chroot'],
461- ['sudo', 'chroot', 'chroot', 'linaro-hwpack-install',
462- '--force-yes', '/hwpack1.tgz'],
463- ['sudo', 'cp', 'hwpack2.tgz', 'chroot'],
464- ['sudo', 'chroot', 'chroot', 'linaro-hwpack-install',
465- '--force-yes', '/hwpack2.tgz'],
466- ['sudo', 'rm', '-f', 'chroot/hwpack2.tgz'],
467- ['sudo', 'rm', '-f', 'chroot/hwpack1.tgz'],
468- ['sudo', 'umount', '-v', 'chroot/proc'],
469- ['sudo', 'rm', '-f', 'chroot/usr/bin/linaro-hwpack-install'],
470- ['sudo', 'rm', '-f', 'chroot/usr/bin/qemu-arm-static'],
471- ['sudo', 'mv', '-f', '/tmp/dir/hosts', 'chroot/etc'],
472- ['sudo', 'mv', '-f', '/tmp/dir/resolv.conf', 'chroot/etc']],
473- fixture.mock.calls)
474+ expected = [
475+ 'mv -f chroot/etc/resolv.conf /tmp/dir/resolv.conf',
476+ 'cp /etc/resolv.conf chroot/etc',
477+ 'mv -f chroot/etc/hosts /tmp/dir/hosts',
478+ 'cp /etc/hosts chroot/etc',
479+ 'cp /usr/bin/qemu-arm-static chroot/usr/bin',
480+ 'cp %s chroot/usr/bin' % linaro_hwpack_install,
481+ 'mount proc chroot/proc -t proc',
482+ 'cp hwpack1.tgz chroot',
483+ 'chroot chroot linaro-hwpack-install --force-yes /hwpack1.tgz',
484+ 'cp hwpack2.tgz chroot',
485+ 'chroot chroot linaro-hwpack-install --force-yes /hwpack2.tgz',
486+ 'rm -f chroot/hwpack2.tgz',
487+ 'rm -f chroot/hwpack1.tgz',
488+ 'umount -v chroot/proc',
489+ 'rm -f chroot/usr/bin/linaro-hwpack-install',
490+ 'rm -f chroot/usr/bin/qemu-arm-static',
491+ 'mv -f /tmp/dir/hosts chroot/etc',
492+ 'mv -f /tmp/dir/resolv.conf chroot/etc']
493+ expected = [
494+ "%s %s" % (sudo_args, line) for line in expected]
495+ self.assertEquals(expected, fixture.mock.commands_executed)
496
497 def test_run_local_atexit_funcs(self):
498 self.useFixture(MockSomethingFixture(

Subscribers

People subscribed via source and target branches