Skip to content

Commit b76f242

Browse files
committed
tests: Adjust ordering for adsb_soc extraction
Testing IMaH extraction on that module requires un-partitioning the image, and doing that in proper order. This change alters order so that adsb_soc exists as separate IMaH file when time comes for its extraction.
1 parent b7ec43b commit b76f242

File tree

3 files changed

+61
-8
lines changed

3 files changed

+61
-8
lines changed

tests/test_bin_partimg_extract1.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ def test_bin_bootimg_imah_v2_extract(capsys, modl_inp_dir, test_nth):
233233
"{}/*/*_1301-extr1/bootarea.img".format(modl_inp_dir),
234234
"{}/*/*_1301-extr1/loader.img".format(modl_inp_dir),
235235
"{}/*/*_1502-extr1/bootarea.img".format(modl_inp_dir),
236-
"{}/*/*_1502-extr1/vendor-extr1/adsb/adsb_soc.img".format(modl_inp_dir),
237236
"{}/*/*_2607.bin".format(modl_inp_dir), # in ag500 and ag501, this module is a bootarea.img as well
238237
"{}/*/*_2801-extr1/bootarea.img".format(modl_inp_dir),
239238
) ]) if os.path.isfile(fn)]
@@ -248,3 +247,38 @@ def test_bin_bootimg_imah_v2_extract(capsys, modl_inp_dir, test_nth):
248247
case_bin_bootimg_extract(img_inp_fn)
249248
capstdout, _ = capsys.readouterr()
250249
pass
250+
251+
@pytest.mark.order(5) # must be run after test_bin_archives_imah_v2_nested_extract
252+
@pytest.mark.fw_imah_v2
253+
@pytest.mark.parametrize("modl_inp_dir,test_nth", [
254+
('out/pm320-matrice30',1,),
255+
('out/pm430-matrice300',1,),
256+
('out/wm170-fpv_racer',1,),
257+
('out/wm231-mavic_air_2',1,),
258+
('out/wm232-mavic_air_2s',1,),
259+
('out/wm260-mavic_pro_3',1,),
260+
('out/wm2605-mavic_3_classic',1,),
261+
('out/wm265e-mavic_pro_3_enterpr',1,),
262+
('out/wm265m-mavic_pro_3_mulspectr',1,),
263+
('out/wm265t-mavic_pro_3_thermal',1,),
264+
] )
265+
def test_bin_bootimg_imah_v2_nested_extract(capsys, modl_inp_dir, test_nth):
266+
""" Test if boot images are extracting correctly, and prepare data for tests which use the extracted files.
267+
"""
268+
if test_nth < 1:
269+
pytest.skip("limited scope")
270+
271+
img_inp_filenames = [fn for fn in itertools.chain.from_iterable([ glob.glob(e, recursive=True) for e in (
272+
# Some nested archives contain yet another set of boot images with IMaH encryption
273+
"{}/*/*_0801-extr1/vendor-extr1/adsb/adsb_soc.img".format(modl_inp_dir),
274+
"{}/*/*_0802-extr1/vendor-extr1/adsb/adsb_soc.img".format(modl_inp_dir),
275+
"{}/*/*_1502-extr1/vendor-extr1/adsb/adsb_soc.img".format(modl_inp_dir),
276+
) ]) if os.path.isfile(fn)]
277+
278+
if len(img_inp_filenames) < 1:
279+
pytest.skip("no package files to test in this directory")
280+
281+
for img_inp_fn in img_inp_filenames:
282+
case_bin_bootimg_extract(img_inp_fn)
283+
capstdout, _ = capsys.readouterr()
284+
pass

tests/test_dji_flyc_param_ed1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ def test_dji_flyc_param_ed_imah_v1_ckmod(capsys, modl_inp_dir, test_nth):
713713
pass
714714

715715

716-
@pytest.mark.order(6) # must be run after test_dji_mvfc_fwpak_imah_v2_rebin and test_dji_imah_fwsig_v2_nested_rebin
716+
@pytest.mark.order(7) # must be run after test_dji_mvfc_fwpak_imah_v2_rebin and test_dji_imah_fwsig_v2_nested_rebin
717717
@pytest.mark.fw_imah_v2
718718
@pytest.mark.parametrize("modl_inp_dir,test_nth", [
719719
('out/ag500-agras_t10',1,),

tests/test_dji_imah_fwsig_rebin1.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,11 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
288288
module_changes_limit = 2 + 256
289289
elif (m := re.match(r'^.*/(rc-n1-wm260)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
290290
platform = m.group(1)
291-
if False:
292-
pass # no quirks
291+
# specific nested modules
292+
if (re.match(r'^.*{:s}_1502_[^/]*[.]fw_1502.*adsb_soc.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
293+
module_cmdopts = "-k PRAK-2020-04 -k TBIE-9999-99 -f" # TBIE not published, forcing extract encrypted
294+
# allow change of 2 bytes from auth key name, 4+4 from enc+dec checksum, 256 from signature, up to 11x16 chunk padding, 32 payload digest
295+
module_changes_limit = 2 + 4 + 4 + 256 + 11*16 + 32
293296
else: # if first level module or nested within m1301
294297
module_cmdopts = "-k PRAK-2018-01 -k TBIE-2020-04"
295298
# allow change of 2 bytes from auth key name, 256 from signature, up to 16 chunk padding
@@ -356,6 +359,11 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
356359
module_cmdopts = "-k PRAK-2018-01 -k TBIE-2020-04"
357360
# allow change of 2 bytes from auth key name, 4+4 from enc+dec checksum, 256 from signature, up to 11x16 chunk padding, 32 payload digest
358361
module_changes_limit = 2 + 4 + 4 + 256 + 11*16 + 32
362+
# specific nested modules
363+
elif (re.match(r'^.*{:s}_0801_[^/]*[.]fw_0801.*adsb_soc.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
364+
module_cmdopts = "-k PRAK-2020-04 -k TBIE-9999-99 -f" # TBIE not published, forcing extract encrypted
365+
# allow change of 2 bytes from auth key name, 4+4 from enc+dec checksum, 256 from signature, up to 11x16 chunk padding, 32 payload digest
366+
module_changes_limit = 2 + 4 + 4 + 256 + 11*16 + 32
359367
# remaining nested modules
360368
elif (re.match(r'^.*{:s}_0701_[^/]*[.]fw_0701.*$'.format(platform), modl_inp_fn, re.IGNORECASE) or
361369
re.match(r'^.*{:s}_0801_[^/]*[.]fw_0801.*$'.format(platform), modl_inp_fn, re.IGNORECASE) or
@@ -369,8 +377,13 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
369377
module_changes_limit = 2 + 4 + 256
370378
elif (m := re.match(r'^.*/(wm170|wm232|gl170|pm430|ag500)([._].*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
371379
platform = m.group(1)
372-
# nested modules
373-
if (re.match(r'^.*{:s}_0701_[^/]*[.]fw_0701.*$'.format(platform), modl_inp_fn, re.IGNORECASE) or
380+
# specific nested modules
381+
if (re.match(r'^.*{:s}_0801_[^/]*[.]fw_0801.*adsb_soc.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
382+
module_cmdopts = "-k PRAK-2020-04 -k TBIE-9999-99 -f" # TBIE not published, forcing extract encrypted
383+
# allow change of 2 bytes from auth key name, 4+4 from enc+dec checksum, 256 from signature, up to 11x16 chunk padding, 32 payload digest
384+
module_changes_limit = 2 + 4 + 4 + 256 + 11*16 + 32
385+
# remaining nested modules
386+
elif (re.match(r'^.*{:s}_0701_[^/]*[.]fw_0701.*$'.format(platform), modl_inp_fn, re.IGNORECASE) or
374387
re.match(r'^.*{:s}_0801_[^/]*[.]fw_0801.*$'.format(platform), modl_inp_fn, re.IGNORECASE) or
375388
re.match(r'^.*{:s}_0802_[^/]*[.]fw_0802.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
376389
module_cmdopts = "-k PRAK-2020-01 -k TBIE-2020-02"
@@ -622,7 +635,12 @@ def get_params_for_dji_imah_fwsig(modl_inp_fn):
622635
elif (m := re.match(r'^.*/(wm260|wm2605)([.][a-z]*|[_][0-9]{4}.*)?[.](bin|cfg|enc|fw|img|sig|ta|txt)$', modl_inp_fn, re.IGNORECASE)):
623636
platform = m.group(1)
624637
# specific nested modules
625-
if (re.match(r'^.*{:s}_1502_[^/]*[.]fw_1502.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
638+
if (re.match(r'^.*{:s}_1502_[^/]*[.]fw_1502.*adsb_soc.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
639+
module_cmdopts = "-k PRAK-2020-04 -k TBIE-9999-99 -f" # TBIE not published, forcing extract encrypted
640+
# allow change of 2 bytes from auth key name, 4+4 from enc+dec checksum, 256 from signature, up to 11x16 chunk padding, 32 payload digest
641+
module_changes_limit = 2 + 4 + 4 + 256 + 11*16 + 32
642+
# specific nested modules
643+
elif (re.match(r'^.*{:s}_1502_[^/]*[.]fw_1502.*$'.format(platform), modl_inp_fn, re.IGNORECASE)):
626644
module_cmdopts = "-k PRAK-2020-01 -k TBIE-2020-02"
627645
# allow change of 2 bytes from auth key name, 4+4 from enc+dec checksum, 256 from signature, up to 9x16 chunk padding, 32 payload digest, 6x16 unknown additional
628646
module_changes_limit = 2 + 4 + 4 + 256 + 9*16 + 32 + 6*16
@@ -937,7 +955,7 @@ def test_dji_imah_fwsig_v2_rebin(capsys, cmdargs, pkg_inp_dir, test_nth):
937955
pass
938956

939957

940-
@pytest.mark.order(5) # must be run after test_bin_archives_imah_v2_extract, test_bin_bootimg_imah_v2_extract, test_bin_archives_imah_v2_nested_extract
958+
@pytest.mark.order(6) # must be run after test_bin_archives_imah_v2_extract, test_bin_bootimg_imah_v2_extract, test_bin_archives_imah_v2_nested_extract, test_bin_bootimg_imah_v2_nested_extract
941959
@pytest.mark.fw_imah_v2
942960
@pytest.mark.parametrize("modl_inp_dir,test_nth", [
943961
('out/ac103-osmo_action_2',1,),
@@ -1006,6 +1024,7 @@ def test_dji_imah_fwsig_v2_nested_rebin(capsys, cmdargs, modl_inp_dir, test_nth)
10061024
"{}/*/*-loader_p*.img.sig".format(modl_inp_dir),
10071025
"{}/*/*-unpack_p*.img.sig".format(modl_inp_dir),
10081026
"{}/*/*-part_p*.img.sig".format(modl_inp_dir),
1027+
# output from test_bin_bootimg_imah_v2_nested_extract
10091028
"{}/*/*-adsb_soc_p*.img.sig".format(modl_inp_dir),
10101029
# output from test_bin_archives_imah_v2_nested_extract
10111030
"{}/*/*-extr1/vendor-extr1/ta/*-*-*0.ta".format(modl_inp_dir),

0 commit comments

Comments
 (0)