4
0

quicktest.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #! /bin/sh
  2. # This file is part of GNU tar testsuite.
  3. # Copyright (C) 2004, 2005, 2007 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 3, 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., 51 Franklin Street, Fifth Floor, Boston, MA
  18. # 02110-1301, USA.
  19. PWD=`pwd`
  20. P=`expr $0 : '\(.*\)/.*'`
  21. DIR=`cd $P; pwd`/../../src
  22. if [ -d $DIR ]; then
  23. PATH=`cd $DIR;pwd`:$PATH
  24. fi
  25. # Usage: quicktest FILELIST ARCHIVE-NAME
  26. quicktest() {
  27. DIR=quicktest.$$
  28. mkdir $DIR
  29. cd $DIR
  30. TAR_OPTIONS=""
  31. export TAR_OPTIONS
  32. tar xf $2
  33. tar -cf ../archive -H ustar -T $1
  34. cd ..
  35. ${TARTEST:-tartest} -v < $2 > $DIR/old.out
  36. ${TARTEST:-tartest} -v < archive > $DIR/new.out
  37. if cmp $DIR/old.out $DIR/new.out; then
  38. echo "PASS"
  39. rm -r $DIR
  40. exit 0
  41. else
  42. echo "FAIL. Examine $DIR for details"
  43. exit 1
  44. fi
  45. }
  46. test_access() {
  47. if [ -r $1 ]; then
  48. :
  49. else
  50. echo "$1 does not exist or is unreadable"
  51. echo 77
  52. fi
  53. }
  54. check_environ() {
  55. if [ "$STAR_TESTSCRIPTS" = "" ]; then
  56. echo "STAR_TESTSCRIPTS not set"
  57. exit 77
  58. fi
  59. if [ -d $STAR_TESTSCRIPTS ]; then
  60. :
  61. else
  62. echo "STAR_TESTSCRIPTS is not a directory"
  63. exit 77
  64. fi
  65. ARCHIVE=$STAR_TESTSCRIPTS/ustar-all-quicktest.tar
  66. test_access $ARCHIVE
  67. FILELIST=$STAR_TESTSCRIPTS/quicktest.filelist
  68. test_access $FILELIST
  69. ${TARTEST:-tartest} < /dev/null > /dev/null 2>&1
  70. if [ $? -eq 127 ]; then
  71. echo "tartest not in your path"
  72. exit 77
  73. fi
  74. tar --version
  75. }
  76. getargs() {
  77. for option
  78. do
  79. case $option in
  80. *=*) eval $option;;
  81. *) echo "Unknown option: $option" >&2
  82. exit 77;;
  83. esac
  84. done
  85. }
  86. if [ -w / ]; then
  87. getargs $*
  88. check_environ
  89. quicktest $FILELIST $ARCHIVE
  90. else
  91. echo "You need to be root to run this test"
  92. exit 77
  93. fi
  94. # End of quicktest.sh