1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Catalyst IT Ltd 2017.
4 # Originally written by Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 from samba.tests.samba_tool.base import SambaToolCmdTest
22 from samba.tests import BlackboxProcessError
25 class HelpTestCase(SambaToolCmdTest):
26 """Tests for samba-tool help and --help
28 We test for consistency and lack of crashes."""
30 def _find_sub_commands(self, args):
33 def test_help_tree(self):
34 # we call actual subprocesses, because we are probing the
35 # actual help output where there is no sub-command. Don't copy
36 # this if you have an actual command: for that use
37 # self.runcmd() or self.runsubcmd().
43 for c in known_commands:
44 line = ' '.join(['samba-tool'] + c + ['--help'])
46 output = self.check_output(line)
47 except BlackboxProcessError as e:
49 failed_commands.append(c)
51 tail = output.partition('Available subcommands:')[2]
52 subcommands = re.findall(r'^\s*([\w-]+)\s+-', tail,
55 new_commands.append(c + [s])
57 # check that `samba-tool help X Y` == `samba-tool X Y --help`
58 line = ' '.join(['samba-tool', 'help'] + c)
60 output2 = self.check_output(line)
61 except BlackboxProcessError as e:
63 failed_commands.append(c)
65 self.assertEqual(output, output2)
70 known_commands = new_commands
72 self.assertEqual(failed_commands, [])