maint: refactor tests/misc/pr.pl into tests/pr/pr-tests.pl
[coreutils.git] / tests / mv / leak-fd.sh
blob1dd006fa4052bc64a4b0f6ac077d557167baaaec
1 #!/bin/sh
2 # Exercise mv's file-descriptor-leak bug, reported against coreutils-5.2.1
3 # and fixed (properly) on 2004-10-21.
5 # Copyright (C) 2004-2012 Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # limit so don't run it by default.
21 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
22 print_ver_ mv
23 skip_if_root_
24 cleanup_() { rm -rf "$other_partition_tmpdir"; }
25 . "$abs_srcdir/tests/other-fs-tmpdir"
27 # This test is relatively expensive, and might well evoke a
28 # framework-failure on systems with a smaller command-line length
29 expensive_
31 b="0 1 2 3 4 5 6 7 8 9
32 a b c d e f g h i j k l m n o p q r s t u v w x y z
33 _A _B _C _D _E _F _G _H _I _J _K _L _M _N _O _P _Q _R _S _T _U _V _W _X _Y _Z"
35 for i in $(echo $b); do
36 echo $i
37 for j in $b; do
38 echo $i$j
39 done
40 done > .dirs
41 mkdir $(cat .dirs) || framework_failure_
42 sed 's,$,/f,' .dirs | xargs touch
44 last_file=$(tail -n1 .dirs)/f
45 test -f $last_file || framework_failure_
48 mv * "$other_partition_tmpdir" || fail=1
49 test -f $last_file/f && fail=1
50 rm .dirs
52 out=$(ls -A) || fail=1
53 test -z "$out" || fail=1
55 Exit $fail