xref: /illumos-gate/usr/src/test/smbsrv-tests/tests/smbtorture/runst-rpc.ksh (revision 1b38ec66a3ea040587c1b346f8c010a3b37c8080)
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-rpc.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 || fail "Could not cd to $outdir"
55
56tstamp=$(date +'%Y%m%dT%H%M%S')
57logfile=$outdir/smbtor-rpc-${tstamp}.log
58outfile=$outdir/smbtor-rpc-${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 rpc"
67fi
68for m
69do
70    match="$match -m $m"
71done
72
73#It would be nice to have a generic 'Can I connect to this server/share?' test
74$SMBTOR -U "$SMBT_USER%${SMBT_PASS}" //$SMBT_HOST/IPC\$	\
75    rpc.wkssvc.wkssvc.NetWkstaGetInfo > /dev/null 2>&1 || \
76    fail "Cannot connect to //$SMBT_HOST/IPC\$"
77
78echo "Running smbtorture/RPC tests with //$SMBT_HOST/IPC\$"
79$runsmbtor $match -e $excl_file -o $logfile $timeout \
80    "$SMBT_HOST" "IPC\$" "$SMBT_USER" "${SMBT_PASS}" |
81     tee $outfile
82
83exit 0
84