2 # Exercise chdir-long's sample main program.
4 # Copyright (C) 2005-2006, 2009-2012 Free Software Foundation, Inc.
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 of the License, or
9 # (at your option) any later version.
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.
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/>.
20 # FIXME: add traps and choose top level names so that
21 # temporary directories are easier to remove.
22 # FIXME: don't clobber a.out
24 gcc
-DTEST_CHDIR -g -O -W -Wall \
25 chdir-long.c libcoreutils.a
27 vg
='valgrind --track-fds=yes --leak-check=yes --quiet --num-callers=9'
28 vg
="$vg --leak-resolution=high"
30 # Create a directory with name of the specified length.
31 # Caveat: assumes the requested length is longer than that of $TMPDIR or /tmp.
35 case $# in 1) n
=$1;; *) echo "Usage: $FUNCNAME N" 1>&2; return 1;; esac
36 local root
=${TMPDIR=/tmp}
37 test -n "$ROOT" && root
=$ROOT
39 perl
-e 'my $len='$n'-length "'$root'";$i=100;$d="z"x$i;
42 mkdir $d,0700 or die "$!\n";
43 chdir $d} $d="z"x($len-1);
44 mkdir $d or die "mkdir_len: $d: $!\n"' )
49 for i
in 7 8 9 10 11 12 13 14 15 16 17; do
53 size_list
="$size_list $nm1 $n $np1"
54 pow_2
=`expr $pow_2 \* 2`
57 for t
in .
/t
/tmp
/var
/tmp
; do
58 test -d $t ||
continue
61 for i
in `echo $size_list 99999 11`; do
64 find $TMPDIR/zz
*|
tail -n1 > in
66 # strace -o /t/k-$tt-$i ./a.out < in > out
68 # eval "$vg ./a.out no-pwd < in"
70 if test "$TMPDIR" = .
; then
71 (pwd|
tr -d '\n'; sed 's/^\.//' in) > k
; rm -f in; mv k
in
73 diff -u in out
> diff \
74 ||
{ echo FAIL
$t:$i; cut
-b 1-35 diff; } \