tpm_version_tests.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #! /bin/sh
  2. #
  3. # Copyright (c) International Business Machines Corp., 2005
  4. #
  5. # This program is free software; you can redistribute it and#or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. # for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. #
  19. export TCID=tpm_version
  20. export TST_TOTAL=1
  21. export TST_COUNT=1
  22. setup()
  23. {
  24. RC=0 # Return code from commands.
  25. if [ -z "$LTPTMP" ] && [ -z "$TMPBASE" ]
  26. then
  27. LTPTMP="/tmp"
  28. else
  29. LTPTMP="$TMPBASE"
  30. fi
  31. export TPM_TMPFILE="$LTPTMP/tst_tpm.err"
  32. rm -f $TPM_TMPFILE 2>&1
  33. tst_resm TINFO "INIT: Inititalizing tests."
  34. which tpm_version 1>$TPM_TMPFILE 2>&1 || RC=$?
  35. if [ $RC -ne 0 ]
  36. then
  37. tst_brk TBROK $TPM_TMPFILE NULL \
  38. "Test: tpm_version command does not exist. Reason:"
  39. return $RC
  40. fi
  41. return $RC
  42. }
  43. test01()
  44. {
  45. RC=0 # Return value from commands
  46. export TCID=tpm_version01 # Test ID
  47. export TST_COUNT=1 # Test number
  48. tpm_version 1>$TPM_TMPFILE 2>&1 || RC=$?
  49. if [ $RC -eq 0 ]
  50. then
  51. tst_resm TPASS "'tpm_version' passed."
  52. RC=0
  53. else
  54. tst_res TFAIL $TPM_TMPFILE "'tpm_version' failed."
  55. RC=1
  56. fi
  57. return $RC
  58. }
  59. cleanup()
  60. {
  61. rm -f $TPM_TMPFILE 2>&1
  62. }
  63. # Function: main
  64. #
  65. # Description: - Execute all tests, report results.
  66. #
  67. # Exit: - zero on success
  68. # - non-zero on failure.
  69. TFAILCNT=0 # Set TFAILCNT to 0, increment on failure.
  70. RC=0 # Return code from tests.
  71. setup || exit $RC # Exit if initializing testcases fails.
  72. export TCID=tpm_version # Test ID
  73. export TST_TOTAL=1 # Total numner of tests in this file.
  74. export TST_COUNT=0 # Initialize identifier
  75. test01 || TFAILCNT=$(($TFAILCNT+1))
  76. cleanup
  77. exit $TFAILCNT