diff --git a/test/bootconf-2019-05-10.txt b/test/bootconf-2019-05-10.txt new file mode 100644 index 0000000..2f9f956 --- /dev/null +++ b/test/bootconf-2019-05-10.txt @@ -0,0 +1,2 @@ +BOOT_UART=0 +WAKE_ON_GPIO=0 diff --git a/test/bootconf-2019-07-15-freeze.txt b/test/bootconf-2019-07-15-freeze.txt new file mode 100644 index 0000000..db43a54 --- /dev/null +++ b/test/bootconf-2019-07-15-freeze.txt @@ -0,0 +1,16 @@ +BOOT_UART=0 +WAKE_ON_GPIO=1 +POWER_OFF_ON_HALT=0 +FREEZE_VERSION=1 + + + + + + + + + + + + diff --git a/test/bootconf-2019-07-15.txt b/test/bootconf-2019-07-15.txt new file mode 100644 index 0000000..8cf72d5 --- /dev/null +++ b/test/bootconf-2019-07-15.txt @@ -0,0 +1,16 @@ +BOOT_UART=0 +WAKE_ON_GPIO=1 +POWER_OFF_ON_HALT=0 + + + + + + + + + + + + + diff --git a/test/pieeprom-2019-07-15-freeze.bin b/test/pieeprom-2019-07-15-freeze.bin new file mode 100644 index 0000000..cc791ee Binary files /dev/null and b/test/pieeprom-2019-07-15-freeze.bin differ diff --git a/test/test-rpi-eeprom-config b/test/test-rpi-eeprom-config new file mode 100755 index 0000000..309b991 --- /dev/null +++ b/test/test-rpi-eeprom-config @@ -0,0 +1,75 @@ +#!/bin/sh + +set -e + +script_dir="$(cd "$(dirname "$0")" && pwd)" +die() { + echo "$@" >&2 + exit 1 +} + +TMP_CONFIG="" +TMP_EEPROM="" +cleanup() { + rm -f "${TMP_CONFIG}" -f "${TMP_EEPROM}" + TMP_CONFIG="" + TMP_EEPROM="" +} +trap cleanup EXIT + +check_loopback() +{ + echo "check_update $1 $2" + + image="${script_dir}/$1" + conf="${script_dir}/$2" + + # Check that the production config file can be read correctly + expected_md5="$(md5sum "${conf}" | awk '{print $1}')" + actual_md5="$("${script_dir}/../rpi-eeprom-config" "${image}" | md5sum | awk '{print $1}')" + [ "${actual_md5}" = "${expected_md5}" ] || die "Config-read: checksum mismatch" + + # Check that overwriting the config section produces an identical binary + TMP_EEPROM=$(mktemp) + "${script_dir}/../rpi-eeprom-config" \ + "${image}" \ + --config "${conf}" \ + --out "${TMP_EEPROM}" + + expected_md5="$(md5sum "${image}" | awk '{print $1}')" + actual_md5="$(md5sum "${TMP_EEPROM}" | awk '{print $1}')" + [ "${actual_md5}" = "${expected_md5}" ] || die "EEPROM loopback: checksum mismatch" +} + +# Update the EEPROM with a new config and check the expected image is produced +check_update() +{ + echo "check_update $1 $2 $3" + + image="${script_dir}/$1" + ref_image="${script_dir}/$2" + conf="${script_dir}/$3" + + expected_md5="$(md5sum "${ref_image}" | awk '{print $1}')" + + TMP_EEPROM="$(mktemp)" + "${script_dir}/../rpi-eeprom-config" \ + "${image}" \ + --config "${conf}" \ + --out "${TMP_EEPROM}" + + actual_md5="$(md5sum "${TMP_EEPROM}" | awk '{print $1}')" + if [ "${actual_md5}" != "${expected_md5}" ]; then + hexdump -C "${TMP_EEPROM}" > "tmp.hex" + die "EEPROM update: checksum mismatch" + fi +} + +check_loopback "../firmware/critical/pieeprom-2019-05-10.bin" "bootconf-2019-05-10.txt" +cleanup + +check_loopback "../firmware/critical/pieeprom-2019-07-15.bin" "bootconf-2019-07-15.txt" +cleanup + +check_update "../firmware/critical/pieeprom-2019-07-15.bin" "pieeprom-2019-07-15-freeze.bin" "bootconf-2019-07-15-freeze.txt" +cleanup