153
153
[('FORMAT', format), ('metadata', metadata)])
154
154
hp = HardwarepackHandler([tarball], bootloader='u_boot')
156
self.assertEquals(hp.get_field('u_boot_file')[0], 'a_file')
156
self.assertEquals(hp.get_field('bootloader_file')[0], 'a_file')
158
158
def test_hardwarepack_boards(self):
159
159
metadata = ("format: 3.0\nname: ahwpack\nversion: 4\narchitecture: "
168
168
[('FORMAT', format), ('metadata', metadata)])
169
169
hp = HardwarepackHandler([tarball], board='panda')
171
self.assertEquals(hp.get_field('u_boot_file')[0], 'panda_file')
171
self.assertEquals(hp.get_field('bootloader_file')[0], 'panda_file')
173
173
def test_hardwarepack_boards_and_bootloaders(self):
174
174
metadata = ("format: 3.0\nname: ahwpack\nversion: 4\narchitecture: "
186
186
[('FORMAT', format), ('metadata', metadata)])
187
187
hp = HardwarepackHandler([tarball], board='panda', bootloader='uefi')
189
self.assertEquals(hp.get_field('u_boot_file')[0],
189
self.assertEquals(hp.get_field('bootloader_file')[0],
190
190
'uefi_panda_file')
192
192
def add_to_tarball(self, files, tarball=None):
268
268
[('metadata', metadata)])
269
269
hp = HardwarepackHandler([tarball])
271
test_data, _ = hp.get_field('u_boot_file')
271
test_data, _ = hp.get_field('bootloader_file')
272
272
self.assertEqual(test_data, data)
274
274
def test_preserves_formatters(self):
278
278
[('metadata', metadata)])
279
279
hp = HardwarepackHandler([tarball])
281
test_data, _ = hp.get_field('u_boot_file')
281
test_data, _ = hp.get_field('bootloader_file')
282
282
self.assertEqual(test_data, data)
284
284
def test_creates_tempdir(self):
598
598
def test_old_file_present(self):
599
599
tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
600
path = _create_uboot_dir(tempdir, self.config.uboot_flavor)
600
path = _create_uboot_dir(tempdir, self.config.bootloader_flavor)
601
601
spl_path = os.path.join(path, 'v310_mmc_spl.bin')
602
602
open(spl_path, 'w').close()
603
603
self.assertEquals(spl_path, self.config._get_samsung_spl(tempdir))
605
605
def test_new_file_present(self):
606
606
tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
607
path = _create_uboot_dir(tempdir, self.config.uboot_flavor)
607
path = _create_uboot_dir(tempdir, self.config.bootloader_flavor)
608
608
spl_path = os.path.join(path, 'u-boot-mmc-spl.bin')
609
609
open(spl_path, 'w').close()
610
610
self.assertEquals(spl_path, self.config._get_samsung_spl(tempdir))
612
612
def test_prefers_old_path(self):
613
613
tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
614
path = _create_uboot_dir(tempdir, self.config.uboot_flavor)
614
path = _create_uboot_dir(tempdir, self.config.bootloader_flavor)
615
615
old_spl_path = os.path.join(path, 'v310_mmc_spl.bin')
616
616
new_spl_path = os.path.join(path, 'u-boot-mmc-spl.bin')
617
617
open(old_spl_path, 'w').close()
625
625
def test_uses_uboot_flavour(self):
626
626
chroot_dir = "chroot"
627
627
uboot_file = os.path.join(chroot_dir, 'usr', 'lib', 'u-boot',
628
self.config.uboot_flavor, 'u-boot.bin')
628
self.config.bootloader_flavor, 'u-boot.bin')
629
629
self.assertEquals(
630
uboot_file, self.config._get_samsung_uboot(chroot_dir))
630
uboot_file, self.config._get_samsung_bootloader(chroot_dir))
633
633
class TestGetOrigenSPL(TestCaseWithFixtures):
641
641
def test_new_file_present(self):
642
642
tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
643
path = _create_uboot_dir(tempdir, self.config.uboot_flavor)
643
path = _create_uboot_dir(tempdir, self.config.bootloader_flavor)
644
644
spl_path = os.path.join(path, 'u-boot-mmc-spl.bin')
645
645
open(spl_path, 'w').close()
646
646
self.assertEquals(spl_path, self.config._get_samsung_spl(tempdir))
1061
1061
def test_mx5_steps(self):
1062
1062
class SomeMx5Config(boards.Mx5Config):
1063
uboot_flavor = 'uboot_flavor'
1063
bootloader_flavor = 'bootloader_flavor'
1064
1064
SomeMx5Config.hardwarepack_handler = (
1065
1065
TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
1066
1066
SomeMx5Config.hardwarepack_handler.get_format = (
2051
2051
def test_install_smdk_u_boot(self):
2052
2052
fixture = self._mock_Popen()
2053
uboot_flavor = boards.SMDKV310Config.uboot_flavor
2053
bootloader_flavor = boards.SMDKV310Config.bootloader_flavor
2054
2054
self.useFixture(MockSomethingFixture(os.path, 'getsize',
2055
2055
lambda file: 1))
2056
2056
boards.SMDKV310Config.install_samsung_boot_loader(
2057
"%s/%s/SPL" % ("chroot_dir", uboot_flavor),
2058
"%s/%s/uboot" % ("chroot_dir", uboot_flavor), "boot_disk")
2057
"%s/%s/SPL" % ("chroot_dir", bootloader_flavor),
2058
"%s/%s/uboot" % ("chroot_dir", bootloader_flavor), "boot_disk")
2060
2060
'%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
2061
'seek=%d' % (sudo_args, uboot_flavor,
2061
'seek=%d' % (sudo_args, bootloader_flavor,
2062
2062
boards.SMDKV310Config.SAMSUNG_V310_BL1_START),
2063
2063
'%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
2064
'seek=%d' % (sudo_args, uboot_flavor,
2064
'seek=%d' % (sudo_args, bootloader_flavor,
2065
2065
boards.SMDKV310Config.SAMSUNG_V310_BL2_START)]
2066
2066
self.assertEqual(expected, fixture.mock.commands_executed)
2068
2068
def test_install_origen_u_boot(self):
2069
2069
fixture = self._mock_Popen()
2070
uboot_flavor = boards.OrigenConfig.uboot_flavor
2070
bootloader_flavor = boards.OrigenConfig.bootloader_flavor
2071
2071
self.useFixture(MockSomethingFixture(
2072
2072
boards.OrigenConfig, '_get_samsung_spl',
2073
2073
classmethod(lambda cls, chroot_dir: "%s/%s/SPL" % (
2074
chroot_dir, uboot_flavor))))
2074
chroot_dir, bootloader_flavor))))
2075
2075
self.useFixture(MockSomethingFixture(
2076
boards.OrigenConfig, '_get_samsung_uboot',
2076
boards.OrigenConfig, '_get_samsung_bootloader',
2077
2077
classmethod(lambda cls, chroot_dir: "%s/%s/uboot" % (
2078
chroot_dir, uboot_flavor))))
2078
chroot_dir, bootloader_flavor))))
2079
2079
boards.OrigenConfig.hardwarepack_handler = (
2080
2080
TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
2081
2081
boards.OrigenConfig.hardwarepack_handler.get_format = (
2084
2084
lambda file: 1))
2085
2085
boards.OrigenConfig.install_samsung_boot_loader(
2086
2086
boards.OrigenConfig._get_samsung_spl("chroot_dir"),
2087
boards.OrigenConfig._get_samsung_uboot("chroot_dir"), "boot_disk")
2087
boards.OrigenConfig._get_samsung_bootloader("chroot_dir"),
2089
2090
'%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
2090
'seek=%d' % (sudo_args, uboot_flavor,
2091
'seek=%d' % (sudo_args, bootloader_flavor,
2091
2092
boards.OrigenConfig.SAMSUNG_V310_BL1_START),
2092
2093
'%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
2093
'seek=%d' % (sudo_args, uboot_flavor,
2094
'seek=%d' % (sudo_args, bootloader_flavor,
2094
2095
boards.OrigenConfig.SAMSUNG_V310_BL2_START)]
2095
2096
self.assertEqual(expected, fixture.mock.commands_executed)
2919
2920
self.expected_calls, self.popen_fixture.mock.commands_executed)
2920
2921
self.assertEquals(self.expected_args, self.saved_args)
2922
def test_populate_boot_uboot_flavor(self):
2923
def test_populate_boot_bootloader_flavor(self):
2923
2924
self.prepare_config(boards.BoardConfig)
2924
self.config.uboot_flavor = "uboot_flavor"
2925
self.config.bootloader_flavor = "bootloader_flavor"
2925
2926
self.call_populate_boot(self.config)
2926
2927
self.assertEquals(
2927
2928
self.expected_calls, self.popen_fixture.mock.commands_executed)
2930
2931
def test_populate_boot_bootloader_file_in_boot_part(self):
2931
2932
self.prepare_config(boards.BoardConfig)
2932
self.config.uboot_flavor = "uboot_flavor"
2933
self.config.bootloader_flavor = "bootloader_flavor"
2933
2934
self.config.bootloader_file_in_boot_part = True
2934
2935
self.call_populate_boot(self.config)
2935
2936
expected_calls = self.expected_calls[:]
2936
2937
expected_calls.insert(2,
2937
'%s cp -v chroot_dir/usr/lib/u-boot/uboot_flavor/u-boot.bin '
2938
'%s cp -v chroot_dir/usr/lib/u-boot/bootloader_flavor/u-boot.bin '
2938
2939
'boot_disk' % sudo_args)
2939
2940
self.assertEquals(
2940
2941
expected_calls, self.popen_fixture.mock.commands_executed)
2943
2944
def test_populate_boot_bootloader_file_in_boot_part_false(self):
2944
2945
self.prepare_config(boards.BoardConfig)
2945
self.config.uboot_flavor = "uboot_flavor"
2946
self.config.bootloader_flavor = "bootloader_flavor"
2946
2947
self.config.bootloader_file_in_boot_part = False
2947
2948
self.call_populate_boot(self.config)
2948
2949
expected_calls = self.expected_calls[:]
2950
2951
expected_calls, self.popen_fixture.mock.commands_executed)
2951
2952
self.assertEquals(self.expected_args, self.saved_args)
2953
def test_populate_boot_no_uboot_flavor(self):
2954
def test_populate_boot_no_bootloader_flavor(self):
2954
2955
self.prepare_config(boards.BoardConfig)
2955
2956
self.config.bootloader_file_in_boot_part = True
2956
2957
self.assertRaises(