def test_device_parameters(self):
     """
     Test that the correct parameters have been set for the device
     """
     cubie = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/cubie1.yaml'))
     self.assertIsNotNone(cubie['parameters']['media'].get('usb', None))
     self.assertIsNotNone(cubie.get('commands', None))
     self.assertIsNotNone(cubie.get('actions', None))
     self.assertIsNotNone(cubie['actions'].get('deploy', None))
     self.assertIsNotNone(cubie['actions']['deploy'].get('methods', None))
     self.assertIn('usb', cubie['actions']['deploy']['methods'])
     self.assertIsNotNone(cubie['actions'].get('boot', None))
     self.assertIsNotNone(cubie['actions']['boot'].get('methods', None))
     self.assertIn('u-boot', cubie['actions']['boot']['methods'])
     u_boot_params = cubie['actions']['boot']['methods']['u-boot']
     self.assertIn('usb', u_boot_params)
     self.assertIn('commands', u_boot_params['usb'])
     self.assertIn('parameters', u_boot_params)
     self.assertIn('boot_message', u_boot_params['parameters'])
     self.assertIn('bootloader_prompt', u_boot_params['parameters'])
 def test_device_parameters(self):
     """
     Test that the correct parameters have been set for the device
     """
     cubie = NewDevice(os.path.join(os.path.dirname(__file__), "../devices/cubie1.yaml"))
     self.assertIsNotNone(cubie["parameters"]["media"].get("usb", None))
     self.assertIsNotNone(cubie.get("commands", None))
     self.assertIsNotNone(cubie.get("actions", None))
     self.assertIsNotNone(cubie["actions"].get("deploy", None))
     self.assertIsNotNone(cubie["actions"]["deploy"].get("methods", None))
     self.assertIn("usb", cubie["actions"]["deploy"]["methods"])
     self.assertIsNotNone(cubie["actions"].get("boot", None))
     self.assertIsNotNone(cubie["actions"]["boot"].get("methods", None))
     self.assertIn("u-boot", cubie["actions"]["boot"]["methods"])
     u_boot_params = cubie["actions"]["boot"]["methods"]["u-boot"]
     self.assertIn("usb", u_boot_params)
     self.assertIn("commands", u_boot_params["usb"])
     self.assertIn("parameters", u_boot_params)
     self.assertIn("boot_message", u_boot_params["parameters"])
     self.assertIn("bootloader_prompt", u_boot_params["parameters"])
示例#3
0
 def test_device_parameters(self):
     """
     Test that the correct parameters have been set for the device
     """
     cubie = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/cubie1.yaml'))
     self.assertIsNotNone(cubie['parameters']['media'].get('usb', None))
     self.assertIsNotNone(cubie.get('commands', None))
     self.assertIsNotNone(cubie.get('actions', None))
     self.assertIsNotNone(cubie['actions'].get('deploy', None))
     self.assertIsNotNone(cubie['actions']['deploy'].get('methods', None))
     self.assertIn('usb', cubie['actions']['deploy']['methods'])
     self.assertIsNotNone(cubie['actions'].get('boot', None))
     self.assertIsNotNone(cubie['actions']['boot'].get('methods', None))
     self.assertIn('u-boot', cubie['actions']['boot']['methods'])
     u_boot_params = cubie['actions']['boot']['methods']['u-boot']
     self.assertIn('usb', u_boot_params)
     self.assertIn('commands', u_boot_params['usb'])
     self.assertIn('parameters', u_boot_params)
     self.assertIn('boot_message', u_boot_params['parameters'])
     self.assertIn('bootloader_prompt', u_boot_params['parameters'])
示例#4
0
    def test_substitutions(self):
        """
        Test substitution of secondary media values into u-boot commands

        Unlike most u-boot calls, removable knows in advance all the values it needs to substitute
        into the boot commands for the secondary deployment as these are fixed by the device config
        and the image details from the job submission.
        """
        job_parser = JobParser()
        cubie = NewDevice(
            os.path.join(os.path.dirname(__file__), '../devices/cubie1.yaml'))
        sample_job_file = os.path.join(
            os.path.dirname(__file__), 'sample_jobs/cubietruck-removable.yaml')
        with open(sample_job_file) as sample_job_data:
            job = job_parser.parse(sample_job_data,
                                   cubie,
                                   4212,
                                   None,
                                   "",
                                   output_dir='/tmp/')
        job.logger = DummyLogger()
        job.validate()
        boot_params = [
            methods for methods in job.parameters['actions']
            if 'boot' in methods.keys()
        ][1]['boot']
        self.assertIn('ramdisk', boot_params)
        self.assertIn('kernel', boot_params)
        self.assertIn('dtb', boot_params)
        self.assertIn('root_uuid', boot_params)
        self.assertIn('boot_part', boot_params)
        self.assertNotIn('type', boot_params)
        self.assertGreater(len(job.pipeline.actions), 1)
        self.assertIsNotNone(job.pipeline.actions[1].internal_pipeline)
        u_boot_action = [
            action for action in job.pipeline.actions
            if action.name == 'uboot-action'
        ][1]
        overlay = [
            action for action in u_boot_action.internal_pipeline.actions
            if action.name == 'bootloader-overlay'
        ][0]
        self.assertIsNotNone(
            overlay.get_namespace_data(action='storage-deploy',
                                       label='u-boot',
                                       key='device'))

        methods = cubie['actions']['boot']['methods']
        self.assertIn('u-boot', methods)
        self.assertIn('usb', methods['u-boot'])
        self.assertIn('commands', methods['u-boot']['usb'])
        commands_list = methods['u-boot']['usb']['commands']
        device_id = u_boot_action.get_namespace_data(action='storage-deploy',
                                                     label='u-boot',
                                                     key='device')
        self.assertIsNotNone(device_id)
        kernel_type = u_boot_action.parameters['kernel_type']
        bootcommand = map_kernel_uboot(kernel_type,
                                       device_params=cubie.get(
                                           'parameters', None))
        substitutions = {
            '{BOOTX}':
            "%s %s %s %s" % (
                bootcommand,
                cubie['parameters'][bootcommand]['kernel'],
                cubie['parameters'][bootcommand]['ramdisk'],
                cubie['parameters'][bootcommand]['dtb'],
            ),
            '{RAMDISK}':
            boot_params['ramdisk'],
            '{KERNEL}':
            boot_params['kernel'],
            '{DTB}':
            boot_params['dtb'],
            '{ROOT}':
            boot_params['root_uuid'],
            '{ROOT_PART}':
            "%s:%s" %
            (cubie['parameters']['media']['usb'][device_id]['device_id'],
             u_boot_action.parameters['boot_part'])
        }
        self.assertEqual('bootz 0x42000000 0x43300000 0x43000000',
                         substitutions['{BOOTX}'])
        self.assertEqual('/boot/initrd.img-3.16.0-4-armmp-lpae.u-boot',
                         substitutions['{RAMDISK}'])
        commands = substitute(commands_list, substitutions)
        self.assertEqual(commands, [
            'usb start', 'usb info', 'setenv autoload no',
            "setenv initrd_high '0xffffffff'", "setenv fdt_high '0xffffffff'",
            'setenv initrd_addr_r ${ramdisk_addr_r}',
            "setenv loadkernel 'load usb 0:1 ${kernel_addr_r} /boot/vmlinuz-3.16.0-4-armmp-lpae'",
            "setenv loadinitrd 'load usb 0:1 ${initrd_addr_r} /boot/initrd.img-3.16.0-4-armmp-lpae.u-boot; setenv initrd_size ${filesize}'",
            "setenv loadfdt 'load usb 0:1 ${fdt_addr_r} /boot/dtb-3.16.0-4-armmp-lpae'",
            "setenv bootargs 'console=ttyS0,115200n8 root=UUID=159d17cc-697c-4125-95a0-a3775e1deabe ip=dhcp'",
            "setenv bootcmd 'run loadkernel; run loadinitrd; run loadfdt; bootz 0x42000000 0x43300000 0x43000000'",
            'boot'
        ])