diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02e9e5a..b51e88e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,9 +14,11 @@ jobs: with: fetch-depth: 0 - - name: Run make + - name: Build all platforms and run tests run: | - make + sudo apt install pycodestyle + make lint + make all integration - name: Run cargo run: | diff --git a/Makefile b/Makefile index 647c6e2..bfd072f 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ PLATFORMS := $(foreach platform,$(wildcard platforms/*),$(platform)/gpt) BINS := gen_partition.py msp.py ptool.py PREFIX ?= /usr/local -.PHONY: all +.PHONY: all check lint integration all: $(PLATFORMS) @@ -13,10 +13,16 @@ all: $(PLATFORMS) %/partitions.xml: %/partitions.conf $(TOPDIR)/gen_partition.py -i $^ -o $@ -check: +lint: # W605: invalid escape sequence pycodestyle --select=W605 *.py +integration: all + # make sure generated output has created expected files + tests/integration/check-missing-files platforms/*/*.xml + +check: lint integration + install: $(BINS) install -d $(DESTDIR)$(PREFIX)/bin install -m 755 $^ $(DESTDIR)$(PREFIX)/bin diff --git a/ptool.py b/ptool.py index f20d375..5a8ff29 100755 --- a/ptool.py +++ b/ptool.py @@ -396,6 +396,7 @@ def CreateErasingRawProgramFiles(): temp.append(Comment('NOTE: This is an ** Autogenerated file **')) temp.append(Comment('NOTE: Sector size is %ibytes'%SECTOR_SIZE_IN_BYTES)) + CreateFileOfZeros("zeros_33sectors.bin",33) UpdateRawProgram(temp,0, 0.5, i, 0, 1, "zeros_33sectors.bin", "false", "Overwrite MBR sector") UpdateRawProgram(temp,1, BackupGPTNumLBAs*SECTOR_SIZE_IN_BYTES/1024.0, i, 0, BackupGPTNumLBAs, "zeros_%dsectors.bin" % BackupGPTNumLBAs, "false", "Overwrite Primary GPT Sectors") @@ -795,7 +796,7 @@ def CreateGPTPartitionTable(PhysicalPartitionNumber,UserProvided=False): PhysicalPartitionNumber, FileOffset[z], LastLBA-FirstLBA+1-FilePartitionOffset[z], # num_partition_sectors - "zeros_33sectorS.bin", + "zeros_33sectors.bin", "false", PartitionLabel, PhyPartition[k][j]['readbackverify'], diff --git a/tests/integration/check-missing-files b/tests/integration/check-missing-files new file mode 100755 index 0000000..f6a7307 --- /dev/null +++ b/tests/integration/check-missing-files @@ -0,0 +1,77 @@ +#!/bin/sh +# Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +# Takes XML files as arguments, collects the filenames referenced, and checks +# if any gpt_* or zeros_* file is missing + +set -eu + +errors=no + +for xml in "$@"; do + dir="$(dirname "${xml}")" + for file in $(sed -En 's/.*filename="([^"]+)".*/\1/p' "${xml}" | sort -u); do + case "${file}" in + # expected files that should be generated by ptool + gpt_*|zeros_*) + if ! [ -r "${dir}/${file}" ]; then + errors=yes + echo "Missing ${file} referenced in ${xml}" >&2 + fi + ;; + # known files that will be provided by the OS + abl.elf) ;; + aop.mbn) ;; + boot.img) ;; + cmnlib.mbn) ;; + cmnlib64.mbn) ;; + cpucp.elf) ;; + devcfg_iot.mbn) ;; + devcfg.mbn) ;; + efi.bin) ;; + DISK) ;; + dtb.bin) ;; + emmc_appsboot.mbn) ;; + featenabler.mbn) ;; + fs_image_linux.tar.gz.mbn.img) ;; + hyp.mbn) ;; + hypvm.mbn) ;; + imagefv.elf) ;; + keymaster.mbn) ;; + keymaster64.mbn) ;; + km4.mbn) ;; + multi_image_qti.mbn) ;; + multi_image.mbn) ;; + pmic.elf) ;; + qupv3fw.elf) ;; + rootfs.img) ;; + rpm.mbn) ;; + sbc_1.0_8016.bin) ;; + sbc_1.0_8096.bin) ;; + sbl1.mbn) ;; + sec.dat) ;; + sed.dat) ;; + shrm.elf) ;; + storsec.mbn) ;; + tools.fv) ;; + tz.mbn) ;; + uefi_sec.mbn) ;; + uefi.elf) ;; + xbl_config.elf) ;; + xbl_feature_config.elf) ;; + xbl.elf) ;; + XblRamdump.elf) ;; + *) + echo "Unknown ${file} referenced in ${xml}" >&2 + errors=1 + ;; + esac + done +done + +if [ "${errors}" != no ]; then + exit 1 +fi +exit 0 +