Skip to content

Commit

Permalink
Merge pull request #97 from CrossTheRoadElec/verify_improvements
Browse files Browse the repository at this point in the history
Improve robustness of verification script
  • Loading branch information
CoryNessCTR authored Feb 10, 2025
2 parents af305bb + 72ba034 commit 548460c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion verify_firmware.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import json
import os
import re

with open('firmware-index.json', 'r') as f:
firmware_files = json.load(f)

all_firmwares_in_index = [a for (_, major_vers) in firmware_files["Releases"].items() for (_, vers_cont) in major_vers.items() for dev_entry in vers_cont for a in dev_entry['AvailRelease']]
all_firmwares_in_index = [a for (_, major_vers) in firmware_files["Releases"].items()
for (_, vers_cont) in major_vers.items()
for dev_entry in vers_cont
for a in dev_entry['AvailRelease']]
all_firmwares_in_directory = os.listdir('ctr-device-firmware')

items_missing_from_directory = list(set(all_firmwares_in_index).difference(all_firmwares_in_directory))
Expand All @@ -15,3 +19,21 @@
# items_missing_from_index = list(set(all_firmwares_in_directory).difference(all_firmwares_in_index))
# if len(items_missing_from_index) != 0:
# raise Exception(f'The following firmwares are not present in the index: {items_missing_from_index}')


dev_entry = [a for (_, major_vers) in firmware_files["Releases"].items()
for (_, vers_cont) in major_vers.items()
for a in vers_cont]

version_regex = r'([0-9]+)\.([0-9]+)(\.([0-9]+)\.([0-9]+))?'

for d in dev_entry:
if d["LatestRelease"] != d["AvailRelease"][0]:
raise Exception(f"Device {d['Device']} does not have latest release matching first avail release")


latest_vers_num_regex = re.search(version_regex, d["LatestRelease"])
latest_vers = latest_vers_num_regex.group(0)

if latest_vers != d["LatestVersion"]:
raise Exception(f"Device {d['Device']} does not match latest version")

0 comments on commit 548460c

Please sign in to comment.