2 # Exercise chdir-long's sample main program.
3 # FIXME: add traps and choose top level names so that
4 # temporary directories are easier to remove.
5 # FIXME: don't clobber a.out
7 gcc -DTEST_CHDIR=1 -DHAVE_CONFIG_H -I.. -g -O -W -Wall \
8 chdir-long.c libcoreutils.a
10 vg='valgrind --track-fds=yes --leak-check=yes --quiet --num-callers=9'
11 vg="$vg --leak-resolution=high"
13 # Create a directory with name of the specified length.
14 # Caveat: assumes the requested length is longer than that of $TMPDIR or /tmp.
18 case $# in 1) n=$1;; *) echo "Usage: $FUNCNAME N" 1>&2; return 1;; esac
19 local root=${TMPDIR=/tmp}
20 test -n "$ROOT" && root=$ROOT
22 perl -e 'my $len='$n'-length "'$root'";$i=100;$d="z"x$i;
25 mkdir $d,0700 or die "$!\n";
26 chdir $d} $d="z"x($len-1);
27 mkdir $d or die "mkdir_len: $d: $!\n"' )
32 for i in 7 8 9 10 11 12 13 14 15 16 17; do
36 size_list="$size_list $nm1 $n $np1"
37 pow_2=`expr $pow_2 \* 2`
40 for t in . /t /tmp /var/tmp; do
41 test -d $t || continue
44 for i in `echo $size_list 99999 11`; do
47 find $TMPDIR/zz*|tail -n1 > in
49 # strace -o /t/k-$tt-$i ./a.out < in > out
51 # eval "$vg ./a.out no-pwd < in"
53 if test "$TMPDIR" = . ; then
54 (pwd|tr -d '\n'; sed 's/^\.//' in) > k; rm -f in; mv k in
56 diff -u in out > diff \
57 || { echo FAIL $t:$i; cut -b 1-35 diff; } \