From 241f3f224f99139cf4c1ca7ab36f3a3b30ed2f5c Mon Sep 17 00:00:00 2001 From: Ahmed Karic Date: Thu, 22 Aug 2024 17:26:47 +0200 Subject: [PATCH] board/common: introduce image test-mode To support testing, the test-config.cfg file has been introduced in Infix. Additionally, a "test mode" for the running image is required for this configuration to be applied. Basically the test-config will only be loaded when the device is in test mode, which is determined by the presence of the /mnt/aux/test-mode file. However, placing this file via the Qeneth system proved to be inconvenient in the test environment. Therefore, it the entire image is built in test mode, with the 'test-mode' file preloaded onto the disk image (specifically in the auxiliary partition). To support this, a new variable, (bool) DISK_IMAGE_TEST_MODE, has been introduced: enabled: the image will be built in the test mode; disabled: the image will be built in the standard mode. Part of issue #568 --- board/common/Config.in | 12 ++++++++++++ board/common/mkdisk.sh | 11 ++++++++++- board/common/post-image.sh | 7 ++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/board/common/Config.in b/board/common/Config.in index 70891198..57e65a12 100644 --- a/board/common/Config.in +++ b/board/common/Config.in @@ -107,6 +107,18 @@ config DISK_IMAGE_BOOT_OFFSET to make sure that the GPT still fits at the start of the image. +config DISK_IMAGE_TEST_MODE + bool "Enable Test Mode" + depends on DISK_IMAGE + default y + help + Enable the test mode option by default. This setting creates a test-mode flag + in the auxiliary partition of the disk image, initiating the system with the test-config + instead of regular startup-config. The primary purpose of running an image in this mode + is to ensure proper execution of all Infix tests. Additionally, it enables extra RPCs + related to system restart and configuration overrides, allowing tests to be run even on + systems where the factory configuration may potentially create L2 loops. + config DISK_IMAGE_RELEASE_URL string "Infix URL" depends on DISK_IMAGE diff --git a/board/common/mkdisk.sh b/board/common/mkdisk.sh index 79516aaf..973dd37a 100755 --- a/board/common/mkdisk.sh +++ b/board/common/mkdisk.sh @@ -128,7 +128,7 @@ diskimg=disk.img bootimg= bootpart= -while getopts "a:b:B:n:s:" opt; do +while getopts "a:b:B:n:s:t" opt; do case ${opt} in a) arch=$OPTARG @@ -145,6 +145,9 @@ while getopts "a:b:B:n:s:" opt; do s) total=$(size2int $OPTARG) ;; + t) + testmode=true + ;; esac done shift $((OPTIND - 1)) @@ -190,6 +193,12 @@ cp -f $BINARIES_DIR/rootfs.itbh $root/aux/primary.itbh cp -f $BINARIES_DIR/rootfs.itbh $root/aux/secondary.itbh cp -f $BINARIES_DIR/rauc.status $root/aux/rauc.status +if [ "$testmode" = true ]; then + touch "$root/aux/test-mode" +else + rm -f "$root/aux/test-mode" +fi + case "$arch" in aarch64) mkenvimage -s 0x4000 -o "$root/aux/uboot.env" \ diff --git a/board/common/post-image.sh b/board/common/post-image.sh index ccd8e70e..dd342d45 100755 --- a/board/common/post-image.sh +++ b/board/common/post-image.sh @@ -59,8 +59,13 @@ if [ "$DISK_IMAGE" = "y" ]; then tar -xa --strip-components=1 -C "$BINARIES_DIR" -f "$archive" fi + testmode_flag="" + if [ "$DISK_IMAGE_TEST_MODE" = "y" ]; then + testmode_flag="-t" + fi + $common/mkrauc-status.sh "$BINARIES_DIR/${NAME}.pkg" >"$BINARIES_DIR/rauc.status" - $common/mkdisk.sh -a $BR2_ARCH -n $diskimg -s $DISK_IMAGE_SIZE $bootcfg + $common/mkdisk.sh -a $BR2_ARCH -n $diskimg $testmode_flag -s $DISK_IMAGE_SIZE $bootcfg fi load_cfg SDCARD_AUX