def test_invalid_fip_h(self): """Check failure to parse firmware_image_package.h""" self.setup_readme() self.setup_macro('blah') with self.assertRaises(Exception) as err: fip_util.main(self.args, self.src_file) self.assertIn('Cannot parse file', str(err.exception))
def test_invalid_tbbr_c(self): """Check failure to parse tbbr_config.c""" self.setup_readme() self.setup_macro() # Check invalid format for C file self.setup_name('blah') with self.assertRaises(Exception) as err: fip_util.main(self.args, self.src_file) self.assertIn('Cannot parse file', str(err.exception))
def test_missing_tbbr_c(self): """Check handlinh of missing tbbr_config.c""" self.setup_readme() self.setup_macro() # Still need the .c file with self.assertRaises(Exception) as err: fip_util.main(self.args, self.src_file) self.assertIn('tbbr_config.c', str(err.exception))
def test_no_debug(self): """Test running without the -D flag""" self.setup_readme() self.setup_macro() self.setup_name() args = self.args.copy() args.remove('-D') tools.WriteFile(self.src_file, '', binary=False) with test_util.capture_sys_output(): fip_util.main(args, self.src_file)
def test_inconsistent_tbbr_c(self): """Check tbbr_config.c in a format we don't expect""" self.setup_readme() # This is missing a hex value self.setup_macro(''' /* ToC Entry UUIDs */ #define UUID_TRUSTED_UPDATE_FIRMWARE_SCP_BL2U \\ {{0x65, 0x92, 0x27,}, {0x2f, 0x74}, {0xe6, 0x44}, 0x8d, 0xff, {0x57, 0x9a, 0xc1, 0xff, 0x06, 0x10} } #define UUID_TRUSTED_UPDATE_FIRMWARE_BL2U \\ {{0x60, 0xb3, 0xeb, 0x37}, {0xc1, 0xe5}, {0xea, 0x41}, 0x9d, 0xf3, {0x19, 0xed, 0xa1, 0x1f, 0x68, 0x01} } ''') # Check invalid format for C file self.setup_name('blah') with self.assertRaises(Exception) as err: fip_util.main(self.args, self.src_file) self.assertIn('Cannot parse UUID line 5', str(err.exception))
def test_changes(self): """Check handling of a source file that does/doesn't need changes""" self.setup_readme() self.setup_macro() self.setup_name() # Check generating the file when changes are needed tools.WriteFile(self.src_file, ''' # This is taken from tbbr_config.c in ARM Trusted Firmware FIP_TYPE_LIST = [ # ToC Entry UUIDs FipType('scp-fwu-cfg', 'SCP Firmware Updater Configuration FWU SCP_BL2U', [0x65, 0x92, 0x27, 0x03, 0x2f, 0x74, 0xe6, 0x44, 0x8d, 0xff, 0x57, 0x9a, 0xc1, 0xff, 0x06, 0x10]), ] # end blah de blah ''', binary=False) with test_util.capture_sys_output() as (stdout, _): fip_util.main(self.args, self.src_file) self.assertIn('Needs update', stdout.getvalue()) # Check generating the file when no changes are needed tools.WriteFile(self.src_file, ''' # This is taken from tbbr_config.c in ARM Trusted Firmware FIP_TYPE_LIST = [ # ToC Entry UUIDs FipType('scp-fwu-cfg', 'SCP Firmware Updater Configuration FWU SCP_BL2U', [0x65, 0x92, 0x27, 0x03, 0x2f, 0x74, 0xe6, 0x44, 0x8d, 0xff, 0x57, 0x9a, 0xc1, 0xff, 0x06, 0x10]), FipType('ap-fwu-cfg', 'AP Firmware Updater Configuration BL2U', [0x60, 0xb3, 0xeb, 0x37, 0xc1, 0xe5, 0xea, 0x41, 0x9d, 0xf3, 0x19, 0xed, 0xa1, 0x1f, 0x68, 0x01]), ] # end blah blah''', binary=False) with test_util.capture_sys_output() as (stdout, _): fip_util.main(self.args, self.src_file) self.assertIn('is up-to-date', stdout.getvalue())
def test_no_fip_h(self): """Check handling of missing firmware_image_package.h""" self.setup_readme() with self.assertRaises(Exception) as err: fip_util.main(self.args, self.src_file) self.assertIn('No such file or directory', str(err.exception))
def test_invalid_readme(self): """Test that an invalid readme.rst is detected""" tools.WriteFile(self.readme, 'blah', binary=False) with self.assertRaises(Exception) as err: fip_util.main(self.args, self.src_file) self.assertIn('does not start with', str(err.exception))
def test_no_readme(self): """Test handling of a missing readme.rst""" with self.assertRaises(Exception) as err: fip_util.main(self.args, self.src_file) self.assertIn('Expected file', str(err.exception))