]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
selftest: Add a test for recycle:touch,touch_mtime,keeptree
authorPavel Filipenský <pfilipensky@samba.org>
Sun, 26 Oct 2025 20:01:40 +0000 (21:01 +0100)
committerJule Anger <janger@samba.org>
Wed, 5 Nov 2025 09:05:09 +0000 (09:05 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15940

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 498984cf346630c17169dbdb13a232854309f6a8)

selftest/knownfail
selftest/target/Samba3.pm
source3/script/tests/test_recycle.sh

index ab2d79d7114edb6ee29eafd4ef5e4ce84921471b..717a2576e633a2bbd347b5ef84989c6df34a94fd 100644 (file)
@@ -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
index 60f7a9a546a00a3aab21a5993ec63747f80bbbc7..b61e5d6a855675267b6cf207b8e4e6a73e079ac6 100755 (executable)
@@ -3722,6 +3722,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
 
index 779683f4822fda6d289d58192e4e276316968487..9f98841bd32011d3751cdec30833d4145135794d 100755 (executable)
@@ -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))