head	1.31;
access;
symbols
	UNIONFS-1_4:1.30
	LKML-branch:1.30.0.12
	LKML:1.30
	UNIONFS-1_3-branch:1.30.0.10
	UNIONFS-1_3:1.30
	UNIONFS-1_2:1.30
	UNIONFS-1_2-branch:1.30.0.8
	UNIONFS-1_2-branchpoint:1.30
	UNIONFS_branchman:1.30
	branchman:1.30.0.6
	UNIONFS-1_1_4:1.30
	UNIONFS-1_1-patches:1.30.0.4
	UNIONFS-1_1_3:1.30
	crc-submitted-to-ols2006:1.30
	remount:1.30.0.2
	UNIONFS-1_1_2:1.30
	BEFORE_MOUNTPOINT_CROSSING:1.30
	UNIONFS-1_1_1:1.30
	UNIONFS_PRE_1_1_1:1.30
	UNIONFS-1_1:1.30
	UNIONFS_PRE_1_1:1.29.0.2
	UNIONFS-1_0_14:1.29
	UNIONFS-1_0_13:1.16
	submitted-to-tos-2005:1.13
	UNIONFS-1_0_4:1.13
	SUBMITTED_TO_USENIX_2005:1.13;
locks; strict;
comment	@# @;


1.31
date	2007.01.17.16.49.34;	author jsipek;	state Exp;
branches;
next	1.30;

1.30
date	2005.09.28.18.02.38;	author cwright;	state Exp;
branches
	1.30.12.1;
next	1.29;

1.29
date	2005.09.14.20.51.09;	author dquigley;	state Exp;
branches;
next	1.28;

1.28
date	2005.08.30.14.09.25;	author cwright;	state Exp;
branches;
next	1.27;

1.27
date	2005.08.29.17.35.26;	author cwright;	state Exp;
branches;
next	1.26;

1.26
date	2005.08.29.17.16.45;	author cwright;	state Exp;
branches;
next	1.25;

1.25
date	2005.08.29.16.58.23;	author cwright;	state Exp;
branches;
next	1.24;

1.24
date	2005.08.24.14.17.21;	author cwright;	state Exp;
branches;
next	1.23;

1.23
date	2005.08.17.20.17.25;	author cwright;	state Exp;
branches;
next	1.22;

1.22
date	2005.08.16.19.45.18;	author cwright;	state Exp;
branches;
next	1.21;

1.21
date	2005.08.15.13.11.28;	author cwright;	state Exp;
branches;
next	1.20;

1.20
date	2005.08.12.17.40.50;	author arunmk;	state Exp;
branches;
next	1.19;

1.19
date	2005.08.10.18.34.24;	author arunmk;	state Exp;
branches;
next	1.18;

1.18
date	2005.08.10.16.21.40;	author cwright;	state Exp;
branches;
next	1.17;

1.17
date	2005.08.01.15.15.09;	author cwright;	state Exp;
branches;
next	1.16;

1.16
date	2005.07.22.17.02.28;	author cwright;	state Exp;
branches;
next	1.15;

1.15
date	2005.07.20.16.40.06;	author cwright;	state Exp;
branches;
next	1.14;

1.14
date	2005.07.19.17.32.38;	author cwright;	state Exp;
branches;
next	1.13;

1.13
date	2004.08.24.20.17.22;	author cwright;	state Exp;
branches;
next	1.12;

1.12
date	2004.08.24.17.33.02;	author zubair;	state Exp;
branches;
next	1.11;

1.11
date	2004.08.19.19.18.51;	author cwright;	state Exp;
branches;
next	1.10;

1.10
date	2004.08.19.17.47.17;	author zubair;	state Exp;
branches;
next	1.9;

1.9
date	2004.08.19.17.24.35;	author cwright;	state Exp;
branches;
next	1.8;

1.8
date	2004.08.19.16.40.19;	author cwright;	state Exp;
branches;
next	1.7;

1.7
date	2004.08.19.16.27.52;	author cwright;	state Exp;
branches;
next	1.6;

1.6
date	2004.08.19.15.46.25;	author cwright;	state Exp;
branches;
next	1.5;

1.5
date	2004.08.18.17.41.24;	author zubair;	state Exp;
branches;
next	1.4;

1.4
date	2004.08.17.20.58.55;	author zubair;	state Exp;
branches;
next	1.3;

1.3
date	2004.08.17.17.34.08;	author cwright;	state Exp;
branches;
next	1.2;

1.2
date	2004.08.17.16.51.48;	author zubair;	state Exp;
branches;
next	1.1;

1.1
date	2004.08.17.15.43.58;	author zubair;	state Exp;
branches;
next	;

1.30.12.1
date	2006.07.26.05.05.21;	author dquigley;	state Exp;
branches;
next	;


desc
@@


1.31
log
@* ALL: Use /bin/bash instead of /bin/sh as we use a number of bashisms
@
text
@#!/bin/bash
#vim:filetype=sh
#vim:shiftwidth=8

set -e
echo -n "$0: "

if [ -z "$MOUNTPOINT" ] ; then
	MOUNTPOINT=/mnt/unionfs
fi
if [ -z "$LOWER_DIR" ] ; then
	LOWER_DIR=/n/lower
fi
if [ -z "$NFS" ] ; then
	NFS=
fi
if [ -z "$DEBUG" ] ; then
	DEBUG=0
fi
MOUNTS=0

function roloopify {
	local DIR=$1
	if [ ! -d "$DIR" ] ; then
		echo "Can not find $DIR" 1>&2
		return 1
	fi
	mkisofs -quiet -o /tmp/$$.iso -JR $DIR
	mount -o loop,ro /tmp/$$.iso $DIR
#	rm -f /tmp/$$.iso
	echo "Inspect"
	read N
	return 0
}

function havechattr {
	local FILE=tmp.chattr.check
	if [ ! -d $1 ] ; then
		return 1
	fi
	touch $1/$FILE
	if ! chattr +i $1/$FILE >/dev/null 2>&1 ; then
		rm -f $1/$FILE
		return 1
	fi
	if (echo "Hello World" > $1/$FILE) >/dev/null 2>&1 ; then
		chattr -i $1/$FILE >/dev/null 2>&1
		rm -f $1/$FILE
		return 1
	fi
	chattr -i $1/$FILE
	rm -f $1/$FILE
	return 0
}

function create_hierarchy {
	touch $LOWER_DIR/f
	if havechattr $LOWER_DIR ; then
		chattr -R -i $LOWER_DIR/*
	fi
        rm -rf $LOWER_DIR/*

        while read LINE
        do
                if [ "$LINE" = "" ] ; then
                    continue
                fi
                TYPE=`echo $LINE | cut -d' ' -f 1`
                NAME=`echo $LINE | cut -d' ' -f 2`

		unset DIR FILE IMMUTABLE SOURCE	SYMLINK

		( echo $TYPE | grep -q d ) && DIR=1
		( echo $TYPE | grep -q f ) && FILE=1
		( echo $TYPE | grep -q i ) && IMMUTABLE=1
		( echo $TYPE | grep -q s ) && SOURCE=1
		( echo $TYPE | grep -q l ) && SYMLINK=1

		if [ ! -z "$SOURCE" ] ; then
			if [ ! -z "$DIR" ] ; then
				echo "BAD TYPE (rename sources cannot be directories): $TYPE" 1>&2
				exit 1
			fi
			FILE=1
		fi

		if [ ! -z "$IMMUTABLE" ] ; then
			if [ -z "$DIR" -a -z "$SYMLINK" ] ; then
				FILE=1
			fi
		fi

		if [ ! -z "$DIR" -a ! -z "$FILE" ] ; then
			echo "BAD TYPE (both a file and directory) : $TYPE" 1>&2
			exit 1
		fi
		if [ ! -z "$DIR" -a ! -z "$SYMLINK" ] ; then
			echo "BAD TYPE (both a symbolic link and directory) : $TYPE" 1>&2
			exit 1
		fi
		if [ ! -z "$FILE" -a ! -z "$SYMLINK" ] ; then
			echo "BAD TYPE (both a symbolic link and a file) : $TYPE" 1>&2
			exit 1
		fi


		if [ ! -z "$DIR" -a ! -z "$SOURCE" ] ; then
			echo "Directories can not be sources: $TYPE" 1>&2
			exit 1
		fi

		if [ ! -z "$SYMLINK" -a ! -z "$SOURCE" ] ; then
			echo "Symbolic links can not be sources: $TYPE" 1>&2
			exit 1
		fi

                if [ ! -z "$DIR" ] ; then
                        mkdir -p $NAME
                elif [ ! -z "$FILE" ] ; then
                        mkdir -p `dirname $NAME` || exit $?
			if [ ! -z "$SOURCE" ] ; then
				echo "Source file." > $NAME || exit $?
			else
				echo $NAME > $NAME || exit $?
			fi
                elif [ ! -z "$SYMLINK" ] ; then
			ln -s "linktext:$NAME" $NAME
		else
			echo "What type am i: $TYPE" 1>&2
			exit $?
		fi

                if [ ! -z "$IMMUTABLE" ] ; then
			chattr +i $NAME || exit $?
		fi
        done
}

function check_hierarchy {
        ( find $1 -type d -printf 'd %p\n' ; find $1 -type f -printf 'f %p\n' ; find $1 -type b -printf 'b %p\n' ; find $1 -type c -printf 'c %p\n' ; find $1 -type l -printf 'l %p\n') | sort > /tmp/check-$$
        grep -v '^$' | sort | diff -u - /tmp/check-$$
        ERR=$?
        rm -f /tmp/check-$$
        return $ERR
}

function mount_union {
	if [ "$MOUNTS" -gt 0 ] ; then
		echo "There is already an outstanding mount!" 1>&2
		exit 1
	fi

        if [ -z "$1" ] ; then
                OPTION="debug=$DEBUG,dirs="
        else
                OPTION="$1,debug=$DEBUG,dirs="
        fi

        shift

        while [ "$#" -gt 0 ]
        do
                OPTION="$OPTION$1"
                if [ "$#" -ne "1" ] ; then
                        OPTION="$OPTION"":"
                fi
                shift
        done

        mount -t unionfs -o $OPTION none $MOUNTPOINT

	MOUNTS=$((MOUNTS + 1))

        return $?
}

function unmount_union {
	umount $MOUNTPOINT
	ERR=$?
	if [ "$?" -eq "0" ] ; then
		MOUNTS=$((MOUNTS - 1))
	else
		echo "Could not unmount $MOUNTPOINT" 1>&2
		exit 1
	fi
	return $ERR
}

function checktype {
    local F=$1
    local CHECK=$2

    local ERR=
    if [ "$CHECK" = "-" ] ; then
        [ ! -e "$F" ] || ERR=$?
    elif [ "$CHECK" = "f" ] ; then
        [ -f "$F" ] || ERR=$?
    elif [ "$CHECK" = "d" ] ; then
        [ -d "$F" ] || ERR=$?
    elif [ "$CHECK" = "b" ] ; then
        [ -b "$F" ] || ERR=$?
    elif [ "$CHECK" = "c" ] ; then
        [ -c "$F" ] || ERR=$?
    elif [ "$CHECK" = "l" ] ; then
        [ -l "$F" ] || ERR=$?
    else
        echo "Unknown check '$CHECK'" 1>&2
        /bin/false
    fi
    local SERR=$?
    if [ -z "$ERR" ] ; then
	ERR=$SERR
    fi

    if [ "$ERR" != "0" ] ; then
        echo "$F doesn't match '$CHECK'" 1>&2
        ls -ld $F 1>&2
    fi

    return $ERR
}

function checkperms {
	local F=$1
	local CHECK=$2

	local PERMS=`find "$1" -printf %m`

	if [ "$PERMS" != "$CHECK" ] ; then
		echo "$F permissions $PERMS doesn't match '$CHECK'" 1>&2
		ls -ld $F 1>&2
		return 1
	fi

	return 0
}

function shouldfail {
	if $* 2>/tmp/saveout-$$ ; then
		echo "UNWANTED SUCCESS: " $*
		cat /tmp/saveout-$$
		return 1
	fi
	rm -f /tmp/saveout-$$
	return 0
}

function complete_test {
	if [ "$MOUNTS" -gt 0 ] ; then
		echo "There is a leftover mount!" 1>&2
		exit 1
	fi
	if [ -f complete.sh ] ; then
		COMPLETE=1
		source complete.sh
	fi
	echo "OK"
	exit 0
}

function start_test {
	if [ -f start.sh ] ; then
		START=1
		source start.sh
		START=
	fi
}

start_test
@


1.30
log
@* unlink.c (unionfs_rmdir_all): Always create whiteouts on directory
removal.
@
text
@d1 1
a1 1
#!/bin/sh
@


1.30.12.1
log
@* Everything: Removed all debug code and references
to debug in parsing and in the regession suite.
@
text
@d17 3
d154 1
a154 1
                OPTION=",dirs="
d156 1
a156 1
                OPTION="$1,dirs="
@


1.29
log
@* scaffold: touch will return 0 on an immutable file so the
test in havechattr will be done with echo now
@
text
@d22 14
@


1.28
log
@* inode.c (unionfs_link): Copy directory attrs to directory (BUG391).
Unfortunately, regression test doesn't quite catch the bug because of a
revalidate for the stat.
* commit: Don't complain about .sh file's indentation.
@
text
@d32 1
a32 1
	if touch $1/$FILE 2>/dev/null ; then
@


1.27
log
@Quiet up havechattr more.
@
text
@d33 1
a33 1
		chattr -i $1/$FILE
@


1.26
log
@Fix havechattr
@
text
@d28 1
a28 1
	if ! chattr +i $1/$FILE 2>/dev/null ; then
@


1.25
log
@* Detect working chattr so we can run tests on reiser.
@
text
@d28 1
a28 1
	if ! chattr +i $1/$FILE ; then
@


1.24
log
@* scaffold (checkperms): Permissions checking function.
* create.sh (BUG383): Test for BUG383.
@
text
@d22 20
d44 1
a44 1
	if [ -z "$NFS" ] ; then
d120 1
a120 3
			if [ -z "$NFS" ] ; then
				chattr +i $NAME || exit $?
			fi
@


1.23
log
@* link.sh, unlink-all.sh: Make it easier to run a subset of tests.
* flock.sh: Use complete_test.
@
text
@d191 15
@


1.22
log
@* scaffold: Make sure unmount is executed for each mount.
@
text
@d207 1
d216 1
d218 1
@


1.21
log
@* flock.sh: Test for bug 360.
@
text
@d20 1
d116 5
d131 1
a131 1
                OPTION="$OPTION$1" 
d138 3
a140 1
        mount -t unionfs -o $OPTION none $MOUNTPOINT 
d146 9
a154 2
    umount $MOUNTPOINT 
    return $?
d156 1
d200 20
@


1.20
log
@* all files : now the files can be used for testing
unionfs over NFS as well
@
text
@d8 11
a18 6
MOUNTPOINT=/mnt/unionfs
LOWER_DIR=/n/lower
if [ ! -z "$NFS" ] ; then
#{
	LOWER_DIR=$NFS_DIR
#}
a19 1
DEBUG=0
@


1.19
log
@* all files : introduced a variable to set the lower-level
directory. introduced a variable that will later help
test NFS in future (this does not test it completelt now).
@
text
@d10 5
a14 1
NFS=""
@


1.18
log
@* branchman.sh: Branch removal using new unionctl remount.
@
text
@d9 2
d14 5
a18 3
	touch /n/lower/f
	chattr -R -i /n/lower/*
        rm -rf /n/lower/*
d91 3
a93 1
			chattr +i $NAME || exit $?
@


1.17
log
@* open.sh: Test directory-none-directory open.
@
text
@d12 1
@


1.16
log
@* scaffold: Behave slightly better when chattr -i'ing the tree.
* Makefile: Die on a failed test.
* progs/open-unlink.c: Fix a comment typo.
@
text
@a67 1
		
a72 1
                        echo $NAME > $NAME || exit $?
d74 3
a76 3
                        	echo "Source file." > $NAME || exit $?
			else 
                        	echo $NAME > $NAME || exit $?
d84 1
a84 1
	
@


1.15
log
@* scaffold: Remove checkfile_after_remove and checkfile_after_create
as checktype does the same thing.
* unlink-all.sh: Check type of files after removal.
* unlink-whiteout.sh: Update results of tests and test rw symlink.
@
text
@d12 1
a12 1
	chattr -R -i /n/lower
@


1.14
log
@* scaffold: Add symlink support.
* unlink-whiteout.sh: Add symlink tests (currently broken).
@
text
@a127 20



function checkfile_after_remove {
    if [ -e "$1" ] ; then
        echo "$1 still exists after trying to unlink!"
        return 1
    fi
    return 0
}


function checkfile_after_create {
    if [ ! -e "$1" ] ; then
        echo "$1 does not exist after trying to create it!"
        return 1
    fi
    return 0
}

d129 2
a130 2
    F=$1
    CHECK=$2
d132 1
d134 1
a134 1
        [ ! -e "$F" ]
d136 1
a136 1
        [ -f "$F" ] 
d138 1
a138 1
        [ -d "$F" ]
d140 1
a140 1
        [ -b "$F" ]
d142 1
a142 1
        [ -c "$F" ]
d144 1
a144 1
        [ -l "$F" ]
d149 4
a152 1
    ERR=$?
@


1.13
log
@* symlink.sh: readlink to make sure that it worked, and check the hierarchy

* *.sh: Use set -e, so we don't need to do || exit $?
* scaffold: Support checking devices.
* mknod.sh: Make sure the devices are created and check the results!
@
text
@d23 1
a23 1
		unset DIR FILE IMMUTABLE SOURCE	
d29 1
d40 1
a40 1
			if [ -z "$DIR" ] ; then
d49 8
d63 5
d80 2
@


1.12
log
@mkdir.sh updated with rest of tests
@
text
@d5 1
d78 1
a78 1
        ( find $1 -type d -printf 'd %p\n' ; find $1 -type f -printf 'f %p\n' ) | sort > /tmp/check-$$
d118 1
a118 1
        return $?
d120 1
d127 1
a127 1
        return $?
d129 1
d142 6
@


1.11
log
@* rename-whiteout.sh: Test rename-whiteout.
@
text
@d12 1
a12 1
        rm -rf /n/lower
@


1.10
log
@unionfs_link tested according to testplan and with mix of rw and ro branches
@
text
@d8 1
a8 1
DEBUG=17
d21 35
a55 1
                if [ "$TYPE" = "d" ] ; then
d57 1
a57 7
                elif [ "$TYPE" = "f" ] ; then
                        mkdir -p `dirname $NAME` || exit $?
                        echo $NAME > $NAME || exit $?
                elif [ "$TYPE" = "s" ] ; then
                        mkdir -p `dirname $NAME` || exit $?
                        echo "Source file." > $NAME || exit $?
                elif [ "$TYPE" = "i" ] ; then
d60 11
d72 1
a72 4
                else 
                        echo "Unknown type: '$TYPE' (name is '$NAME')" 1>&2 
                        exit 1
                fi
d155 1
@


1.9
log
@Fix unlink-all tests for immutable file.
@
text
@d44 1
a44 1
    #    rm -f /tmp/check-$$
@


1.8
log
@Read only and Immutable rename tests (which pass).
@
text
@d5 2
@


1.7
log
@Read-Write results (it even passes).
@
text
@d24 3
d113 9
@


1.6
log
@Rename-all test plan, but not the tests.
@
text
@d6 1
d45 1
a45 1
                OPTION="dirs="
d47 1
a47 1
                OPTION="$1,dirs="
@


1.5
log
@rmdir tested in delete_all mode with rw and ro branches. Also tested creating back removed directories
@
text
@d22 1
a22 1
                        touch $NAME || exit $?
d25 1
a25 1
                        touch $NAME || exit $?
@


1.4
log
@after unlinking files in whiteout mode, create them back
@
text
@d72 1
a72 1
function checkfile_unlink {
d80 1
a80 1
function checkfile_touch {
@


1.3
log
@2004-08-17  Charles P. Wright <cwright@@fsl.cs.sunysb.edu>

	* testplan: symlink, link, truncate, times, and mknod were left out
		A detailed mknod plan example is included
	* unlink.sh: Test recursive whiteout creation and an error in the
		middle
	* scaffold: Create immutable files with 'i' instead of 'f'
@
text
@d70 17
@


1.2
log
@description of scripts that will test unionfs
@
text
@d8 1
d23 4
@


1.1
log
@Lookup tests.
@
text
@d30 1
a30 2
        ( find $1 -type d -printf 'd %p\n' ;
        find $1 -type f -printf 'f %p\n' ) |sort >/tmp/check-$$
d33 1
a33 1
        rm -f /tmp/check-$$
d61 2
a62 2
        umount $MOUNTPOINT
        return $?
@

