test_main.sh 1.9 KB

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