diff options
-rw-r--r-- | exception_lists/packaging.deps | 1 | ||||
-rw-r--r-- | usr/src/pkg/manifests/system-test-smbsrvtest.p5m | 33 | ||||
-rw-r--r-- | usr/src/test/Makefile | 3 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/Makefile | 20 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/Makefile.com | 69 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/cmd/Makefile | 26 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/cmd/run_smbtorture.py | 244 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/cmd/smbsrvtests.ksh | 55 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/doc/Makefile | 36 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/doc/README | 84 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/include/Makefile | 21 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/include/default.cfg | 23 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/include/smbtor-excl-smb2.txt | 33 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/tests/Makefile | 17 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/tests/smbtorture/Makefile | 22 | ||||
-rw-r--r-- | usr/src/test/smbsrv-tests/tests/smbtorture/runst-smb2.ksh | 83 | ||||
-rwxr-xr-x | usr/src/tools/quick/make-smbsrv | 19 |
17 files changed, 786 insertions, 3 deletions
diff --git a/exception_lists/packaging.deps b/exception_lists/packaging.deps index b15092247f..665550c048 100644 --- a/exception_lists/packaging.deps +++ b/exception_lists/packaging.deps @@ -29,6 +29,7 @@ pkg:/runtime/java/openjdk11 pkg:/runtime/java/openjdk8 pkg:/runtime/java/runtime64 pkg:/security/sudo +pkg:/service/network/samba pkg:/shell/bash pkg:/shell/expect pkg:/system/bhyve/firmware diff --git a/usr/src/pkg/manifests/system-test-smbsrvtest.p5m b/usr/src/pkg/manifests/system-test-smbsrvtest.p5m new file mode 100644 index 0000000000..cfcf885aeb --- /dev/null +++ b/usr/src/pkg/manifests/system-test-smbsrvtest.p5m @@ -0,0 +1,33 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. + +set name=pkg.fmri value=pkg:/system/test/smbsrvtest@$(PKGVERS) +set name=pkg.summary value="SMB Server Functional Tests" +set name=pkg.description value="SMB Server Test Suite" +set name=info.classification \ + value=org.opensolaris.category.2008:Development/System +set name=variant.arch value=$(ARCH) +dir path=opt/smbsrv-tests +file path=opt/smbsrv-tests/README mode=0444 +dir path=opt/smbsrv-tests/bin +file path=opt/smbsrv-tests/bin/run_smbtorture mode=0555 +file path=opt/smbsrv-tests/bin/smbsrvtests mode=0555 +dir path=opt/smbsrv-tests/include +file path=opt/smbsrv-tests/include/default.cfg mode=0444 +file path=opt/smbsrv-tests/include/smbtor-excl-smb2.txt mode=0444 +dir path=opt/smbsrv-tests/tests +dir path=opt/smbsrv-tests/tests/smbtorture +file path=opt/smbsrv-tests/tests/smbtorture/runst-smb2 mode=0555 +license lic_CDDL license=lic_CDDL +depend type=optional fmri=service/network/samba +depend type=require fmri=runtime/python$(PYTHON3_PKGVERS) diff --git a/usr/src/test/Makefile b/usr/src/test/Makefile index 90c0c40487..c951638a63 100644 --- a/usr/src/test/Makefile +++ b/usr/src/test/Makefile @@ -13,7 +13,7 @@ # Copyright (c) 2012 by Delphix. All rights reserved. # Copyright 2014 Garrett D'Amore <garrett@damore.org> # Copyright 2019 Joyent, Inc. -# Copyright 2020 Tintri by DDN, Inc. All rights reserved. +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. # Copyright 2022 Oxide Computer Company # @@ -28,6 +28,7 @@ SUBDIRS = \ net-tests \ os-tests \ smbclient-tests \ + smbsrv-tests \ test-runner \ util-tests \ zfs-tests diff --git a/usr/src/test/smbsrv-tests/Makefile b/usr/src/test/smbsrv-tests/Makefile new file mode 100644 index 0000000000..c148fa93e8 --- /dev/null +++ b/usr/src/test/smbsrv-tests/Makefile @@ -0,0 +1,20 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2012, 2017 by Delphix. All rights reserved. +# + +.PARALLEL: $(SUBDIRS) + +SUBDIRS:sh = find ./* -maxdepth 0 -type d + +include $(SRC)/test/Makefile.com diff --git a/usr/src/test/smbsrv-tests/Makefile.com b/usr/src/test/smbsrv-tests/Makefile.com new file mode 100644 index 0000000000..988bbae0b6 --- /dev/null +++ b/usr/src/test/smbsrv-tests/Makefile.com @@ -0,0 +1,69 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2016, 2017 by Delphix. All rights reserved. +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. +# + +# The following file name generation rules allow the addition of tests, +# libraries and other miscellaneous files without having to specify them +# all individually in lower level Makefiles. +PROGS:sh = find . -maxdepth 1 -type f \( \ + -name "*.ksh" -o \ + -name "*.py" -o \ + -name "*.sh" \) +FILES:sh = find . -maxdepth 1 -type f \( \ + -name "*.Z" -o \ + -name "*.bz2" -o \ + -name "*.cfg" -o \ + -name "*.d" -o \ + -name "*.err" -o \ + -name "*.fio" -o \ + -name "*.out" -o \ + -name "*.run" -o \ + -name "*shlib" -o \ + -name "*.txt" -o \ + -name "*.zcp" \) + +CMDS = $(PROGS:%.sh=$(TARGETDIR)/%) +CMDS += $(PROGS:%.ksh=$(TARGETDIR)/%) +CMDS += $(PROGS:%.py=$(TARGETDIR)/%) +$(CMDS) := FILEMODE = 0555 + +LIBS = $(FILES:%=$(TARGETDIR)/%) +$(LIBS) := FILEMODE = 0444 + +all clean clobber: + +install: $(CMDS) $(LIBS) + +$(CMDS): $(TARGETDIR) + +$(LIBS): $(TARGETDIR) + +$(TARGETDIR): + $(INS.dir) + +$(TARGETDIR)/%: %.sh + $(INS.rename) + +$(TARGETDIR)/%: %.ksh + $(INS.rename) + +$(TARGETDIR)/%: %.py + $(INS.pyfile) + +$(TARGETDIR)/%: % + $(INS.file) + +.PARALLEL: $(SUBDIRS) +SUBDIRS:sh = find ./* -maxdepth 0 -type d ; exit 0 diff --git a/usr/src/test/smbsrv-tests/cmd/Makefile b/usr/src/test/smbsrv-tests/cmd/Makefile new file mode 100644 index 0000000000..d28988e431 --- /dev/null +++ b/usr/src/test/smbsrv-tests/cmd/Makefile @@ -0,0 +1,26 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. +# + +include $(SRC)/Makefile.master + +# The python code in here required python3 or later. +PYSHEBANG = $(PYTHON3) +PYVER = $(PYTHON3_VERSION) +PYSUFFIX = $(PYTHON3_SUFFIX) + +ROOTOPTPKG = $(ROOT)/opt/smbsrv-tests +TARGETDIR = $(ROOTOPTPKG)/bin + +include $(SRC)/test/smbsrv-tests/Makefile.com diff --git a/usr/src/test/smbsrv-tests/cmd/run_smbtorture.py b/usr/src/test/smbsrv-tests/cmd/run_smbtorture.py new file mode 100644 index 0000000000..fd008f7b19 --- /dev/null +++ b/usr/src/test/smbsrv-tests/cmd/run_smbtorture.py @@ -0,0 +1,244 @@ +#!@PYTHON@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. +# + +# +# Run tests provided by smbtorture. +# + +import subprocess +import argparse +import re +import fnmatch + +from enum import Enum +from datetime import datetime +from tempfile import TemporaryFile + +def stripped_file(f): + """Strips trailing whitespace from lines in f""" + + for line in f: + yield line.strip() + +def parse_tests(f): + """Returns test names from f, skipping commented lines""" + + yield from (line for line in f + if line and not line.startswith('#')) + +def matched_suites(m): + """Gets all smbtorture tests that match pattern m""" + + with TemporaryFile('w+') as tmp: + subprocess.run(['smbtorture', '--list'], stdout=tmp, + universal_newlines=True) + tmp.seek(0) + yield from (line for line in stripped_file(tmp) + if not line.startswith('smbtorture') and + m.match(line)) + +class TestResult(Enum): + PASS = 0 + FAIL = 1 + UNKNOWN = 2 + SKIP = 3 + KILLED = 4 + + def __str__(self): + return self.name + + def __len__(self): + return len(self.name) + +class TestCase: + """A particular instance of an smbtorture test""" + + __slots__ = 'name', 'result' + + def __init__(self, name, skip=False): + self.name = name + self.result = TestResult.SKIP if skip else TestResult.UNKNOWN + + def __str__(self): + return '{0.name} | {0.result}'.format(self) + + def run(self, rfd, wfd, timeout, cmd): + """Run cmd, setting the last element to the test name, and setting result + based on rfd. Output is sent to wfd, and the test is killed based on timeout.""" + + def finish(self, start, wfd): + timediff = datetime.now() - start + wfd.write('END | {} | {}\n'.format(self, timediff)) + return self.result + + starttime = datetime.now() + wfd.write('START | {} | {}\n'.format(self.name, starttime.time())) + if self.result == TestResult.SKIP: + return finish(self, starttime, wfd) + + cmd[-1] = self.name + try: + subprocess.run(cmd, universal_newlines=True, stdout=wfd, + stderr=subprocess.STDOUT, timeout=timeout) + for line in stripped_file(rfd): + if self.result != TestResult.UNKNOWN: + continue + elif line.startswith('failure:') or line.startswith('error:'): + self.result = TestResult.FAIL + elif line.startswith('success:'): + self.result = TestResult.PASS + elif line.startswith('skip:'): + self.result = TestResult.SKIP + except subprocess.TimeoutExpired: + self.result = TestResult.KILLED + wfd.write('\nKilled due to timeout\n') + rfd.read() + + return finish(self, starttime, wfd) + +def should_skip(test, pattern, verbose): + """Returns whether test matches pattern, indicating it should be skipped.""" + + if not pattern or not pattern.match(test): + return False + + if verbose: + print('{} matches exception pattern; marking as skipped'.format(test)) + return True + +def fnm2regex(fnm_pat): + """Maps an fnmatch(7) pattern to a regex pattern that will match against + any suite that encapsulates the test name""" + + rpat = fnmatch.translate(fnm_pat) + return r'{}|{}'.format(rpat, rpat.replace(r'\Z', r'\.')) + +def combine_patterns(iterable, verbose): + """Combines patterns in an iterable into a single REGEX""" + + pat = re.compile('|'.join(map(fnm2regex, iterable)), + flags=re.DEBUG if verbose > 1 else 0) + if verbose > 1: + print('final pattern: {}'.format(pat.pattern)) + return pat + +class ArgumentFile(argparse.FileType): + """argparse.FileType, but wrapped in stripped_file()""" + + def __call__(self, *args, **kwargs): + return stripped_file(argparse.FileType.__call__(self, *args, **kwargs)) + + +def main(): + parser = argparse.ArgumentParser(description= + 'Run a set of smbtorture tests, parsing the results.') + + parser.add_argument('server', help='The target server') + parser.add_argument('share', help='The target share') + parser.add_argument('user', help='Username for smbtorture') + parser.add_argument('password', help='Password for user') + + parser.add_argument('--except', '-e', + type=ArgumentFile('r'), metavar='EXCEPTIONS_FILE', dest='skip_list', + help='A file containing fnmatch(5) patterns of tests to skip') + parser.add_argument('--list', '-l', + type=ArgumentFile('r'), metavar='LIST_FILE', + help='A file containing the list of tests to run') + parser.add_argument('--match', '-m', + action='append', metavar='FNMATCH', + help='An fnmatch(5) pattern to select tests from smbtorture --list') + parser.add_argument('--output', '-o', + default='/tmp/lastrun.log', metavar='LOG_FILE', + help='Location to store full smbtorture output') + parser.add_argument('--seed', '-s', + type=int, + help='Seed passed to smbtorture') + parser.add_argument('--timeout', '-t', + default=120, type=float, + help='Timeout after which test is killed') + parser.add_argument('--verbose', '-v', + action='count', default=0, + help='Verbose output') + + args = parser.parse_args() + + if (args.match == None) == (args.list == None): + print('Must provide one of -l and -m') + return + + server = args.server + share = args.share + user = args.user + pswd = args.password + fout = args.output + + if args.match != None: + if args.verbose > 1: + print('Patterns to match:') + print(*args.match) + + testgen = matched_suites(combine_patterns(args.match, args.verbose)) + else: + testgen = args.list + + if args.skip_list != None: + skip_pat = combine_patterns(parse_tests(args.skip_list), args.verbose) + if args.verbose > 1: + print('Exceptions pattern (in REGEX): {}'.format(skip_pat.pattern)) + else: + skip_pat = None + + tests = [TestCase(line, should_skip(line, skip_pat, args.verbose)) + for line in parse_tests(testgen)] + + if args.verbose: + print('Tests to run:') + for test in tests: + if test.result != TestResult.SKIP: + print(test.name) + + outw = open(fout, 'w', buffering=1) + outr = open(fout, 'r') + + cmd = 'smbtorture //{srv}/{shr} -U{usr}%{pswd}'.format( + srv=server, shr=share, usr=user, pswd=pswd).split() + if args.seed != None: + cmd.append('--seed={}'.format(args.seed)) + cmd.append('TEST_HERE') + + if args.verbose: + print('Command to run:') + print(*cmd) + + results = {res: 0 for res in TestResult} + for test in tests: + print(test.name, end=': ', flush=True) + res = test.run(outr, outw, args.timeout, cmd) + results[res] += 1 + print(res, flush=True) + + print('\n\nRESULTS:') + print('=' * 22) + for res in TestResult: + print('{}: {:>{}}'.format(res, results[res], 20 - len(res))) + print('=' * 22) + print('Total: {:>15}'.format(len(tests))) + +if __name__ == '__main__': + try: + main() + except KeyboardInterrupt: + print('Terminated by KeyboardInterrupt.') diff --git a/usr/src/test/smbsrv-tests/cmd/smbsrvtests.ksh b/usr/src/test/smbsrv-tests/cmd/smbsrvtests.ksh new file mode 100644 index 0000000000..934f4e26ed --- /dev/null +++ b/usr/src/test/smbsrv-tests/cmd/smbsrvtests.ksh @@ -0,0 +1,55 @@ +#!/usr/bin/ksh + +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. +# + +# Run all the smbsrv-tests + +export PATH="/usr/bin" +export SMBSRV_TESTS="/opt/smbsrv-tests" + +export CFGFILE=$SMBSRV_TESTS/include/default.cfg +export OUTDIR=/var/tmp/test_results/smbsrv-tests + +function fail +{ + echo $1 + exit ${2:-1} +} + +while getopts b:c:o:t: c; do + case $c in + 'b') + export BASEFILE=$OPTARG + [[ -f $BASEFILE ]] || fail "Cannot read file: $BASEFILE" + ;; + 'c') + CFGFILE=$OPTARG + [[ -f $CFGFILE ]] || fail "Cannot read file: $CFGFILE" + ;; + 'o') + OUTDIR=$OPTARG + ;; + 't') + export TIMEOUT=$OPTARG + ;; + esac +done +shift $((OPTIND - 1)) + +set -x + +# Just one test for now. More to come. +$SMBSRV_TESTS/tests/smbtorture/runst-smb2 diff --git a/usr/src/test/smbsrv-tests/doc/Makefile b/usr/src/test/smbsrv-tests/doc/Makefile new file mode 100644 index 0000000000..d3ceeef7f2 --- /dev/null +++ b/usr/src/test/smbsrv-tests/doc/Makefile @@ -0,0 +1,36 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2012 by Delphix. All rights reserved. +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. +# + +include $(SRC)/Makefile.master + +READMES = README + +ROOTOPTPKG = $(ROOT)/opt/smbsrv-tests + +FILES = $(READMES:%=$(ROOTOPTPKG)/%) +$(FILES) := FILEMODE = 0444 + +all: $(READMES) + +install: $(ROOTOPTPKG) $(FILES) + +clean clobber: + +$(ROOTOPTPKG): + $(INS.dir) + +$(ROOTOPTPKG)/%: % + $(INS.file) diff --git a/usr/src/test/smbsrv-tests/doc/README b/usr/src/test/smbsrv-tests/doc/README new file mode 100644 index 0000000000..e83affbb9b --- /dev/null +++ b/usr/src/test/smbsrv-tests/doc/README @@ -0,0 +1,84 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. +# + +SMB Server Test Suite README + +1. Building and installing the SMB Server Test Suite +2. Running the SMB Server Test Suite +3. Test Results + +-------------------------------------------------------------------------------- + +1. Building and installing the SMB Server Test Suite + +The SMB Server test suite uses external programs including: + smbtorture (and more to come) +which is installed via a package dependency on: + service/network/samba +Those are run by python and ksh wrappers found here. + +To build, just do: + cd $SRC/test/smbsrv-tests + make install + +To install the full suite, run: + pkg install pkg:/system/test/smbsrvtest + +-------------------------------------------------------------------------------- + +2. Running the SMB Server Test Suite + +The default configuration: + /opt/smbsrv-tests/include/default.cfg +runs tests against a server instance on "localhost", +using a share named "test" and user=test, pw=test + +It's common to copy that default.cfg to something new +and modify the SMBT_... variables to specify different +host, share, user, etc. + +To run all tests using the default configuration run: + /opt/smbsrv-tests/bin/smbsrvtests + +To run all tests using a different configuration: + /opt/smbsrv-tests/bin/smbsrvtests -c config_file + +You can also run individual tests found under: + /opt/smbsrv-tests/tests/* +For example: + /opt/smbsrv-tests/tests/smbtorture/runst-smb2 + +These take similar options (eg. -c config_file). + +To run only a subset of the tests, you can pass match patterns +as additional arguments to the individual test, eg + /opt/smbsrv-tests/tests/smbtorture/runst-smb2 smb2.lease + +-------------------------------------------------------------------------------- + +3. Test Results + +While the SMB Server Test Suite is running, one informational line is +printed for each test, ending with one of: + PASS, FAIL, SKIP, KILLED, UNKNOWN + +The test outputs can be found in: + /var/tmp/test_results/smbsrv-tests/ +For example: + smbtor-smb2-20210317T162827.summary + smbtor-smb2-20210317T162827.log + +The *.summary file is the same as what's shown while the test runs. +The *.log file is the detailed output from the test program(s). diff --git a/usr/src/test/smbsrv-tests/include/Makefile b/usr/src/test/smbsrv-tests/include/Makefile new file mode 100644 index 0000000000..039d796e84 --- /dev/null +++ b/usr/src/test/smbsrv-tests/include/Makefile @@ -0,0 +1,21 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. +# + +include $(SRC)/Makefile.master + +ROOTOPTPKG = $(ROOT)/opt/smbsrv-tests +TARGETDIR = $(ROOTOPTPKG)/include + +include $(SRC)/test/smbsrv-tests/Makefile.com diff --git a/usr/src/test/smbsrv-tests/include/default.cfg b/usr/src/test/smbsrv-tests/include/default.cfg new file mode 100644 index 0000000000..1ce658ed2d --- /dev/null +++ b/usr/src/test/smbsrv-tests/include/default.cfg @@ -0,0 +1,23 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. +# + +# Sample configuration. Either edit this, +# provide your own with: smbsrvtest -c ... + +export SMBT_HOST="localhost" +export SMBT_SHARE="test" +export SMBT_USER="test" +export SMBT_PASS="test" +export SMBTOR="/usr/bin/smbtorture" diff --git a/usr/src/test/smbsrv-tests/include/smbtor-excl-smb2.txt b/usr/src/test/smbsrv-tests/include/smbtor-excl-smb2.txt new file mode 100644 index 0000000000..05b69d1c9b --- /dev/null +++ b/usr/src/test/smbsrv-tests/include/smbtor-excl-smb2.txt @@ -0,0 +1,33 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# +# +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. +# Copyright 2022 RackTop Systems, Inc. +# + +# +# smbtorture tests we choose to skip, either because the +# tests hang, or we disagree with the test, or whatever. +# + +smb2.aio_delay +smb2.bench-oplock +smb2.change_notify_disabled +smb2.check-sharemode +smb2.hold-sharemode +smb2.hold-oplock +smb2.maxfid +smb2.multichannel +smb2.notify.invalid-reauth +smb2.replay +smb2.scan +smb2.session.reauth* +smb2.timestamps diff --git a/usr/src/test/smbsrv-tests/tests/Makefile b/usr/src/test/smbsrv-tests/tests/Makefile new file mode 100644 index 0000000000..0d4ee56fbb --- /dev/null +++ b/usr/src/test/smbsrv-tests/tests/Makefile @@ -0,0 +1,17 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. +# + +include $(SRC)/test/smbsrv-tests/Makefile.com +include $(SRC)/test/Makefile.com diff --git a/usr/src/test/smbsrv-tests/tests/smbtorture/Makefile b/usr/src/test/smbsrv-tests/tests/smbtorture/Makefile new file mode 100644 index 0000000000..53169748ef --- /dev/null +++ b/usr/src/test/smbsrv-tests/tests/smbtorture/Makefile @@ -0,0 +1,22 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. +# + +include $(SRC)/Makefile.master + +ROOTOPTPKG = $(ROOT)/opt/smbsrv-tests +TARGETDIR = $(ROOTOPTPKG)/tests/smbtorture + +include $(SRC)/test/smbsrv-tests/Makefile.com +include $(SRC)/test/Makefile.com diff --git a/usr/src/test/smbsrv-tests/tests/smbtorture/runst-smb2.ksh b/usr/src/test/smbsrv-tests/tests/smbtorture/runst-smb2.ksh new file mode 100644 index 0000000000..6f8e51ffd1 --- /dev/null +++ b/usr/src/test/smbsrv-tests/tests/smbtorture/runst-smb2.ksh @@ -0,0 +1,83 @@ +#!/usr/bin/ksh + +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2021 Tintri by DDN, Inc. All rights reserved. +# + +export SMBSRV_TESTS="/opt/smbsrv-tests" +export SMBTOR="/usr/bin/smbtorture" + +runsmbtor=$SMBSRV_TESTS/bin/run_smbtorture +excl_file=$SMBSRV_TESTS/include/smbtor-excl-smb2.txt + +cfgfile=${CFGFILE:-$SMBSRV_TESTS/include/default.cfg} +outdir=${OUTDIR:-/var/tmp/test_results/smbsrv-tests} + +function fail +{ + echo $1 + exit ${2:-1} +} + +while getopts c:o:t: c; do + case $c in + 'c') + cfgfile=$OPTARG + [[ -f $cfgfile ]] || fail "Cannot read file: $cfgfile" + ;; + 'o') + outdir=$OPTARG + ;; + 't') + timeout="-t $OPTARG" + ;; + esac +done +shift $((OPTIND - 1)) + +. $cfgfile + +export PATH="$(dirname $SMBTOR):$PATH" + +mkdir -p $outdir +cd $outdir + +tstamp=$(date +'%Y%m%dT%H%M%S') +logfile=$outdir/smbtor-smb2-${tstamp}.log +outfile=$outdir/smbtor-smb2-${tstamp}.summary + +if [[ -z "$timeout" && -n "$TIMEOUT" ]]; then + timeout="-t $TIMEOUT" +fi + +# Non-option args taken as list of match patterns +if [ -z "$1" ] ; then + match="-m smb2" +fi +for m +do + match="$match -m $m" +done + +# Make sure we can connect, otherwise we'll report every test as failing. +$SMBTOR -U "$SMBT_USER%${SMBT_PASS}" //$SMBT_HOST/$SMBT_SHARE smb2.dir.find \ + > /dev/null 2>&1 || \ + fail "Cannot connect to //$SMBT_HOST/$SMBT_SHARE" + +echo "Running smbtorture/smb2 tests with //$SMBT_HOST/$SMBT_SHARE" +$runsmbtor $match -e $excl_file -o $logfile $timeout \ + "$SMBT_HOST" "$SMBT_SHARE" "$SMBT_USER" "${SMBT_PASS}" | + tee $outfile + +exit 0 diff --git a/usr/src/tools/quick/make-smbsrv b/usr/src/tools/quick/make-smbsrv index b04ab47721..c2436ed021 100755 --- a/usr/src/tools/quick/make-smbsrv +++ b/usr/src/tools/quick/make-smbsrv @@ -152,6 +152,7 @@ do_kern() { *) targ=$1 ;; esac ( unset SOURCEDEBUG ; + export NO_GENUNIX_UNIQUIFY= ; (cd $SRC/uts/$x/smbsrv && $make $targ) ) } @@ -217,6 +218,7 @@ do_libs() { for lib in \ libfakekernel \ libads \ + libidmap \ libsmbfs \ libmlrpc do @@ -271,6 +273,16 @@ done } ################################################################ + +do_tests() { + + for d in test/test-runner test/libmlrpc-tests test/smbsrv-tests + do + [ -f $SRC/$d/Makefile ] && (cd $SRC/$d && $make $1) + done +} + +################################################################ # This builds $SRC/TAGS (and cscope.files) in a helpful order. do_tags() { @@ -346,6 +358,7 @@ do do_kern $arg do_libs $arg do_cmds $arg + do_tests $arg ;; lint) do_hdrs $arg @@ -354,17 +367,19 @@ do do_cmds $arg ;; clean) - # intentionally skip: lib1, hdrs, tools + # intentionally skip: deplib, hdrs, tools + do_tests $arg do_cmds $arg do_libs $arg do_kern $arg ;; clobber) + do_tests $arg do_cmds $arg do_libs $arg + do_deplibs $arg do_kern $arg do_hdrs $arg - do_deplibs $arg clobber_tools ;; deplibs) |