Add more syslog tests (GH-97953)

This commit is contained in:
Serhiy Storchaka 2022-10-07 20:17:08 +03:00 committed by GitHub
parent 80b3e32d62
commit cae7d1d7a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 95 additions and 8 deletions

View file

@ -16,6 +16,7 @@ AUDIT_TESTS_PY = support.findfile("audit-tests.py")
class AuditTest(unittest.TestCase):
maxDiff = None
@support.requires_subprocess()
def do_test(self, *args):
@ -185,7 +186,6 @@ class AuditTest(unittest.TestCase):
self.assertEqual(actual, expected)
def test_wmi_exec_query(self):
import_helper.import_module("_wmi")
returncode, events, stderr = self.run_python("test_wmi_exec_query")
@ -199,6 +199,29 @@ class AuditTest(unittest.TestCase):
self.assertEqual(actual, expected)
def test_syslog(self):
syslog = import_helper.import_module("syslog")
returncode, events, stderr = self.run_python("test_syslog")
if returncode:
self.fail(stderr)
if support.verbose:
print('Events:', *events, sep='\n ')
self.assertSequenceEqual(
events,
[('syslog.openlog', ' ', f'python 0 {syslog.LOG_USER}'),
('syslog.syslog', ' ', f'{syslog.LOG_INFO} test'),
('syslog.setlogmask', ' ', f'{syslog.LOG_DEBUG}'),
('syslog.closelog', '', ''),
('syslog.syslog', ' ', f'{syslog.LOG_INFO} test2'),
('syslog.openlog', ' ', f'audit-tests.py 0 {syslog.LOG_USER}'),
('syslog.openlog', ' ', f'audit-tests.py {syslog.LOG_NDELAY} {syslog.LOG_LOCAL0}'),
('syslog.openlog', ' ', f'None 0 {syslog.LOG_USER}'),
('syslog.closelog', '', '')]
)
if __name__ == "__main__":
unittest.main()