1#!/bin/bash -eu 2# Copyright 2013 The ChromiumOS Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6# Load common constants and variables. 7. "$(dirname "$0")/../common.sh" 8 9OUTDIR="${BUILD_RUN}/tests/futility_test_results" 10[ -d "$OUTDIR" ] || mkdir -p "$OUTDIR" 11 12# Let each test know where to find things... 13export BUILD_RUN 14export SRCDIR 15export FUTILITY 16export SCRIPT_DIR 17export OUTDIR 18 19# These are the scripts to run. Binaries are invoked directly by the Makefile. 20TESTS=" 21${SCRIPT_DIR}/futility/test_create.sh 22${SCRIPT_DIR}/futility/test_dump_fmap.sh 23${SCRIPT_DIR}/futility/test_flash_util.sh 24${SCRIPT_DIR}/futility/test_gbb_utility.sh 25${SCRIPT_DIR}/futility/test_load_fmap.sh 26${SCRIPT_DIR}/futility/test_main.sh 27${SCRIPT_DIR}/futility/test_rwsig.sh 28${SCRIPT_DIR}/futility/test_show_and_verify.sh 29${SCRIPT_DIR}/futility/test_show_usbpd1.sh 30${SCRIPT_DIR}/futility/test_sign_firmware.sh 31${SCRIPT_DIR}/futility/test_sign_fw_main.sh 32${SCRIPT_DIR}/futility/test_sign_kernel.sh 33${SCRIPT_DIR}/futility/test_sign_keyblocks.sh 34${SCRIPT_DIR}/futility/test_sign_usbpd1.sh 35${SCRIPT_DIR}/futility/test_update.sh 36${SCRIPT_DIR}/futility/test_file_types.sh 37${SCRIPT_DIR}/futility/test_gscvd.sh 38${SCRIPT_DIR}/futility/test_read.sh 39${SCRIPT_DIR}/futility/test_vbutil_output.sh 40" 41 42# Get ready... 43pass=0 44progs=0 45 46############################################################################## 47# Invoke the scripts that test the builtin functions. 48 49# Let the test scripts use >&3 to indicate progress 50exec 3>&1 51 52echo "-- builtin --" 53for i in $TESTS; do 54 j=${i##*/} 55 56 : $(( progs++ )) 57 58 echo -n "$j ... " 59 rm -rf "${OUTDIR}/$j."* 60 rc=$("$i" "$FUTILITY" 1>"${OUTDIR}/$j.stdout" \ 61 2>"${OUTDIR}/$j.stderr" || echo "$?") 62 echo "${rc:-0}" > "${OUTDIR}/$j.return" 63 if [ ! "$rc" ]; then 64 echo -e "${COL_GREEN}PASSED${COL_STOP}" 65 : $(( pass++ )) 66 rm -f "${OUTDIR}/$j".{stdout,stderr,return} 67 else 68 echo -e "${COL_RED}FAILED (${rc:-0}). Stdout is recorded in" \ 69 "${OUTDIR}/$j.stdout${COL_STOP}" 70 cat "${OUTDIR}/$j.stderr" 71 fi 72done 73 74############################################################################## 75# How'd we do? 76 77if [ "$pass" -eq "$progs" ]; then 78 echo -e "${COL_GREEN}Success: $pass / $progs passed${COL_STOP}" 79 exit 0 80fi 81 82echo -e "${COL_RED}FAIL: $pass / $progs passed${COL_STOP}" 83exit 1 84