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