1#!/bin/bash -eux 2# Copyright 2014 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 6me=${0##*/} 7TMP="$me.tmp" 8 9# Work in scratch directory 10cd "$OUTDIR" 11 12# No args returns nonzero exit code 13"${FUTILITY}" && false 14 15# It's weird but okay if the command is a full path. 16"${FUTILITY}" /fake/path/to/help > "$TMP" 17grep Usage "$TMP" 18 19# Use some known digests to verify that things work... 20DEVKEYS="${SRCDIR}/tests/devkeys" 21SHA=e78ce746a037837155388a1096212ded04fb86eb 22 23# all progs in the pipelines should work 24set -o pipefail 25 26# If it's invoked as the name of a command we know, it should do that command 27ln -sf "${FUTILITY}" vbutil_key 28./vbutil_key --unpack "${DEVKEYS}/installer_kernel_data_key.vbpubk" | \ 29 grep "${SHA}" 30ln -sf "${FUTILITY}" vbutil_keyblock 31./vbutil_keyblock --unpack "${DEVKEYS}/installer_kernel.keyblock" | \ 32 grep "${SHA}" 33cp "${FUTILITY}" show 34./show "${SCRIPT_DIR}/futility/data/rec_kernel_part.bin" | grep "${SHA}" 35 36# If it's invoked by any other name, expect the command to be the first arg. 37ln -sf "${FUTILITY}" muggle 38./muggle vbutil_key --unpack "${DEVKEYS}/installer_kernel_data_key.vbpubk" \ 39 | grep "${SHA}" 40ln -sf "${FUTILITY}" buggle 41./buggle vbutil_keyblock --unpack "${DEVKEYS}/installer_kernel.keyblock" \ 42 | grep "${SHA}" 43cp "${FUTILITY}" boo 44./boo show "${SCRIPT_DIR}/futility/data/rec_kernel_part.bin" | grep "${SHA}" 45 46 47# we expect the first command fail, but the output to match anyway 48set +o pipefail 49 50# If it can't figure out the command at all, it should complain. 51"${FUTILITY}" muggle | grep Usage: 52./buggle futility | grep Usage: 53./boo | grep Usage: 54 55# cleanup 56rm -f "${TMP}"* vbutil_key vbutil_keyblock show muggle buggle boo 57exit 0 58