extrac11.at 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. dirs='a
  20. a/b
  21. a/b/c
  22. a/b/c/d
  23. a/b/c/d/e
  24. a/b/c/d/e/f
  25. a/b/c/d/e/f/g
  26. a/b/c/d/e/f/g/h
  27. a/b/c/d/e/f/g/h/i
  28. a/b/c/d/e/f/g/h/i/j
  29. a/b/c/d/e/f/g/h/i/j/k
  30. '
  31. files=
  32. mkdir $dirs dest1 dest2 dest3 || exit
  33. for dir in $dirs; do
  34. for file in X Y Z; do
  35. echo $file >$dir/$file || exit
  36. files="$files $file"
  37. done
  38. done
  39. # Check that "ulimit" itself works.
  40. ((ulimit -n 100 &&
  41. tar -cf archive1.tar a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
  42. tar -xf archive1.tar -C dest1 a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&-
  43. ) &&
  44. diff -r a dest1/a
  45. ) >/dev/null 2>&1 ||
  46. AT_SKIP_TEST
  47. # Another test that "ulimit" itself works:
  48. # tar should fail when completely starved of file descriptors.
  49. ((ulimit -n 4 &&
  50. tar -cf archive2.tar a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
  51. tar -xf archive2.tar -C dest2 a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&-
  52. ) &&
  53. diff -r a dest2/a
  54. ) >/dev/null 2>&1 &&
  55. AT_SKIP_TEST
  56. # Tar should work when there are few, but enough, file descriptors.
  57. ((ulimit -n 10 &&
  58. tar -cf archive3.tar a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
  59. tar -xf archive3.tar -C dest3 a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&-
  60. ) &&
  61. diff -r a dest3/a >/dev/null 2>&1
  62. ) || { diff -r a dest3/a; exit 1; }
  63. ],
  64. [0],[],[],[],[],[gnu])
  65. AT_CLEANUP