[U-Boot] [PATCH 4/4] sandbox: dumpimage: Test dumpimage

From: Guilherme Maciel Ferreira guilherme.maciel.ferreira@gmail.com
Signed-off-by: Guilherme Maciel Ferreira guilherme.maciel.ferreira@gmail.com --- test/image/test-imagetools.sh | 107 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 107 insertions(+), 0 deletions(-) create mode 100755 test/image/test-imagetools.sh
diff --git a/test/image/test-imagetools.sh b/test/image/test-imagetools.sh new file mode 100755 index 0000000..b243794 --- /dev/null +++ b/test/image/test-imagetools.sh @@ -0,0 +1,107 @@ +#!/bin/bash +# +# Written by Guilherme Maciel Ferreira guilherme.maciel.ferreira@gmail.com +# +# Sanity check for mkimage and dumpimage tools +# +# SPDX-License-Identifier: GPL-2.0+ +# +# To run this: +# +# make O=sandbox sandbox_config +# make O=sandbox +# ./test/image/test-imagetools.sh + + +BASEDIR=sandbox + +LINUX_VERSION=`uname -r` +IMAGE=linux-${LINUX_VERSION}.img +DATAFILE0=vmlinuz-${LINUX_VERSION} +DATAFILE1=initrd.img-${LINUX_VERSION} +DATAFILE2=System.map-${LINUX_VERSION} + +MKIMAGE=${BASEDIR}/tools/mkimage +DUMPIMAGE=${BASEDIR}/tools/dumpimage +MKIMAGE_LIST=mkimage.list +DUMPIMAGE_LIST=dumpimage.list + +cleanup() +{ + rm -f ${DATAFILE0} + rm -f ${DATAFILE1} + rm -f ${DATAFILE2} + rm -f ${IMAGE} + rm -f ${DUMPIMAGE_LIST} + rm -f ${MKIMAGE_LIST} +} + +assert_equal() +{ + FILE_1=$1 + FILE_2=$2 + diff ${FILE_1} ${FILE_2} + ret=$? + if [ $ret -ne 0 ]; then + echo "Failed." + cleanup + exit $ret + fi +} + +compress_image() +{ + BOOTDIR=$1 + DATAFILES=${BOOTDIR}/${DATAFILE0}:${BOOTDIR}/${DATAFILE1}:${BOOTDIR}/${DATAFILE2} + + echo -e "\nBuilding image..." + echo "# ${MKIMAGE} -A x86 -O linux -T multi -n "${LINUX_VERSION}" -d ${DATAFILES} ${IMAGE}" + ./${MKIMAGE} -A x86 -O linux -T multi -n "${LINUX_VERSION}" -d ${DATAFILES} ${IMAGE} + echo -e "done.\n" +} + +extract_image() +{ + echo -e "\nExtracting image contents..." + echo "# ${DUMPIMAGE} -i ${IMAGE} -p 0 ${DATAFILE0}" + ./${DUMPIMAGE} -i ${IMAGE} -p 0 ${DATAFILE0} + echo "# ${DUMPIMAGE} -i ${IMAGE} -p 1 ${DATAFILE1}" + ./${DUMPIMAGE} -i ${IMAGE} -p 1 ${DATAFILE1} + echo "# ${DUMPIMAGE} -i ${IMAGE} -p 2 ${DATAFILE2}" + ./${DUMPIMAGE} -i ${IMAGE} -p 2 ${DATAFILE2} + echo -e "done.\n" +} + +list_image() +{ + echo -e "\nListing image contents..." + echo "# ${MKIMAGE} -l ${IMAGE}" + ./${MKIMAGE} -l ${IMAGE} > ${MKIMAGE_LIST} 2>&1 + echo "# ${DUMPIMAGE} -l ${IMAGE}" + ./${DUMPIMAGE} -l ${IMAGE} > ${DUMPIMAGE_LIST} 2>&1 + echo -e "done.\n" +} + +main() +{ + # Assume kernel images lie in /boot dir + BOOTDIR=/boot + + # Compress and extract multifile images, compare the result + compress_image ${BOOTDIR} + extract_image + assert_equal ${DATAFILE0} ${BOOTDIR}/${DATAFILE0} + assert_equal ${DATAFILE1} ${BOOTDIR}/${DATAFILE1} + assert_equal ${DATAFILE2} ${BOOTDIR}/${DATAFILE2} + + # List contents and compares output fro tools + list_image + assert_equal ${DUMPIMAGE_LIST} ${MKIMAGE_LIST} + + # Remove files created + cleanup + + echo "Success." +} + +main

Hi,
On Tue, Sep 17, 2013 at 6:42 PM, guilherme.maciel.ferreira@gmail.comwrote:
From: Guilherme Maciel Ferreira guilherme.maciel.ferreira@gmail.com
Please can you add a commit message describing this commit?
Signed-off-by: Guilherme Maciel Ferreira < guilherme.maciel.ferreira@gmail.com>
test/image/test-imagetools.sh | 107 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 107 insertions(+), 0 deletions(-) create mode 100755 test/image/test-imagetools.sh
diff --git a/test/image/test-imagetools.sh b/test/image/test-imagetools.sh new file mode 100755 index 0000000..b243794 --- /dev/null +++ b/test/image/test-imagetools.sh @@ -0,0 +1,107 @@ +#!/bin/bash +# +# Written by Guilherme Maciel Ferreira < guilherme.maciel.ferreira@gmail.com> +# +# Sanity check for mkimage and dumpimage tools +# +# SPDX-License-Identifier: GPL-2.0+ +# +# To run this: +# +# make O=sandbox sandbox_config +# make O=sandbox +# ./test/image/test-imagetools.sh
+BASEDIR=sandbox
+LINUX_VERSION=`uname -r` +IMAGE=linux-${LINUX_VERSION}.img +DATAFILE0=vmlinuz-${LINUX_VERSION} +DATAFILE1=initrd.img-${LINUX_VERSION} +DATAFILE2=System.map-${LINUX_VERSION}
It seems that this uses your native OS images. Is it intended to run on the target rather than the host?
If so, then I think you need sudo so that it can open the OS image for update, else I get:
test/image/test-imagetools.sh
Building image... # sandbox/tools/mkimage -A x86 -O linux -T multi -n "3.2.0-53-generic" -d /boot/vmlinuz-3.2.0-53-generic:/boot/initrd.img-3.2.0-53-generic:/boot/System.map-3.2.0-53-generic linux-3.2.0-53-generic.img ./sandbox/tools/mkimage: Can't open /boot/vmlinuz-3.2.0-53-generic: Permission denied done.
So maybe you should adjust mkimage to open the image read-only in the case where it will not need to update it?
Regards, Simon
participants (2)
-
guilherme.maciel.ferreiraï¼ gmail.com
-
Simon Glass