tests: add initial test set

Add tests make target and a simple test that executes qdl in dry-run mode
for a synthetic reference FLAT build with VIP table generation.

The FLAT build contains:
- patch0.xml
- patch1.xml
- rawprogram0.xml
- rawprogram1.xml

All binaries that these XML files point to are filled with zeros, generated
during github action  execution.

Tests ensures that the table is generated correctly by comparing
calculated and expected SHA256 hashes of DigestToSign.bin file.

Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
This commit is contained in:
Igor Opaniuk authored and Konrad Dybcio committed 2025-06-20 11:51:49 +02:00
1 parent ad123a9531
commit 6c0fbcce08
9 files changed
+192

No files matched your search

+6
View File
@@ -27,6 +27,9 @@ jobs:
- name: Build
run: make
- name: Run tests
run: make tests
- name: Package
run: |
mkdir dist
@@ -62,6 +65,9 @@ jobs:
- name: Build
run: make
- name: Run tests
run: make tests
- name: Package
run: |
set -x
+4
View File
@@ -46,3 +46,7 @@ clean:
install: $(QDL) $(RAMDUMP) $(KS_OUT)
install -d $(DESTDIR)$(prefix)/bin
install -m 755 $^ $(DESTDIR)$(prefix)/bin
tests: default
tests:
@./tests/run_tests.sh
+21
View File
@@ -0,0 +1,21 @@
#!/bin/sh
# SPDX-License-Identifier: BSD-3-Clause
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
create_file_with_size() {
filename="$1"
size_kbytes="$2"
dd if=/dev/zero of="$SCRIPT_PATH/$filename" bs=1024 count="$size_kbytes" status=none
}
create_file_with_size prog_firehose_ddr.elf 20
create_file_with_size efi.bin 524288
create_file_with_size gpt_backup0.bin 20
create_file_with_size gpt_backup1.bin 20
create_file_with_size gpt_main0.bin 24
create_file_with_size gpt_main1.bin 24
create_file_with_size rootfs.img 512000
create_file_with_size xbl_config.elf 320
create_file_with_size xbl.elf 800
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" ?>
<patches>
<!--NOTE: This is an ** Autogenerated file **-->
<!--NOTE: Patching is in little endian format, i.e. 0xAABBCCDD will look like DD CC BB AA in the file or on disk-->
<!--NOTE: This file is used by Trace32 - So make sure to add decimals, i.e. 0x10-10=0, *but* 0x10-10.=6.-->
<patch start_sector="2" byte_offset="168" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="gpt_main0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update last partition 2 'rootfs' with actual size in Primary Header."/>
<patch start_sector="2" byte_offset="168" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update last partition 2 'rootfs' with actual size in Primary Header."/>
<patch start_sector="0" byte_offset="168" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="gpt_backup0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update last partition 2 'rootfs' with actual size in Backup Header."/>
<patch start_sector="NUM_DISK_SECTORS-5." byte_offset="168" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update last partition 2 'rootfs' with actual size in Backup Header."/>
<patch start_sector="1" byte_offset="48" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="gpt_main0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with LastUseableLBA."/>
<patch start_sector="1" byte_offset="48" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with LastUseableLBA."/>
<patch start_sector="4" byte_offset="48" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="gpt_backup0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with LastUseableLBA."/>
<patch start_sector="NUM_DISK_SECTORS-1." byte_offset="48" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with LastUseableLBA."/>
<patch start_sector="1" byte_offset="32" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-1." filename="gpt_main0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with BackupGPT Header Location."/>
<patch start_sector="1" byte_offset="32" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-1." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with BackupGPT Header Location."/>
<patch start_sector="4" byte_offset="24" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-1." filename="gpt_backup0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with CurrentLBA."/>
<patch start_sector="NUM_DISK_SECTORS-1." byte_offset="24" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-1." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with CurrentLBA."/>
<patch start_sector="4" byte_offset="72" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-5." filename="gpt_backup0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with Partition Array Location."/>
<patch start_sector="NUM_DISK_SECTORS-1" byte_offset="72" physical_partition_number="0" size_in_bytes="8" value="NUM_DISK_SECTORS-5." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with Partition Array Location."/>
<patch start_sector="1" byte_offset="88" physical_partition_number="0" size_in_bytes="4" value="CRC32(2,4096)" filename="gpt_main0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with CRC of Partition Array."/>
<patch start_sector="1" byte_offset="88" physical_partition_number="0" size_in_bytes="4" value="CRC32(2,4096)" filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with CRC of Partition Array."/>
<patch start_sector="4" byte_offset="88" physical_partition_number="0" size_in_bytes="4" value="CRC32(0,4096)" filename="gpt_backup0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with CRC of Partition Array."/>
<patch start_sector="NUM_DISK_SECTORS-1." byte_offset="88" physical_partition_number="0" size_in_bytes="4" value="CRC32(NUM_DISK_SECTORS-5.,4096)" filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with CRC of Partition Array."/>
<patch start_sector="1" byte_offset="16" physical_partition_number="0" size_in_bytes="4" value="0" filename="gpt_main0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Zero Out Header CRC in Primary Header."/>
<patch start_sector="1" byte_offset="16" physical_partition_number="0" size_in_bytes="4" value="CRC32(1,92)" filename="gpt_main0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with CRC of Primary Header."/>
<patch start_sector="1" byte_offset="16" physical_partition_number="0" size_in_bytes="4" value="0" filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Zero Out Header CRC in Primary Header."/>
<patch start_sector="1" byte_offset="16" physical_partition_number="0" size_in_bytes="4" value="CRC32(1,92)" filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with CRC of Primary Header."/>
<patch start_sector="4" byte_offset="16" physical_partition_number="0" size_in_bytes="4" value="0" filename="gpt_backup0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Zero Out Header CRC in Backup Header."/>
<patch start_sector="4" byte_offset="16" physical_partition_number="0" size_in_bytes="4" value="CRC32(4,92)" filename="gpt_backup0.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with CRC of Backup Header."/>
<patch start_sector="NUM_DISK_SECTORS-1." byte_offset="16" physical_partition_number="0" size_in_bytes="4" value="0" filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Zero Out Header CRC in Backup Header."/>
<patch start_sector="NUM_DISK_SECTORS-1." byte_offset="16" physical_partition_number="0" size_in_bytes="4" value="CRC32(NUM_DISK_SECTORS-1.,92)" filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with CRC of Backup Header."/>
</patches>
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" ?>
<patches>
<!--NOTE: This is an ** Autogenerated file **-->
<!--NOTE: Patching is in little endian format, i.e. 0xAABBCCDD will look like DD CC BB AA in the file or on disk-->
<!--NOTE: This file is used by Trace32 - So make sure to add decimals, i.e. 0x10-10=0, *but* 0x10-10.=6.-->
<patch start_sector="2" byte_offset="552" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="gpt_main1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update last partition 5 'last_parti' with actual size in Primary Header."/>
<patch start_sector="2" byte_offset="552" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update last partition 5 'last_parti' with actual size in Primary Header."/>
<patch start_sector="0" byte_offset="552" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="gpt_backup1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update last partition 5 'last_parti' with actual size in Backup Header."/>
<patch start_sector="NUM_DISK_SECTORS-5." byte_offset="552" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update last partition 5 'last_parti' with actual size in Backup Header."/>
<patch start_sector="1" byte_offset="48" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="gpt_main1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with LastUseableLBA."/>
<patch start_sector="1" byte_offset="48" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with LastUseableLBA."/>
<patch start_sector="4" byte_offset="48" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="gpt_backup1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with LastUseableLBA."/>
<patch start_sector="NUM_DISK_SECTORS-1." byte_offset="48" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-6." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with LastUseableLBA."/>
<patch start_sector="1" byte_offset="32" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-1." filename="gpt_main1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with BackupGPT Header Location."/>
<patch start_sector="1" byte_offset="32" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-1." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with BackupGPT Header Location."/>
<patch start_sector="4" byte_offset="24" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-1." filename="gpt_backup1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with CurrentLBA."/>
<patch start_sector="NUM_DISK_SECTORS-1." byte_offset="24" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-1." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with CurrentLBA."/>
<patch start_sector="4" byte_offset="72" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-5." filename="gpt_backup1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with Partition Array Location."/>
<patch start_sector="NUM_DISK_SECTORS-1" byte_offset="72" physical_partition_number="1" size_in_bytes="8" value="NUM_DISK_SECTORS-5." filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with Partition Array Location."/>
<patch start_sector="1" byte_offset="88" physical_partition_number="1" size_in_bytes="4" value="CRC32(2,4096)" filename="gpt_main1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with CRC of Partition Array."/>
<patch start_sector="1" byte_offset="88" physical_partition_number="1" size_in_bytes="4" value="CRC32(2,4096)" filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with CRC of Partition Array."/>
<patch start_sector="4" byte_offset="88" physical_partition_number="1" size_in_bytes="4" value="CRC32(0,4096)" filename="gpt_backup1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with CRC of Partition Array."/>
<patch start_sector="NUM_DISK_SECTORS-1." byte_offset="88" physical_partition_number="1" size_in_bytes="4" value="CRC32(NUM_DISK_SECTORS-5.,4096)" filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with CRC of Partition Array."/>
<patch start_sector="1" byte_offset="16" physical_partition_number="1" size_in_bytes="4" value="0" filename="gpt_main1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Zero Out Header CRC in Primary Header."/>
<patch start_sector="1" byte_offset="16" physical_partition_number="1" size_in_bytes="4" value="CRC32(1,92)" filename="gpt_main1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with CRC of Primary Header."/>
<patch start_sector="1" byte_offset="16" physical_partition_number="1" size_in_bytes="4" value="0" filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Zero Out Header CRC in Primary Header."/>
<patch start_sector="1" byte_offset="16" physical_partition_number="1" size_in_bytes="4" value="CRC32(1,92)" filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Primary Header with CRC of Primary Header."/>
<patch start_sector="4" byte_offset="16" physical_partition_number="1" size_in_bytes="4" value="0" filename="gpt_backup1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Zero Out Header CRC in Backup Header."/>
<patch start_sector="4" byte_offset="16" physical_partition_number="1" size_in_bytes="4" value="CRC32(4,92)" filename="gpt_backup1.bin" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with CRC of Backup Header."/>
<patch start_sector="NUM_DISK_SECTORS-1." byte_offset="16" physical_partition_number="1" size_in_bytes="4" value="0" filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Zero Out Header CRC in Backup Header."/>
<patch start_sector="NUM_DISK_SECTORS-1." byte_offset="16" physical_partition_number="1" size_in_bytes="4" value="CRC32(NUM_DISK_SECTORS-1.,92)" filename="DISK" SECTOR_SIZE_IN_BYTES="4096" what="Update Backup Header with CRC of Backup Header."/>
</patches>
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" ?>
<data>
<!--NOTE: This is an ** Autogenerated file **-->
<!--NOTE: Sector size is 4096bytes-->
<program start_sector="6" size_in_KB="524288.0" physical_partition_number="0" partofsingleimage="false" file_sector_offset="0" num_partition_sectors="131072" readbackverify="false" filename="efi.bin" sparse="false" start_byte_hex="0x6000" SECTOR_SIZE_IN_BYTES="4096" label="efi"/>
<program start_sector="131078" size_in_KB="0" physical_partition_number="0" partofsingleimage="false" file_sector_offset="0" num_partition_sectors="0" readbackverify="false" filename="rootfs.img" sparse="false" start_byte_hex="0x20006000" SECTOR_SIZE_IN_BYTES="4096" label="rootfs"/>
<program start_sector="0" size_in_KB="24.0" physical_partition_number="0" partofsingleimage="true" file_sector_offset="0" num_partition_sectors="6" readbackverify="false" filename="gpt_main0.bin" sparse="false" start_byte_hex="0x0" SECTOR_SIZE_IN_BYTES="4096" label="PrimaryGPT"/>
<program start_sector="NUM_DISK_SECTORS-5." size_in_KB="20.0" physical_partition_number="0" partofsingleimage="true" file_sector_offset="0" num_partition_sectors="5" readbackverify="false" filename="gpt_backup0.bin" sparse="false" start_byte_hex="(4096*NUM_DISK_SECTORS)-20480." SECTOR_SIZE_IN_BYTES="4096" label="BackupGPT"/>
</data>
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" ?>
<data>
<!--NOTE: This is an ** Autogenerated file **-->
<!--NOTE: Sector size is 4096bytes-->
<program start_sector="6" size_in_KB="3604.0" physical_partition_number="1" partofsingleimage="false" file_sector_offset="0" num_partition_sectors="901" readbackverify="false" filename="xbl.elf" sparse="false" start_byte_hex="0x6000" SECTOR_SIZE_IN_BYTES="4096" label="xbl_a"/>
<program start_sector="907" size_in_KB="512.0" physical_partition_number="1" partofsingleimage="false" file_sector_offset="0" num_partition_sectors="128" readbackverify="false" filename="xbl_config.elf" sparse="false" start_byte_hex="0x38b000" SECTOR_SIZE_IN_BYTES="4096" label="xbl_config_a"/>
<program start_sector="1035" size_in_KB="3604.0" physical_partition_number="1" partofsingleimage="false" file_sector_offset="0" num_partition_sectors="901" readbackverify="false" filename="" sparse="false" start_byte_hex="0x40b000" SECTOR_SIZE_IN_BYTES="4096" label="xbl_b"/>
<program start_sector="1936" size_in_KB="512.0" physical_partition_number="1" partofsingleimage="false" file_sector_offset="0" num_partition_sectors="128" readbackverify="false" filename="" sparse="false" start_byte_hex="0x790000" SECTOR_SIZE_IN_BYTES="4096" label="xbl_config_b"/>
<program start_sector="2064" size_in_KB="0" physical_partition_number="1" partofsingleimage="false" file_sector_offset="0" num_partition_sectors="0" readbackverify="false" filename="" sparse="false" start_byte_hex="0x810000" SECTOR_SIZE_IN_BYTES="4096" label="last_parti"/>
<program start_sector="0" size_in_KB="24.0" physical_partition_number="1" partofsingleimage="true" file_sector_offset="0" num_partition_sectors="6" readbackverify="false" filename="gpt_main1.bin" sparse="false" start_byte_hex="0x0" SECTOR_SIZE_IN_BYTES="4096" label="PrimaryGPT"/>
<program start_sector="NUM_DISK_SECTORS-5." size_in_KB="20.0" physical_partition_number="1" partofsingleimage="true" file_sector_offset="0" num_partition_sectors="5" readbackverify="false" filename="gpt_backup1.bin" sparse="false" start_byte_hex="(4096*NUM_DISK_SECTORS)-20480." SECTOR_SIZE_IN_BYTES="4096" label="BackupGPT"/>
</data>
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
set -e
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
FLAT_BUILD_PATH=$SCRIPT_PATH/data
echo "####### Generate a FLAT build"
$FLAT_BUILD_PATH/generate_flat_build.sh
echo "####### Run QDL tests"
cd $SCRIPT_PATH
for t in test_*.sh; do
echo "###### Run $t"
bash $t
if [ $? -eq 0 ]; then
echo "####### Test $t: OK"
else
echo "####### Test $t: FAIL"
failed=1
fi
done
echo "####### Housekeeping"
rm -f ${FLAT_BUILD_PATH}/*.bin ${FLAT_BUILD_PATH}/*.img
rm -f ${FLAT_BUILD_PATH}/*.elf
if [ "$failed" == "1" ]; then
echo "####### Some test failed"
exit 1
fi
echo "####### All tests passed"
+42
View File
@@ -0,0 +1,42 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
set -e
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
FLAT_BUILD=${SCRIPT_PATH}/data
REP_ROOT=${SCRIPT_PATH}/..
VIP_PATH=${FLAT_BUILD}/vip
EXPECTED_DIGEST="4e13981189ede380172369aa0a4847ca3c9a4e2795733bca90ec1b1e713972ea"
VIP_TABLE_FILE=${VIP_PATH}/DigestsToSign.bin
mkdir -p $VIP_PATH
cd $FLAT_BUILD
${REP_ROOT}/qdl --dry-run --create-digests=${VIP_PATH} \
prog_firehose_ddr.elf rawprogram*.xml patch*.xml
if command -v sha256sum >/dev/null 2>&1; then
shacmd="sha256sum"
elif command -v shasum >/dev/null 2>&1; then
shacmd="shasum -a 256"
else
echo "No SHA-256 checksum tool found (need 'sha256sum' or 'shasum')"
exit 1
fi
actual_digest=`${shacmd} "${VIP_TABLE_FILE}" | cut -d ' ' -f1`
if [ "$actual_digest" != "${EXPECTED_DIGEST}" ]; then
echo "Expected SHA256 digest of ${VIP_TABLE_FILE} file is ${EXPECTED_DIGEST}"
echo "Calculated SHA256 digest of ${VIP_TABLE_FILE} file is $actual_digest"
echo "VIP table folder contents:"
ls -la ${VIP_PATH}
exit 1
fi
echo "VIP tables are generated successfully and validated"
rm -r ${VIP_PATH}/*.bin
rmdir ${VIP_PATH}