Imported Upstream version 1.25
[debian/tar] / tests / extrac11.at
index 9456695a49387dc3a60713e4748078d59b8b9424..0481c2755098736946530ab00e9cc74771614386 100644 (file)
@@ -24,6 +24,7 @@ AT_SETUP([scarce file descriptors])
 AT_KEYWORDS([extract extrac11])
 
 AT_TAR_CHECK([
+exec </dev/null
 dirs='a
       a/b
       a/b/c
@@ -45,31 +46,37 @@ for dir in $dirs; do
   done
 done
 
-# Check that "ulimit" itself works.
-((ulimit -n 100 &&
-  tar -cf archive1.tar a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
-  tar -xf archive1.tar -C dest1 a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&-
- ) &&
- diff -r a dest1/a
+# Check that "ulimit" itself works.  Close file descriptors before
+# invoking ulimit, to work around a bug (or a "feature") in some shells,
+# where they squirrel away dups of file descriptors into FD 10 and up
+# before closing the originals.
+( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
+   ulimit -n 100 &&
+   tar -cf archive1.tar a &&
+   tar -xf archive1.tar -C dest1 a
+  ) &&
+  diff -r a dest1/a
 ) >/dev/null 2>&1 ||
    AT_SKIP_TEST
 
 # Another test that "ulimit" itself works:
 # tar should fail when completely starved of file descriptors.
-((ulimit -n 4 &&
-  tar -cf archive2.tar a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
-  tar -xf archive2.tar -C dest2 a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&-
- ) &&
- diff -r a dest2/a
+( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
+   ulimit -n 4 &&
+   tar -cf archive2.tar a &&
+   tar -xf archive2.tar -C dest2 a
+  ) &&
+  diff -r a dest2/a
 ) >/dev/null 2>&1 &&
    AT_SKIP_TEST
 
 # Tar should work when there are few, but enough, file descriptors.
-((ulimit -n 10 &&
-  tar -cf archive3.tar a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
-  tar -xf archive3.tar -C dest3 a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&-
- ) &&
- diff -r a dest3/a >/dev/null 2>&1
+( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
+   ulimit -n 10 &&
+   tar -cf archive3.tar a &&
+   tar -xf archive3.tar -C dest3 a
+  ) &&
+  diff -r a dest3/a >/dev/null 2>&1
 ) || { diff -r a dest3/a; exit 1; }
 ],
 [0],[],[],[],[],[gnu])