• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
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# Make sure logging does something.
20LOG="/tmp/futility.log"
21[ -f ${LOG} ] && mv ${LOG} ${LOG}.backup
22touch ${LOG}
23${FUTILITY} help
24grep ${FUTILITY} ${LOG}
25rm -f ${LOG}
26[ -f ${LOG}.backup ] && mv ${LOG}.backup ${LOG}
27
28# Use some known digests to verify that things work...
29DEVKEYS=${SRCDIR}/tests/devkeys
30SHA=e78ce746a037837155388a1096212ded04fb86eb
31
32# all progs in the pipelines should work
33set -o pipefail
34
35# If it's invoked as the name of a command we know, it should do that command
36ln -sf ${FUTILITY} vbutil_key
37./vbutil_key --unpack ${DEVKEYS}/installer_kernel_data_key.vbpubk | grep ${SHA}
38ln -sf ${FUTILITY} vbutil_keyblock
39./vbutil_keyblock --unpack ${DEVKEYS}/installer_kernel.keyblock | grep ${SHA}
40cp ${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.
44ln -sf ${FUTILITY} muggle
45./muggle vbutil_key --unpack ${DEVKEYS}/installer_kernel_data_key.vbpubk \
46  | grep ${SHA}
47ln -sf ${FUTILITY} buggle
48./buggle vbutil_keyblock --unpack ${DEVKEYS}/installer_kernel.keyblock \
49  | grep ${SHA}
50cp ${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
55set +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
63rm -f ${TMP}* vbutil_key vbutil_keyblock show muggle buggle boo
64exit 0
65