1 #!/bin/bash -eux 2 # Copyright 2014 The Chromium OS Authors. All rights reserved. 3 # Use of this source code is governed by a BSD-style license that can be 4 # found in the LICENSE file. 5 6 me=${0##*/} 7 TMP="$me.tmp" 8 9 # Work in scratch directory 10 cd "$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" 17 grep Usage "$TMP" 18 19 # Make sure logging does something. 20 LOG="/tmp/futility.log" 21 [ -f ${LOG} ] && mv ${LOG} ${LOG}.backup 22 touch ${LOG} 23 ${FUTILITY} help 24 grep ${FUTILITY} ${LOG} 25 rm -f ${LOG} 26 [ -f ${LOG}.backup ] && mv ${LOG}.backup ${LOG} 27 28 # Use some known digests to verify that things work... 29 DEVKEYS=${SRCDIR}/tests/devkeys 30 SHA=e78ce746a037837155388a1096212ded04fb86eb 31 32 # all progs in the pipelines should work 33 set -o pipefail 34 35 # If it's invoked as the name of a command we know, it should do that command 36 ln -sf ${FUTILITY} vbutil_key 37 ./vbutil_key --unpack ${DEVKEYS}/installer_kernel_data_key.vbpubk | grep ${SHA} 38 ln -sf ${FUTILITY} vbutil_keyblock 39 ./vbutil_keyblock --unpack ${DEVKEYS}/installer_kernel.keyblock | grep ${SHA} 40 cp ${FUTILITY} show 41 ./show ${SCRIPTDIR}/data/rec_kernel_part.bin | grep ${SHA} 42 43 # If it's invoked by any other name, expect the command to be the first arg. 44 ln -sf ${FUTILITY} muggle 45 ./muggle vbutil_key --unpack ${DEVKEYS}/installer_kernel_data_key.vbpubk \ 46 | grep ${SHA} 47 ln -sf ${FUTILITY} buggle 48 ./buggle vbutil_keyblock --unpack ${DEVKEYS}/installer_kernel.keyblock \ 49 | grep ${SHA} 50 cp ${FUTILITY} boo 51 ./boo show ${SCRIPTDIR}/data/rec_kernel_part.bin | grep ${SHA} 52 53 54 # we expect the first command fail, but the output to match anyway 55 set +o pipefail 56 57 # If it can't figure out the command at all, it should complain. 58 ${FUTILITY} muggle | grep Usage: 59 ./buggle futility | grep Usage: 60 ./boo | grep Usage: 61 62 # cleanup 63 rm -f ${TMP}* vbutil_key vbutil_keyblock show muggle buggle boo 64 exit 0 65