tests: Add dbus-monitor'ing to PAM tests

Should prove useful debugging the PAM module if we need it.
This commit is contained in:
Bastien Nocera
2020-01-23 15:52:10 +01:00
parent d70f15b5e8
commit 205dedae4f
2 changed files with 27 additions and 1 deletions

View File

@ -1,6 +1,6 @@
SUBDIRS = services
TESTS_ENVIRONMENT = export TOPSRCDIR=$(abs_top_srcdir); export LD_PRELOAD=libpam_wrapper.so; export PAM_WRAPPER_SERVICE_DIR=$(abs_top_builddir)/tests/pam/services; export PAM_WRAPPER=1; export PYTHON=@PYTHON@;
TESTS_ENVIRONMENT = export TOPBUILDDIR=$(abs_top_builddir); export TOPSRCDIR=$(abs_top_srcdir); export LD_PRELOAD=libpam_wrapper.so; export PAM_WRAPPER_SERVICE_DIR=$(abs_top_builddir)/tests/pam/services; export PAM_WRAPPER=1; export PYTHON=@PYTHON@;
TESTS = test_pam_fprintd.py
EXTRA_DIST = $(TESTS)

View File

@ -33,9 +33,31 @@ PAM_USER_UNKNOWN = 10
class TestPamFprintd(dbusmock.DBusTestCase):
'''Test pam_fprintd'''
@classmethod
def start_monitor(klass):
'''Start dbus-monitor'''
workdir = os.environ['TOPBUILDDIR'] + '/tests/pam/'
klass.monitor_log = open(os.path.join(workdir, 'dbus-monitor.log'), 'wb', buffering=0)
klass.monitor = subprocess.Popen(['dbus-monitor', '--monitor', '--system'],
stdout=klass.monitor_log,
stderr=subprocess.STDOUT)
@classmethod
def stop_monitor(klass):
'''Stop dbus-monitor'''
assert klass.monitor
klass.monitor.terminate()
klass.monitor.wait()
klass.monitor_log.flush()
klass.monitor_log.close()
@classmethod
def setUpClass(klass):
klass.start_system_bus()
klass.start_monitor()
klass.dbus_con = klass.get_dbus(True)
template_path = './'
@ -44,6 +66,10 @@ class TestPamFprintd(dbusmock.DBusTestCase):
klass.template_name = template_path + 'dbusmock/fprintd.py'
print ('Using template from %s' % klass.template_name)
@classmethod
def tearDownClass(klass):
klass.stop_monitor()
def setUp(self):
(self.p_mock, self.obj_fprintd_manager) = self.spawn_server_template(
self.template_name, {}, stdout=subprocess.PIPE)