Files
OpenCellular/tests/futility/run_test_scripts.sh
Nicolas Boichat 7c5d3b2240 futility: rwsig: Add support for images with FMAP
If an FMAP is detected in the rwsig image file, use it
to determine the location of:
 - RW region
 - RW signature
 - public key in RO region

futility show uses that information to verify the signature,
and futility sign uses it is correctly resign the image,
and replace the public key a well.

This also adds tests for this use case. hammer_dev.bin sample
image uses huge RO public key and RW signature regions to make
sure all keys up to RSA-8192 can be used.

BRANCH=none
BUG=chrome-os-partner:62321
TEST=make -j
TEST=./build/futility/futility --debug show \
                    --pubkey hammer.vbpubk2 hammer.bin
TEST=./build/futility/futility --debug show hammer.bin
TEST=cp hammer.bin hammer.bin.orig
     ./build/futility/futility --debug sign \
       --prikey hammer.vbprik2 hammer.bin
     diff hammer.bin hammer.bin.orig => identical
TEST=openssl genrsa -3 -out hammer2.pem 2048
     futility create --desc="Hammer 2nd key" hammer2.pem \
       hammer2
     ./build/futility/futility --debug sign \
       --version 2 --prikey hammer2.vbprik2 hammer.bin
     These 2 commands succeed, but show different keys:
     ./build/futility/futility --debug show hammer.bin
     ./build/futility/futility --debug show hammer.bin.orig
TEST=make runtests

Change-Id: I2cebc421eaf97d1b92c9a58afc238d41487d0f6d
Reviewed-on: https://chromium-review.googlesource.com/445536
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-25 10:32:03 -08:00

103 lines
2.5 KiB
Bash
Executable File

#!/bin/bash -eu
# Copyright 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Load common constants and variables.
SCRIPTDIR=$(dirname $(readlink -f "$0"))
. "$SCRIPTDIR/common.sh"
# Mandatory arg is the directory where futility is installed.
[ -z "${1:-}" ] && error "Directory argument is required"
BINDIR="$1"
shift
FUTILITY="$BINDIR/futility"
# The Makefile should export the $BUILD directory, but if it's not just warn
# and guess (mostly so we can run the script manually).
if [ -z "${BUILD:-}" ]; then
BUILD=$(dirname "${BINDIR}")
yellow "Assuming BUILD=$BUILD"
fi
# Same for $SRCDIR
if [ -z "${SRCDIR:-}" ]; then
SRCDIR=$(readlink -f "${SCRIPTDIR}/../..")
yellow "Assuming SRCDIR=$SRCDIR"
fi
OUTDIR="${BUILD}/tests/futility_test_results"
[ -d "$OUTDIR" ] || mkdir -p "$OUTDIR"
# Let each test know where to find things...
export BUILD
export SRCDIR
export FUTILITY
export SCRIPTDIR
export BINDIR
export OUTDIR
# These are the scripts to run. Binaries are invoked directly by the Makefile.
TESTS="
${SCRIPTDIR}/test_bdb.sh
${SCRIPTDIR}/test_create.sh
${SCRIPTDIR}/test_dump_fmap.sh
${SCRIPTDIR}/test_gbb_utility.sh
${SCRIPTDIR}/test_load_fmap.sh
${SCRIPTDIR}/test_main.sh
${SCRIPTDIR}/test_rwsig.sh
${SCRIPTDIR}/test_show_contents.sh
${SCRIPTDIR}/test_show_kernel.sh
${SCRIPTDIR}/test_show_vs_verify.sh
${SCRIPTDIR}/test_show_usbpd1.sh
${SCRIPTDIR}/test_sign_firmware.sh
${SCRIPTDIR}/test_sign_fw_main.sh
${SCRIPTDIR}/test_sign_kernel.sh
${SCRIPTDIR}/test_sign_keyblocks.sh
${SCRIPTDIR}/test_sign_usbpd1.sh
${SCRIPTDIR}/test_file_types.sh
"
# Get ready...
pass=0
progs=0
##############################################################################
# Invoke the scripts that test the builtin functions.
# Let the test scripts use >&3 to indicate progress
exec 3>&1
echo "-- builtin --"
for i in $TESTS; do
j=${i##*/}
: $(( progs++ ))
echo -n "$j ... "
rm -rf "${OUTDIR}/$j."*
rc=$("$i" "$FUTILITY" 1>"${OUTDIR}/$j.stdout" \
2>"${OUTDIR}/$j.stderr" || echo "$?")
echo "${rc:-0}" > "${OUTDIR}/$j.return"
if [ ! "$rc" ]; then
green "PASSED"
: $(( pass++ ))
rm -f ${OUTDIR}/$j.{stdout,stderr,return}
else
red "FAILED. Stdout is recorded in ${OUTDIR}/$j.stdout"
cat ${OUTDIR}/$j.stderr
fi
done
##############################################################################
# How'd we do?
if [ "$pass" -eq "$progs" ]; then
green "Success: $pass / $progs passed"
exit 0
fi
red "FAIL: $pass / $progs passed"
exit 1