1 # Process this file with autom4te to create testsuite. -*- Autotest -*-
3 # Test suite for GNU tar.
4 # Copyright 2010, 2013 Free Software Foundation, Inc.
6 # This file is part of GNU tar.
8 # GNU tar is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # GNU tar is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # written by Paul Eggert
23 # Check that 'tar' works even in a file-descriptor-limited environment.
25 AT_SETUP([scarce file descriptors])
26 AT_KEYWORDS([extract extrac11])
43 mkdir $dirs dest1 dest2 dest3 || exit
46 echo $file >$dir/$file || exit
51 # Check that "ulimit" itself works. Close file descriptors before
52 # invoking ulimit, to work around a bug (or a "feature") in some shells,
53 # where they squirrel away dups of file descriptors into FD 10 and up
54 # before closing the originals.
55 ( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
57 tar -cf archive1.tar a &&
58 tar -xf archive1.tar -C dest1 a
64 # Another test that "ulimit" itself works:
65 # tar should fail when completely starved of file descriptors.
66 ( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
68 tar -cf archive2.tar a &&
69 tar -xf archive2.tar -C dest2 a
75 # Tar should work when there are few, but enough, file descriptors.
76 ( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
78 tar -cf archive3.tar a &&
79 tar -xf archive3.tar -C dest3 a
81 diff -r a dest3/a >/dev/null 2>&1
82 ) || { diff -r a dest3/a; exit 1; }
84 [0],[],[],[],[],[gnu])