From d79485a566e3c59ce53c3ee205aa6c78f149f5d8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 24 Jan 2013 12:33:53 -0800 Subject: [PATCH] Regression test for bug #9587 - archive flag is always set on directories. Ensure we get the correct attributes on files and directories after a rename. Signed-off-by: Jeremy Allison Reviewed-by: David Disseldorp Autobuild-User(master): David Disseldorp Autobuild-Date(master): Fri Jan 25 13:42:40 CET 2013 on sn-devel-104 --- source3/script/tests/test_smbclient_s3.sh | 186 ++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index b240da07696..596cd425ff9 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -409,6 +409,187 @@ EOF fi } +# Archive bits are correctly set on file/dir creation and rename. +test_rename_archive_bit() +{ + prompt_file="attributes: A (20)" + prompt_dir="attributes: D (10)" + tmpfile="$PREFIX/smbclient.in.$$" + filename="foo.$$" + filename_ren="bar.$$" + dirname="foodir.$$" + dirname_ren="bardir.$$" + filename_path="$PREFIX/$filename" + local_name1="$LOCAL_PATH/$filename" + local_name2="$LOCAL_PATH/$filename_ren" + local_dir_name1="$LOCAL_PATH/$dirname" + local_dir_name2="$LOCAL_PATH/$dirname_ren" + + rm -f $filename_path + rm -f $local_name1 + rm -f $local_name2 + +# Create a new file, ensure it has 'A' attributes. + touch $filename_path + + cat > $tmpfile </dev/null 2>&1 + + ret=$? + + rm -f $filename_path + rm -f $local_name1 + rm -f $local_name2 + + if [ $ret = 0 ] ; then + # got the correct prompt .. succeed + true + else + echo "$out" + echo "Attributes incorrect on new file $ret" + false + fi + +# Now check if we remove 'A' and rename, the A comes back. + touch $filename_path + + cat > $tmpfile </dev/null 2>&1 + + ret=$? + + rm -f $filename_path + rm -f $local_name1 + rm -f $local_name2 + + if [ $ret = 0 ] ; then + # got the correct prompt .. succeed + true + else + echo "$out" + echo "Attributes incorrect on renamed file $ret" + false + fi + + rm -rf $local_dir_name1 + rm -rf $local_dir_name2 + +# Create a new directory, ensure it has 'D' but not 'A' attributes. + + cat > $tmpfile </dev/null 2>&1 + + ret=$? + + rm -rf $local_dir_name1 + rm -rf $local_dir_name2 + + if [ $ret = 0 ] ; then + # got the correct prompt .. succeed + true + else + echo "$out" + echo "Attributes incorrect on new directory $ret" + false + fi + +# Now check if we rename, we still only have 'D' attributes + + cat > $tmpfile </dev/null 2>&1 + + ret=$? + + rm -f $local_name1 + rm -f $local_name2 + + if [ $ret = 0 ] ; then + # got the correct prompt .. succeed + true + else + echo "$out" + echo "Attributes incorrect on renamed directory $ret" + false + fi +} + # Test authenticating using the winbind ccache test_ccache_access() { @@ -541,6 +722,7 @@ EOF fi } + LOGDIR_PREFIX=test_smbclient_s3 # possibly remove old logdirs: @@ -596,6 +778,10 @@ testit "Accessing an MS-DFS link" \ test_msdfs_link || \ failed=`expr $failed + 1` +testit "Ensure archive bit is set correctly on file/dir rename" \ + test_rename_archive_bit || \ + failed=`expr $failed + 1` + testit "ccache access works for smbclient" \ test_ccache_access || \ failed=`expr $failed + 1` -- 2.11.4.GIT