xref: /illumos-gate/usr/src/test/smbsrv-tests/tests/smbtorture/runst-smb2.ksh (revision 3f6fd99d844f7d4b62e4e1ddb0c29a4c2f7eca15)
1#!/usr/bin/ksh
2
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source.  A copy of the CDDL is also available via the Internet at
11# http://www.illumos.org/license/CDDL.
12#
13
14#
15# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
16#
17
18export SMBSRV_TESTS="/opt/smbsrv-tests"
19export SMBTOR="/usr/bin/smbtorture"
20
21runsmbtor=$SMBSRV_TESTS/bin/run_smbtorture
22excl_file=$SMBSRV_TESTS/include/smbtor-excl-smb2.txt
23
24cfgfile=${CFGFILE:-$SMBSRV_TESTS/include/default.cfg}
25outdir=${OUTDIR:-/var/tmp/test_results/smbsrv-tests}
26
27function fail
28{
29	echo $1
30	exit ${2:-1}
31}
32
33while getopts c:o:t: c; do
34	case $c in
35	'c')
36		cfgfile=$OPTARG
37		[[ -f $cfgfile ]] || fail "Cannot read file: $cfgfile"
38		;;
39	'o')
40		outdir=$OPTARG
41		;;
42	't')
43		timeout="-t $OPTARG"
44		;;
45	esac
46done
47shift $((OPTIND - 1))
48
49. $cfgfile
50
51export PATH="$(dirname $SMBTOR):$PATH"
52
53mkdir -p $outdir
54cd $outdir
55
56tstamp=$(date +'%Y%m%dT%H%M%S')
57logfile=$outdir/smbtor-smb2-${tstamp}.log
58outfile=$outdir/smbtor-smb2-${tstamp}.summary
59
60if [[ -z "$timeout" && -n "$TIMEOUT" ]]; then
61	timeout="-t $TIMEOUT"
62fi
63
64# Non-option args taken as list of match patterns
65if [ -z "$1" ] ; then
66    match="-m smb2"
67fi
68for m
69do
70    match="$match -m $m"
71done
72
73# Make sure we can connect, otherwise we'll report every test as failing.
74$SMBTOR -U "$SMBT_USER%${SMBT_PASS}" //$SMBT_HOST/$SMBT_SHARE smb2.dir.find \
75 > /dev/null 2>&1 || \
76    fail "Cannot connect to //$SMBT_HOST/$SMBT_SHARE"
77
78echo "Running smbtorture/smb2 tests with //$SMBT_HOST/$SMBT_SHARE"
79$runsmbtor $match -e $excl_file -o $logfile $timeout \
80    "$SMBT_HOST" "$SMBT_SHARE" "$SMBT_USER" "${SMBT_PASS}" |
81     tee $outfile
82
83exit 0
84