test_main.sh revision ee53d65ac033da640034bc2d04bc09020435c072
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# Make sure deprecated functions fail via symlink
29DEPRECATED="dev_sign_file"
30
31for i in $DEPRECATED; do
32  ln -sf "$FUTILITY" $i
33  if ./$i 2>${TMP}.outmsg ; then false; fi
34  grep deprecated ${TMP}.outmsg
35  # They may still fail when invoked through futility
36  # but with a different error message.
37  "$FUTILITY" $i 1>${TMP}.outmsg2 2>&1 || true
38  if grep deprecated ${TMP}.outmsg2; then false; fi
39  rm -f $i
40done
41
42# cleanup
43rm -f ${TMP}*
44exit 0
45