Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jörg Stucke <joerg.stucke@fkie.fraunhofer.de>
  • Loading branch information
andrewjlamarche and jstucke authored Oct 29, 2024
1 parent 03ce96f commit c5c6735
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ def unpack_function(file_path, tmp_dir):
except IOError as io_error:
return {'output': 'failed to read file: {}'.format(str(io_error))}

except struct.error as struct_error:
return {'output': 'failed to recognized firmware container: {}'.format(str(struct_error))}

return {
'output': 'successfully unpacked Broadcom SAO image'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

from test.unit.unpacker.test_unpacker import TestUnpackerBase

TEST_DATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')
TEST_DATA_DIR = Path(__file__).parent / 'data'

class TestBroadcomSAOUnpacker(TestUnpackerBase):

def test_unpacker_selection_generic(self):
self.check_unpacker_selection('firmware/broadcom-sao', 'Broadcom SAO')

def test_extraction(self):
test_file_path = os.path.join(TEST_DATA_DIR, 'broadcom-sao.bin')
extracted_files, meta_data = self.unpacker.extract_files_from_file(test_file_path, self.tmp_dir.name)
test_file_path = Path(TEST_DATA_DIR) / 'broadcom-sao.bin'
extracted_files, meta_data = self.unpacker.extract_files_from_file(str(test_file_path), self.tmp_dir.name)

assert meta_data['plugin_used'] == 'Broadcom SAO', 'wrong plugin applied'

assert len(extracted_files) == 4, 'not all files extracted'
assert all(element in ['META', 'DTBB', 'KRNL', 'RTFS'] for element in extracted_files), 'not all files extracted'
assert all(
Path(element).name in ['META', 'DTBB', 'KRNL', 'RTFS'] for element in extracted_files
), 'not all files extracted'

0 comments on commit c5c6735

Please sign in to comment.