CI: add a test that checks the dosmode of symlinks
authorRalph Boehme <slow@samba.org>
Wed, 24 May 2023 11:13:19 +0000 (13:13 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 24 May 2023 20:41:38 +0000 (20:41 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15375

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/samba3.blackbox.test_symlink_dosmode [new file with mode: 0644]
source3/script/tests/test_symlink_dosmode.sh [new file with mode: 0755]
source3/selftest/tests.py

diff --git a/selftest/knownfail.d/samba3.blackbox.test_symlink_dosmode b/selftest/knownfail.d/samba3.blackbox.test_symlink_dosmode
new file mode 100644 (file)
index 0000000..93546ab
--- /dev/null
@@ -0,0 +1 @@
+^samba3.blackbox.test_symlink_dosmode.symlink_dosmode\(fileserver\)
diff --git a/source3/script/tests/test_symlink_dosmode.sh b/source3/script/tests/test_symlink_dosmode.sh
new file mode 100755 (executable)
index 0000000..dd6cb6b
--- /dev/null
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+if [ $# -lt 7 ]; then
+       cat <<EOF
+Usage: test_symlink_dosmode.sh SERVER SERVER_IP USERNAME PASSWORD LOCAL_PATH PREFIX SMBCLIENT
+EOF
+       exit 1
+fi
+
+SERVER="${1}"
+SERVER_IP="${2}"
+USERNAME="${3}"
+PASSWORD="${4}"
+LOCAL_PATH="${5}"
+PREFIX="${6}"
+SMBCLIENT="${7}"
+SMBCLIENT="$VALGRIND ${SMBCLIENT}"
+shift 6
+
+incdir=$(dirname "$0")/../../../testprogs/blackbox
+. "$incdir"/subunit.sh
+
+failed=0
+
+# Do not let deprecated option warnings muck this up
+SAMBA_DEPRECATED_SUPPRESS=1
+export SAMBA_DEPRECATED_SUPPRESS
+
+# Define the test environment/filenames.
+#
+share_test_dir="$LOCAL_PATH"
+
+rm -rf "$share_test_dir/testdir"
+
+mkdir -p "$share_test_dir/testdir/dir"
+touch "$share_test_dir/testdir/file"
+ln -s "../file" "$share_test_dir/testdir/dir/symlink"
+
+test_symlink_dosmode()
+{
+       tmpfile=$PREFIX/smbclient_interactive_prompt_commands
+       cat >"$tmpfile" <<EOF
+ls testdir/dir/*
+quit
+EOF
+       cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I$SERVER_IP < $tmpfile 2>&1'
+       eval echo "$cmd"
+       out=$(eval "$cmd")
+       ret=$?
+       rm -f "$tmpfile"
+
+       if [ $ret != 0 ]; then
+               printf "%s\n" "$out"
+               printf "failed accessing local_symlinks with error %s\n" "$ret"
+               return 1
+       fi
+
+       mode=$(printf "%s" "$out" | awk '/symlink/ {print $2}')
+       echo "mode: $mode"
+       if [ x"$mode" != x"N" ] ; then
+               printf "Bad mode: '%s', expected 'N'\n" "$mode"
+               printf "%s\n" "$out"
+               return 1
+       fi
+       return 0
+}
+
+testit "symlink_dosmode" \
+       test_symlink_dosmode ||
+       failed=$((failed + 1))
+
+rm -rf "$share_test_dir/testdir"
+
+testok "$0" "$failed"
index 55087f922c1d057a00ee0c026004c0c2e5604195..76bc90df1ad40facf36aac6d28dfd29383398b09 100755 (executable)
@@ -784,6 +784,10 @@ for env in ["fileserver"]:
                   [os.path.join(samba3srcdir, "script/tests/test_stream_dir_rename.sh"),
                   '$SERVER', '$USERNAME', '$PASSWORD', '$PREFIX', smbclient3])
 
+    plantestsuite("samba3.blackbox.test_symlink_dosmode", env,
+                  [os.path.join(samba3srcdir, "script/tests/test_symlink_dosmode.sh"),
+                  '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/local_symlinks',
+                  '$PREFIX', smbclient3])
     #
     # tar command tests
     #