2 # Exercise chdir-long's sample main program.
4 # Copyright (C) 2005, 2006 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 2 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, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 # FIXME: add traps and choose top level names so that
23 # temporary directories are easier to remove.
24 # FIXME: don't clobber a.out
26 gcc
-DTEST_CHDIR -g -O -W -Wall \
27 chdir-long.c libcoreutils.a
29 vg
='valgrind --track-fds=yes --leak-check=yes --quiet --num-callers=9'
30 vg
="$vg --leak-resolution=high"
32 # Create a directory with name of the specified length.
33 # Caveat: assumes the requested length is longer than that of $TMPDIR or /tmp.
37 case $# in 1) n
=$1;; *) echo "Usage: $FUNCNAME N" 1>&2; return 1;; esac
38 local root
=${TMPDIR=/tmp}
39 test -n "$ROOT" && root
=$ROOT
41 perl
-e 'my $len='$n'-length "'$root'";$i=100;$d="z"x$i;
44 mkdir $d,0700 or die "$!\n";
45 chdir $d} $d="z"x($len-1);
46 mkdir $d or die "mkdir_len: $d: $!\n"' )
51 for i
in 7 8 9 10 11 12 13 14 15 16 17; do
55 size_list
="$size_list $nm1 $n $np1"
56 pow_2
=`expr $pow_2 \* 2`
59 for t
in .
/t
/tmp
/var
/tmp
; do
60 test -d $t ||
continue
63 for i
in `echo $size_list 99999 11`; do
66 find $TMPDIR/zz
*|
tail -n1 > in
68 # strace -o /t/k-$tt-$i ./a.out < in > out
70 # eval "$vg ./a.out no-pwd < in"
72 if test "$TMPDIR" = .
; then
73 (pwd|
tr -d '\n'; sed 's/^\.//' in) > k
; rm -f in; mv k
in
75 diff -u in out
> diff \
76 ||
{ echo FAIL
$t:$i; cut
-b 1-35 diff; } \