quicktest.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #! /bin/sh
  2. # This file is part of GNU tar testsuite.
  3. # Copyright (C) 2004 Free Software Foundation, Inc.
  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, or (at your option)
  8. # any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License 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., 59 Temple Place - Suite 330, Boston, MA
  18. # 02111-1307, USA.
  19. # Usage: quicktest FILELIST ARCHIVE-NAME
  20. quicktest() {
  21. DIR=quicktest.$$
  22. mkdir $DIR
  23. cd $DIR
  24. TAR_OPTIONS=""
  25. export TAR_OPTIONS
  26. tar xf $2
  27. tar -cf ../archive -H ustar -T $1
  28. cd ..
  29. ${TARTEST:-tartest} -v < $2 > $DIR/old.out
  30. ${TARTEST:-tartest} -v < archive > $DIR/new.out
  31. if cmp $DIR/old.out $DIR/new.out; then
  32. echo "PASS"
  33. rm -r $DIR
  34. exit 0
  35. else
  36. echo "FAIL. Examine $DIR for details"
  37. exit 1
  38. fi
  39. }
  40. test_access() {
  41. if [ -r $1 ]; then
  42. :
  43. else
  44. echo "$1 does not exist or is unreadable"
  45. echo 77
  46. fi
  47. }
  48. check_environ() {
  49. if [ "$STAR_TESTSCRIPTS" = "" ]; then
  50. echo "STAR_TESTSCRIPTS not set"
  51. exit 77
  52. fi
  53. if [ -d $STAR_TESTSCRIPTS ]; then
  54. :
  55. else
  56. echo "STAR_TESTSCRIPTS is not a directory"
  57. exit 77
  58. fi
  59. ARCHIVE=$STAR_TESTSCRIPTS/ustar-all-quicktest.tar
  60. test_access $ARCHIVE
  61. FILELIST=$STAR_TESTSCRIPTS/quicktest.filelist
  62. test_access $FILELIST
  63. ${TARTEST:-tartest} < /dev/null > /dev/null 2>&1
  64. if [ $? -eq 127 ]; then
  65. echo "tartest not in your path"
  66. exit 77
  67. fi
  68. }
  69. getargs() {
  70. for option
  71. do
  72. case $option in
  73. *=*) eval $option;;
  74. *) echo "Unknown option: $option" >&2
  75. exit 77;;
  76. esac
  77. done
  78. }
  79. if [ -w / ]; then
  80. getargs $*
  81. check_environ
  82. quicktest $FILELIST $ARCHIVE
  83. else
  84. echo "You need to be root to run this test"
  85. exit 77
  86. fi
  87. # End of quicktest.sh