quicktest.sh 2.2 KB

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