CI: add a test for async dosmode on a file in a shadow_copy2 snapshot
authorRalph Boehme <slow@samba.org>
Wed, 23 Feb 2022 17:10:59 +0000 (18:10 +0100)
committerJule Anger <janger@samba.org>
Tue, 29 Mar 2022 09:07:11 +0000 (09:07 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 1097b1d0776661d873861672ca38e5892014725d)

source3/script/tests/test_shadow_copy_torture.sh

index e5dc0192e95d4c8573d3a662f3ff00914cd45a36..4ae2f9f707f7bb44847d892f3c683735e363c676 100755 (executable)
@@ -150,6 +150,47 @@ test_shadow_copy_fix_inodes()
     echo $out | grep "hardlink: for read/write fnum 1" || return 1
 }
 
+build_hiddenfile()
+{
+    local snapdir
+
+    snapdir=$WORKDIR/.snapshots
+
+    #delete snapshots from previous tests
+    find $WORKDIR -name ".snapshots" -exec rm -rf {} \; 1>/dev/null 2>&1
+    build_snapshots
+
+    touch $WORKDIR/hiddenfile
+
+    # Create a file with hidden attribute
+    $SMBCLIENT -U $USERNAME%$PASSWORD \
+              "//$SERVER/shadow_write" \
+              -c "put $WORKDIR/hiddenfile hiddenfile; setmode hiddenfile +h"
+    # ...and move it to the snapshot directory
+    mv $WORKDIR/hiddenfile $snapdir/$SNAPSHOT/
+}
+
+test_hiddenfile()
+{
+    build_hiddenfile
+
+    out=$($SMBCLIENT \
+          -U $USERNAME%$PASSWORD \
+          "//$SERVER/shadow_write" \
+          -c "allinfo $SNAPSHOT/hiddenfile") || return 1
+    echo $out
+    echo $out | grep "attributes: HA (22)" || return 1
+
+    out=$($SMBCLIENT \
+          -U $USERNAME%$PASSWORD \
+          "//$SERVER/shadow_write" \
+          -c "ls $SNAPSHOT/hiddenfile") || return 1
+    echo $out
+    echo $out | grep "hiddenfile[[:blank:]]*AH" || return 1
+
+    return 0
+}
+
 build_files $WORKDIR
 
 # test open for writing and write behaviour of snapshoted files
@@ -161,4 +202,6 @@ test_shadow_copy_openroot "opening root of shadow copy share"
 
 testit "fix inodes with hardlink" test_shadow_copy_fix_inodes || failed=`expr $failed + 1`
 
+testit "Test reading DOS attribute" test_hiddenfile || failed=`expr $failed + 1`
+
 exit $failed