quicktest.sh 2.2 KB

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