shadow_copy: Add test for missing directory in "current" fileset
authorVolker Lendecke <vl@samba.org>
Thu, 28 Dec 2023 13:20:11 +0000 (14:20 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 2 Jan 2024 19:39:37 +0000 (19:39 +0000)
Right now we can't traverse a subdirectory in a snapshot which was
deleted in the current set of files.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15544

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/shadow_copy2 [new file with mode: 0644]
source3/script/tests/test_shadow_copy.sh

diff --git a/selftest/knownfail.d/shadow_copy2 b/selftest/knownfail.d/shadow_copy2
new file mode 100644 (file)
index 0000000..cb53e55
--- /dev/null
@@ -0,0 +1 @@
+^samba3.blackbox.shadow_copy2.*.fetch\ a\ file\ without\ a\ latest\ version.*
\ No newline at end of file
index b5726e4b83340369066c0557e841143ccf9aaaa5..3141df3568df38ac558fdf8efda17159c09514c3 100755 (executable)
@@ -389,6 +389,32 @@ test_shadow_copy_format()
         failed=`expr $failed + 1`
 }
 
+# Test fetching a file where there's no current version of it
+test_missing_basedir()
+{
+    local share
+    local where
+    local prefix
+    local snapidx
+
+    share=$1
+    where=$2
+    prefix=$3
+    snapidx=$4
+
+    #delete snapshots from previous tests
+    find $WORKDIR -name ".snapshots" -exec rm -rf {} \; 1>/dev/null 2>&1
+    build_snapshots $WORKDIR/$where "$prefix" "$snapidx" "$snapidx"
+
+    (cd "$WORKDIR/$where"/share; mv bar _bar)
+
+    testit "fetch a file without a latest version" \
+       test_fetch_snap_file "$share" "bar/baz" "$snapidx" || \
+       failed=`expr $failed + 1`
+
+    (cd "$WORKDIR/$where"/share; mv _bar bar)
+}
+
 #build "latest" files
 build_files $WORKDIR/mount base/share "latest" "latest"
 
@@ -423,5 +449,6 @@ test_shadow_copy_format shadow_fmt2 mount/base share 2 "shadow:format with some
 test_shadow_copy_format shadow_fmt3 mount/base share 2 "shadow:format with modified format"
 test_shadow_copy_format shadow_fmt4 mount/base share 3 "shadow:format with snapprefix"
 test_shadow_copy_format shadow_fmt5 mount/base share 6 "shadow:format with delimiter"
+test_missing_basedir shadow3 "mount/base" "share" 6
 
 exit $failed