tests: Handle backup command exceptions as test failures, not errors
authorTim Beale <timbeale@catalyst.net.nz>
Thu, 22 Nov 2018 01:35:58 +0000 (14:35 +1300)
committerTim Beale <timbeale@samba.org>
Tue, 27 Nov 2018 02:43:17 +0000 (03:43 +0100)
commit70dee4c1c14ea3eb5c8c81887c6caaa6dc288807
tree17655c055653be658ab75869ad13f14e71dbf803
parent93c2a9522357e7d70d028cbd6bbeda103f40c69e
tests: Handle backup command exceptions as test failures, not errors

If the backup command fails (i.e. throws an exception), we want the test
to fail. This makes it easier to mark tests as 'knownfail' (because we
can't knownfail test errors).

In theory, this should just involve updating run_cmd() to catch any
exceptions from the command and then call self.fail().

However, if the backup command fails, it can leave behind files in the
targetdir. Partly this is intentional, as these files may provide clues
to users as to why the command failed. However, in selftest, it causes
the TestCaseInTempDir._remove_tempdir() assertion to fire. Because this
assert actually gets run as part of the teardown, the assertion gets
treated as an error rather than a failure (and so we can't knownfail the
backup tests). To get around this, we remove any files in the tempdir
prior to calling self.fail().

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/__init__.py
python/samba/tests/domain_backup.py