extrac11.at 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. # Test suite for GNU tar.
  3. # Copyright (C) 2010 Free Software Foundation, Inc.
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 3, or (at your option)
  7. # any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. # written by Paul Eggert
  15. # Check that 'tar' works even in a file-descriptor-limited environment.
  16. AT_SETUP([scarce file descriptors])
  17. AT_KEYWORDS([extract extrac11])
  18. AT_TAR_CHECK([
  19. exec </dev/null
  20. dirs='a
  21. a/b
  22. a/b/c
  23. a/b/c/d
  24. a/b/c/d/e
  25. a/b/c/d/e/f
  26. a/b/c/d/e/f/g
  27. a/b/c/d/e/f/g/h
  28. a/b/c/d/e/f/g/h/i
  29. a/b/c/d/e/f/g/h/i/j
  30. a/b/c/d/e/f/g/h/i/j/k
  31. '
  32. files=
  33. mkdir $dirs dest1 dest2 dest3 || exit
  34. for dir in $dirs; do
  35. for file in X Y Z; do
  36. echo $file >$dir/$file || exit
  37. files="$files $file"
  38. done
  39. done
  40. # Check that "ulimit" itself works. Close file descriptors before
  41. # invoking ulimit, to work around a bug (or a "feature") in some shells,
  42. # where they squirrel away dups of file descriptors into FD 10 and up
  43. # before closing the originals.
  44. ( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
  45. ulimit -n 100 &&
  46. tar -cf archive1.tar a &&
  47. tar -xf archive1.tar -C dest1 a
  48. ) &&
  49. diff -r a dest1/a
  50. ) >/dev/null 2>&1 ||
  51. AT_SKIP_TEST
  52. # Another test that "ulimit" itself works:
  53. # tar should fail when completely starved of file descriptors.
  54. ( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
  55. ulimit -n 4 &&
  56. tar -cf archive2.tar a &&
  57. tar -xf archive2.tar -C dest2 a
  58. ) &&
  59. diff -r a dest2/a
  60. ) >/dev/null 2>&1 &&
  61. AT_SKIP_TEST
  62. # Tar should work when there are few, but enough, file descriptors.
  63. ( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
  64. ulimit -n 10 &&
  65. tar -cf archive3.tar a &&
  66. tar -xf archive3.tar -C dest3 a
  67. ) &&
  68. diff -r a dest3/a >/dev/null 2>&1
  69. ) || { diff -r a dest3/a; exit 1; }
  70. ],
  71. [0],[],[],[],[],[gnu])
  72. AT_CLEANUP