From: Pavel Filipenský Date: Sun, 26 Oct 2025 20:01:40 +0000 (+0100) Subject: selftest: Add a test for recycle:touch,touch_mtime,keeptree X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=498984cf346630c17169dbdb13a232854309f6a8;p=thirdparty%2Fsamba.git selftest: Add a test for recycle:touch,touch_mtime,keeptree BUG: https://bugzilla.samba.org/show_bug.cgi?id=15940 Signed-off-by: Pavel Filipenský Reviewed-by: Andreas Schneider --- diff --git a/selftest/knownfail b/selftest/knownfail index ab2d79d7114..717a2576e63 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -5,6 +5,7 @@ # a successful run for any of these tests an error. ^samba3.blackbox.failure.failure # this is designed to fail, for testing our test infrastructure +^samba3.blackbox.recycle.recycle_touch # recycle:touch_mtime is not working .*driver.add_driver_timestamps # we only can store dates, not timestamps ^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-REAUTH # expected to give ACCESS_DENIED SMB2.1 doesn't have encryption ^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-RECONNECT # expected to give CONNECTION_DISCONNECTED, we need to fix the test diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 6ea64ff3525..6f17d659d96 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -3718,6 +3718,9 @@ sub provision($$) path = $recycle_shrdir vfs objects = recycle recycle : repository = .trash + recycle : keeptree = yes + recycle : touch = yes + recycle : touch_mtime = yes recycle : exclude = *.tmp recycle : directory_mode = 755 diff --git a/source3/script/tests/test_recycle.sh b/source3/script/tests/test_recycle.sh index 779683f4822..9f98841bd32 100755 --- a/source3/script/tests/test_recycle.sh +++ b/source3/script/tests/test_recycle.sh @@ -42,6 +42,7 @@ do_cleanup() cd "$share_test_dir" || return rm -f testfile1 rm -f testfile2.tmp + rm -f test_mtime rm -rf .trash ) ( @@ -117,6 +118,38 @@ quit return 0 } +test_touch() +{ + tmpfile=$PREFIX/test_mtime + touch "$tmpfile" + if ! $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/recycle -I$SERVER_IP $ADDARGS -c "put $tmpfile test_mtime" ; then + printf "failed recycle smbclient" + return 1 + fi + rm -f "$tmpfile" + atime1=`stat -c '%x' "$share_test_dir/test_mtime"` + mtime1=`stat -c '%y' "$share_test_dir/test_mtime"` + if ! $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/recycle -I$SERVER_IP $ADDARGS -c 'del test_mtime' ; then + printf "failed recycle smbclient" + return 1 + fi + test -e "$share_test_dir/.trash/test_mtime" || { + printf ".trash/test_mtime expected to exist but does NOT exist\n" + return 1 + } + atime2=`stat -c '%x' "$share_test_dir/.trash/test_mtime"` + mtime2=`stat -c '%y' "$share_test_dir/.trash/test_mtime"` + test "$atime1" != "$atime2" || { + printf "recycle:touch failed: atime should differ: $atime1, $atime2\n" + return 1 + } + test "$mtime1" != "$mtime2" || { + printf "recycle:touch_mtime failed: mtime should differ: $mtime1, $mtime2\n" + return 1 + } + return 0 +} + test_recycle_crossrename() { tmpfile=$PREFIX/smbclient_interactive_prompt_commands @@ -168,6 +201,10 @@ testit "recycle" \ test_recycle || failed=$((failed + 1)) +testit "recycle_touch" \ + test_touch || + failed=$((failed + 1)) + testit "recycle_crossrename" \ test_recycle_crossrename || failed=$((failed + 1))