From 8b0bba22d37169ed1463b9f650385ba33145bdf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Sun, 13 Apr 2025 12:29:31 +0200 Subject: [PATCH 1/6] Makefile: check target is .PHONY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Loïc Minier --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 647c6e2..55b551c 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 all: $(PLATFORMS) From 3f37704269f24add5f570cca8d0981c826a452b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Sun, 13 Apr 2025 13:59:17 +0200 Subject: [PATCH 2/6] Add integration test to catch missing files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move static analysis test to a new lint target. Signed-off-by: Loïc Minier --- Makefile | 10 +++- tests/integration/check-missing-files | 77 +++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 2 deletions(-) create mode 100755 tests/integration/check-missing-files diff --git a/Makefile b/Makefile index 55b551c..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 check +.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/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 + From 1a8086094221127176256cdf9a06d9b41a0ce218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Sun, 13 Apr 2025 14:00:28 +0200 Subject: [PATCH 3/6] ptool: Generate missing 33 sectors empty file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Loïc Minier --- ptool.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ptool.py b/ptool.py index f20d375..d0cb836 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") From 34c86fd5cf6c0d7881a4763bb1fb2ef7d67f133b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Tue, 15 Apr 2025 10:02:06 +0200 Subject: [PATCH 4/6] worklows: run integration tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Loïc Minier --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02e9e5a..10f2533 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,9 +14,9 @@ jobs: with: fetch-depth: 0 - - name: Run make + - name: Build all platforms and run integration tests run: | - make + make all integration - name: Run cargo run: | From 67287fe7d9d81d513e486739130c172ad269aea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Tue, 15 Apr 2025 10:30:53 +0200 Subject: [PATCH 5/6] ptool: Fix capital S in zeros_33sectorS.bin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Loïc Minier --- ptool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ptool.py b/ptool.py index d0cb836..5a8ff29 100755 --- a/ptool.py +++ b/ptool.py @@ -796,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'], From d89c06518be435e07fb3f50a38f4e63744b234d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Tue, 15 Apr 2025 10:35:37 +0200 Subject: [PATCH 6/6] workflows: Run lint checks as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Install pycodestyle dependency and for running lint checks first. Signed-off-by: Loïc Minier --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10f2533..b51e88e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,8 +14,10 @@ jobs: with: fetch-depth: 0 - - name: Build all platforms and run integration tests + - name: Build all platforms and run tests run: | + sudo apt install pycodestyle + make lint make all integration - name: Run cargo