tpm_restrictpubek_tests.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. setup()
  20. {
  21. RC=0 # Return code from commands.
  22. if [ -z "$LTPTMP" ] && [ -z "$TMPBASE" ]
  23. then
  24. LTPTMP="/tmp"
  25. else
  26. LTPTMP="$TMPBASE"
  27. fi
  28. export TPM_TMPFILE="$LTPTMP/tst_tpm.err"
  29. rm -f $TPM_TMPFILE 2>&1
  30. # Set known password values
  31. if [ -z "$OWN_PWD" ]
  32. then
  33. export OWN_PWD="OWN PWD"
  34. fi
  35. if [ -z "$SRK_PWD" ]
  36. then
  37. export SRK_PWD="SRK PWD"
  38. fi
  39. tst_resm TINFO "INIT: Inititalizing tests."
  40. which tpm_restrictpubek 1>$TPM_TMPFILE 2>&1 || RC=$?
  41. if [ $RC -ne 0 ]
  42. then
  43. tst_brk TBROK $TPM_TMPFILE NULL \
  44. "Setup: tpm_restrictpubek command does not exist. Reason:"
  45. return $RC
  46. fi
  47. which tpm_getpubek 1>$TPM_TMPFILE 2>&1 || RC=$?
  48. if [ $RC -ne 0 ]
  49. then
  50. tst_brk TBROK $TPM_TMPFILE NULL \
  51. "Setup: tpm_getpubek command does not exist. Reason:"
  52. return $RC
  53. fi
  54. return $RC
  55. }
  56. test01()
  57. {
  58. RC=0 # Return value from commands
  59. export TCID=tpm_restrictpubek01 # Test ID
  60. export TST_COUNT=1 # Test number
  61. tpm_restrictpubek_tests_exp01.sh 1>$TPM_TMPFILE 2>&1 || RC=$?
  62. if [ $RC -eq 0 ]
  63. then
  64. tst_resm TPASS "'tpm_restrictpubek -r' passed."
  65. RC=0
  66. else
  67. tst_res TFAIL $TPM_TMPFILE "'tpm_restrictpubek -r' failed."
  68. RC=1
  69. fi
  70. return $RC
  71. }
  72. test02()
  73. {
  74. RC=0 # Return value from commands
  75. export TCID=tpm_restrictpubek02 # Test ID
  76. export TST_COUNT=2 # Test number
  77. tpm_restrictpubek_tests_exp02.sh 1>$TPM_TMPFILE 2>&1 || RC=$?
  78. if [ $RC -eq 0 ]
  79. then
  80. tst_resm TPASS "'tpm_restrictpubek -s' passed."
  81. RC=0
  82. else
  83. tst_res TFAIL $TPM_TMPFILE "'tpm_restrictpubek -s' failed."
  84. RC=1
  85. fi
  86. return $RC
  87. }
  88. test03()
  89. {
  90. RC=0 # Return value from commands
  91. export TCID=tpm_restrictpubek03 # Test ID
  92. export TST_COUNT=3 # Test number
  93. tpm_restrictpubek_tests_exp03.sh 1>$TPM_TMPFILE 2>&1 || RC=$?
  94. if [ $RC -eq 0 ]
  95. then
  96. tst_resm TPASS "'tpm_getpubek' passed."
  97. RC=0
  98. else
  99. tst_res TFAIL $TPM_TMPFILE "'tpm_getpubek' failed."
  100. RC=1
  101. fi
  102. return $RC
  103. }
  104. cleanup()
  105. {
  106. rm -f $TPM_TMPFILE 2>&1
  107. }
  108. # Function: main
  109. #
  110. # Description: - Execute all tests, report results.
  111. #
  112. # Exit: - zero on success
  113. # - non-zero on failure.
  114. TFAILCNT=0 # Set TFAILCNT to 0, increment on failure.
  115. RC=0 # Return code from tests.
  116. export TCID=tpm_restrictpubek # Test ID
  117. export TST_TOTAL=3 # Total numner of tests in this file.
  118. export TST_COUNT=0 # Initialize identifier
  119. setup || exit $RC # Exit if initializing testcases fails.
  120. test01 || TFAILCNT=$(($TFAILCNT+1))
  121. test02 || TFAILCNT=$(($TFAILCNT+1))
  122. test03 || TFAILCNT=$(($TFAILCNT+1))
  123. cleanup
  124. exit $TFAILCNT