Files
OpenCellular/tests/futility/run_test_scripts.sh
Bill Richardson b5a439241f futility: add support for usbpd1 images
The USB Type-C chargers released with Samus ("Pixel (2015)") have
upgradable firmware. Those firmware images are currently signed
by some custom scripts. This adds support for those images to
futility, so that those custom scripts can be replaced.

Note that due to space considerations, the usbpd firmware images
don't have room for handy things like an FMAP or headers for the
signatures. Accordingly, all the normally variable factors (image
size, signature algorithms, etc.) are hard coded and the image
itself just looks like a bunch of random numbers. Because of
this:

1. There's no way to recognize this type of file, and nothing to
   display about it.

2. You have to give the "--type usbpd1" arg to the sign command.

3. I'm designating this file type "v1" because I hope that the
   firmware for any future adapters will be more readily
   identifiable.

BUG=chromium:231574
BRANCH=none
TEST=make runtests

This adds a new test that signs usbpd1 firmware images using
futility, and compares the result to the same files signed by the
custom scripts, ensuring that they are bitwise identical.

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: Idbe061db5b3c8e474ada47b40bcbe04bbecdba3a
Reviewed-on: https://chromium-review.googlesource.com/262899
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-03-31 06:30:36 +00:00

99 lines
2.3 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_create.sh
${SCRIPTDIR}/test_dump_fmap.sh
${SCRIPTDIR}/test_gbb_utility.sh
${SCRIPTDIR}/test_load_fmap.sh
${SCRIPTDIR}/test_main.sh
${SCRIPTDIR}/test_show_kernel.sh
${SCRIPTDIR}/test_show_vs_verify.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"
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