]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
source3:tests: Fix all shellcheck errors found in test_net_tdb.sh
authorAndreas Schneider <asn@samba.org>
Fri, 14 Nov 2025 08:20:21 +0000 (09:20 +0100)
committerMartin Schwenke <martins@samba.org>
Thu, 15 Jan 2026 06:58:35 +0000 (06:58 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/script/tests/test_net_tdb.sh

index abc8786150327c0da0f6477a55f89176160ab727..92847ad522acc77550c0f1a79f821279dde4d29a 100755 (executable)
@@ -28,27 +28,28 @@ LOCKDIR=$8
 FILENAME=net_tdb_testfile
 
 samba_tdbtool=tdbtool
-if test -x $BINDIR/tdbtool; then
-       samba_tdbtool=$BINDIR/tdbtool
+if test -x "$BINDIR/tdbtool"; then
+       samba_tdbtool="$BINDIR/tdbtool"
 fi
 
 failed=0
 
-incdir=$(dirname $0)/../../../testprogs/blackbox
-. $incdir/subunit.sh
+incdir=$(dirname "$0")/../../../testprogs/blackbox
+# shellcheck source=testprogs/blackbox/subunit.sh
+. "$incdir/subunit.sh"
 
-touch $LOCALPATH/$FILENAME
+touch "$LOCALPATH/$FILENAME"
 
 printf "open %s\n"'!sleep 10'"\n" ${FILENAME} |
-       $SMBCLIENT //$SERVER/$SHARE -U$USER%$PASS &
+       "$SMBCLIENT" "//$SERVER/$SHARE" -U"$USER%$PASS" &
 SMBCLIENTPID=$!
 
 # Give smbclient a chance to open the file
 sleep 1
 
 testit "Looking for record key of open file" \
-       $samba_tdbtool $LOCKDIR/locking.tdb hexkeys ||
-       failed=$(expr $failed + 1)
+       "$samba_tdbtool" "$LOCKDIR/locking.tdb" hexkeys ||
+       failed=$((failed + 1))
 
 # The assumption here is that only one file is open, so only one
 # record can exist in the database.
@@ -57,48 +58,48 @@ testit "Looking for record key of open file" \
 #[000] 01 FD 00 00 00 00 00 00  56 02 5C 00 00 00 00 00  ....... V.\....
 #[010] 00 00 00 00 00 00 00 00                           .......
 # Select only the hex data, remove space and join every thing together
-key=0x$($samba_tdbtool $LOCKDIR/locking.tdb hexkeys |
+key=0x$("$samba_tdbtool" "$LOCKDIR/locking.tdb" hexkeys |
        grep '\[' | cut -c 7-56 | sed -e 's/ //g' | tr -d '\n')
 
 testit "Looking for open file in locking.tdb" \
-       $BINDIR/net $CONFIGURATION tdb locking $key ||
-       failed=$(expr $failed + 1)
-out=$($BINDIR/net $CONFIGURATION tdb locking $key)
+       "$BINDIR/net" "$CONFIGURATION" tdb locking "$key" ||
+       failed=$((failed + 1))
+out=$("$BINDIR/net" "$CONFIGURATION" tdb locking "$key")
 
-out=$($BINDIR/net $CONFIGURATION tdb locking $key |
+out=$("$BINDIR/net" "$CONFIGURATION" tdb locking "$key" |
        grep 'Share path: ' | sed -e 's/Share path: \+//')
 testit "Verify pathname in output" \
        test "$out" = "$LOCALPATH" ||
-       failed=$(expr $failed + 1)
+       failed=$((failed + 1))
 
-out=$($BINDIR/net $CONFIGURATION tdb locking $key |
+out=$("$BINDIR/net" "$CONFIGURATION" tdb locking "$key" |
        grep 'Name:' | sed -e 's/Name: \+//')
 testit "Verify filename in output" \
        test "$out" = "$FILENAME" ||
-       failed=$(expr $failed + 1)
+       failed=$((failed + 1))
 
-out=$($BINDIR/net $CONFIGURATION tdb locking $key |
+out=$("$BINDIR/net" "$CONFIGURATION" tdb locking "$key" |
        grep 'Number of share modes:' |
        sed -e 's/Number of share modes: \+//')
 testit "Verify number of share modes in output" \
        test "$out" = "1" ||
-       failed=$(expr $failed + 1)
+       failed=$((failed + 1))
 
 testit "Complete record dump" \
-       $BINDIR/net $CONFIGURATION tdb locking $key dump ||
-       failed=$(expr $failed + 1)
+       "$BINDIR/net" "$CONFIGURATION" tdb locking "$key" dump ||
+       failed=$((failed + 1))
 
-$BINDIR/net $CONFIGURATION tdb locking $key dump | grep -q $FILENAME
+"$BINDIR/net" "$CONFIGURATION" tdb locking "$key" dump | grep -q "$FILENAME"
 RC=$?
 testit "Verify filename in dump output" \
        test $RC = 0 ||
-       failed=$(expr $failed + 1)
-$BINDIR/net $CONFIGURATION tdb locking $key dump | grep -q $LOCALPATH
+       failed=$((failed + 1))
+"$BINDIR/net" "$CONFIGURATION" tdb locking "$key" dump | grep -q "$LOCALPATH"
 RC=$?
 testit "Verify share path in dump output" \
        test $RC = 0 ||
-       failed=$(expr $failed + 1)
+       failed=$((failed + 1))
 
 kill $SMBCLIENTPID
 
-testok $0 $failed
+testok "$0" "$failed"