The branch, master has been updated via 8a42954 samba-tool test: ensure `samba-tool help` works via 316594f samba-tool: treat 'samba-tool help foo' as 'samba-tool foo --help' via 769197d samba-tool: give cache_loader pseudo-dict a .get() method via cef83c0 samba-tool: --help test, ensuring help tree coverage via abcc955 selftest: pass location of perl executable from waf to test-envs from c4919d4 s3:smb2_server: allow logoff, close, unlock, cancel and echo on expired sessions
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 8a42954775df6795efa9b5ba5676301d14b3efac Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Mon Dec 18 17:06:07 2017 +1300 samba-tool test: ensure `samba-tool help` works We make sure the output is identical to `samba-tool --help` for the same subcommands. Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> Autobuild-User(master): Andrew Bartlett <abart...@samba.org> Autobuild-Date(master): Fri Dec 22 07:50:21 CET 2017 on sn-devel-144 commit 316594f211340cc2d11a98895f624b50f2e51f7c Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Fri Aug 11 16:39:33 2017 +1200 samba-tool: treat 'samba-tool help foo' as 'samba-tool foo --help' Vaguely keeping up with the modern style. Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 769197dfa320ce9d252c0871df0ceb3c47fb644b Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Thu Dec 21 11:30:24 2017 +1300 samba-tool: give cache_loader pseudo-dict a .get() method This makes it more dict-like, and makes the next patch (adding samba-tool help) simpler. Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit cef83c0cc60359935fc4fa5db60cdc825bd3fa25 Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Mon Dec 18 16:54:07 2017 +1300 samba-tool: --help test, ensuring help tree coverage `samba-tool [COMMAND] --help` will list sub-commands of COMMAND (or top-level commands if COMMAND is omitted). This ensures that `samba-tool COMMAND SUBCOMMAND --help` works for all the commands found in the help tree. Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit abcc95520102e40d836c60f389bc4fb6110223ec Author: Uri Simchoni <u...@samba.org> Date: Thu Dec 21 19:49:39 2017 +0200 selftest: pass location of perl executable from waf to test-envs Many perl scripts in the codebase are executables with a "/usr/bin/perl" shebang. Running them as executables is not portable as some OS's have a different location for the perl interpreter. During the configuration process, waf finds the location of the perl interpreter. Some or all invocations of perl scripts from within test environment setup code are actually "$PERL <script>", but since PERL env var is typically not set, this amounts to the unportable "<script>", which invokes /usr/bin/perl. This patch exports the location of perl as found by the configuration process to the test environment, causing "$PERL <script>" to be "<correct place of perl interpreter> <script>". Signed-off-by: Uri Simchoni <u...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> ----------------------------------------------------------------------- Summary of changes: python/samba/netcmd/__init__.py | 13 +++++++ python/samba/netcmd/main.py | 6 +++ python/samba/tests/samba_tool/help.py | 72 +++++++++++++++++++++++++++++++++++ selftest/wscript | 3 ++ source4/selftest/tests.py | 1 + 5 files changed, 95 insertions(+) create mode 100644 python/samba/tests/samba_tool/help.py Changeset truncated at 500 lines: diff --git a/python/samba/netcmd/__init__.py b/python/samba/netcmd/__init__.py index ad8143d..05ecc43 100644 --- a/python/samba/netcmd/__init__.py +++ b/python/samba/netcmd/__init__.py @@ -202,6 +202,19 @@ class SuperCommand(Command): return self.subcommands[subcommand]._run( "%s %s" % (myname, subcommand), *args) + if subcommand == 'help': + # pass the request down + if len(args) > 0: + sub = self.subcommands.get(args[0]) + if isinstance(sub, SuperCommand): + return sub._run("%s %s" % (myname, args[0]), 'help', + *args[1:]) + elif sub is not None: + return sub._run("%s %s" % (myname, args[0]), '--help', + *args[1:]) + + subcommand = '--help' + epilog = "\nAvailable subcommands:\n" subcmds = self.subcommands.keys() subcmds.sort() diff --git a/python/samba/netcmd/main.py b/python/samba/netcmd/main.py index ba90748..cc16e4a 100644 --- a/python/samba/netcmd/main.py +++ b/python/samba/netcmd/main.py @@ -36,6 +36,12 @@ class cache_loader(dict): 'cmd_%s' % attr)() return dict.__getitem__(self, attr) + def get(self, attr, default=None): + try: + return self[attr] + except KeyError: + return default + def iteritems(self): for key in self: yield (key, self[key]) diff --git a/python/samba/tests/samba_tool/help.py b/python/samba/tests/samba_tool/help.py new file mode 100644 index 0000000..62e0b3e --- /dev/null +++ b/python/samba/tests/samba_tool/help.py @@ -0,0 +1,72 @@ +# Unix SMB/CIFS implementation. +# Copyright (C) Catalyst IT Ltd 2017. +# +# Originally written by Douglas Bagnall <douglas.bagn...@catalyst.net.nz> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import re +from samba.tests.samba_tool.base import SambaToolCmdTest +from samba.tests import BlackboxProcessError + + +class HelpTestCase(SambaToolCmdTest): + """Tests for samba-tool help and --help + + We test for consistency and lack of crashes.""" + + def _find_sub_commands(self, args): + self.runcmd(*args) + + def test_help_tree(self): + # we call actual subprocesses, because we are probing the + # actual help output where there is no sub-command. Don't copy + # this if you have an actual command: for that use + # self.runcmd() or self.runsubcmd(). + known_commands = [[]] + failed_commands = [] + + for i in range(4): + new_commands = [] + for c in known_commands: + line = ' '.join(['samba-tool'] + c + ['--help']) + try: + output = self.check_output(line) + except BlackboxProcessError as e: + output = e.stdout + failed_commands.append(c) + + tail = output.partition('Available subcommands:')[2] + subcommands = re.findall(r'^\s*([\w-]+)\s+-', tail, + re.MULTILINE) + for s in subcommands: + new_commands.append(c + [s]) + + # check that `samba-tool help X Y` == `samba-tool X Y --help` + line = ' '.join(['samba-tool', 'help'] + c) + try: + output2 = self.check_output(line) + except BlackboxProcessError as e: + output2 = e.stdout + failed_commands.append(c) + + self.assertEqual(output, output2) + + if not new_commands: + break + + known_commands = new_commands + + self.assertEqual(failed_commands, []) diff --git a/selftest/wscript b/selftest/wscript index 9f1fd4d..8264d96 100644 --- a/selftest/wscript +++ b/selftest/wscript @@ -202,6 +202,9 @@ def cmd_testonly(opt): # tell build system where to find config.h os.environ['CONFIG_H'] = 'bin/default/include/config.h' + # tell the test system where perl is + os.environ['PERL'] = env.PERL + st_done = os.path.join(env.SELFTEST_PREFIX, 'st_done') if os.path.exists(st_done): os.unlink(st_done) diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index 0a0bc93..755f0c9 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -607,6 +607,7 @@ planpythontestsuite("chgdcpass:local", "samba.tests.samba_tool.user_check_passwo planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.samba_tool.group") planpythontestsuite("ad_dc:local", "samba.tests.samba_tool.ntacl") planpythontestsuite("none", "samba.tests.samba_tool.provision_password_check") +planpythontestsuite("none", "samba.tests.samba_tool.help") planpythontestsuite("ad_dc:local", "samba.tests.samba_tool.sites") planpythontestsuite("ad_dc:local", "samba.tests.samba_tool.dnscmd") -- Samba Shared Repository