def test_real(self, context, monitor):
     observer = self.make_observer(monitor)
     pytest.unload_dummy()
     monitor.filter_by('net')
     monitor.start()
     observer.start()
     pytest.load_dummy()
     pytest.unload_dummy()
     observer.join(2)
     if observer.is_alive():
         observer.stop()
     assert [d.action for d in self.events] == ['add', 'remove']
     for device in self.events:
         assert device.device_path == '/devices/virtual/net/dummy0'
Example #2
0
 def test_real(self, context, monitor):
     observer = self.make_observer(monitor)
     pytest.unload_dummy()
     monitor.filter_by('net')
     monitor.start()
     observer.start()
     pytest.load_dummy()
     pytest.unload_dummy()
     observer.join(2)
     if observer.is_alive():
         observer.stop()
     assert [d.action for d in self.events] == ['add', 'remove']
     for device in self.events:
         assert device.device_path == '/devices/virtual/net/dummy0'
Example #3
0
 def test_iter(self, monitor):
     pytest.unload_dummy()
     monitor.filter_by('net')
     monitor.enable_receiving()
     pytest.load_dummy()
     iterator = iter(monitor)
     action, device = next(iterator)
     assert action == 'add'
     assert device.subsystem == 'net'
     assert device.device_path == '/devices/virtual/net/dummy0'
     pytest.unload_dummy()
     action, device = next(iterator)
     assert action == 'remove'
     assert device.subsystem == 'net'
     assert device.device_path == '/devices/virtual/net/dummy0'
     iterator.close()
Example #4
0
 def test_receive_device(self, monitor):
     # forcibly unload the dummy module to avoid hangs
     pytest.unload_dummy()
     monitor.filter_by('net')
     monitor.enable_receiving()
     # load the dummy device to trigger an add event
     pytest.load_dummy()
     select([monitor], [], [])
     action, device = monitor.receive_device()
     assert action == 'add'
     assert device.subsystem == 'net'
     assert device.device_path == '/devices/virtual/net/dummy0'
     # and unload again
     pytest.unload_dummy()
     action, device = monitor.receive_device()
     assert action == 'remove'
     assert device.subsystem == 'net'
     assert device.device_path == '/devices/virtual/net/dummy0'
 def test_poll(self, monitor):
     # forcibly unload the dummy module to avoid hangs
     pytest.unload_dummy()
     monitor.filter_by('net')
     monitor.start()
     # load the dummy device to trigger an add event
     pytest.load_dummy()
     select([monitor], [], [])
     device = monitor.poll()
     assert device.action == 'add'
     assert device.sequence_number > 0
     assert device.subsystem == 'net'
     assert device.device_path == '/devices/virtual/net/dummy0'
     # and unload again
     pytest.unload_dummy()
     device = monitor.poll()
     assert device.action == 'remove'
     assert device.sequence_number > 0
     assert device.subsystem == 'net'
     assert device.device_path == '/devices/virtual/net/dummy0'
Example #6
0
 def test_poll(self, monitor):
     # forcibly unload the dummy module to avoid hangs
     pytest.unload_dummy()
     monitor.filter_by('net')
     monitor.start()
     # load the dummy device to trigger an add event
     pytest.load_dummy()
     select([monitor], [], [])
     device = monitor.poll()
     assert device.action == 'add'
     assert device.sequence_number > 0
     assert device.subsystem == 'net'
     assert device.device_path == '/devices/virtual/net/dummy0'
     # and unload again
     pytest.unload_dummy()
     device = monitor.poll()
     assert device.action == 'remove'
     assert device.sequence_number > 0
     assert device.subsystem == 'net'
     assert device.device_path == '/devices/virtual/net/dummy0'
 def test_iter(self, monitor):
     pytest.unload_dummy()
     monitor.filter_by('net')
     monitor.start()
     pytest.load_dummy()
     iterator = iter(monitor)
     # DeprecationWarning triggered on first invocation of generator
     action, device = pytest.deprecated_call(next, iterator)
     assert action == 'add'
     assert device.action == 'add'
     assert device.sequence_number > 0
     assert device.subsystem == 'net'
     assert device.device_path == '/devices/virtual/net/dummy0'
     pytest.unload_dummy()
     action, device = next(iterator)
     assert action == 'remove'
     assert device.action == 'remove'
     assert device.sequence_number > 0
     assert device.subsystem == 'net'
     assert device.device_path == '/devices/virtual/net/dummy0'
     iterator.close()
Example #8
0
 def test_iter(self, monitor):
     pytest.unload_dummy()
     monitor.filter_by('net')
     monitor.start()
     pytest.load_dummy()
     iterator = iter(monitor)
     # DeprecationWarning triggered on first invocation of generator
     action, device = pytest.deprecated_call(next, iterator)
     assert action == 'add'
     assert device.action == 'add'
     assert device.sequence_number > 0
     assert device.subsystem == 'net'
     assert device.device_path == '/devices/virtual/net/dummy0'
     pytest.unload_dummy()
     action, device = next(iterator)
     assert action == 'remove'
     assert device.action == 'remove'
     assert device.sequence_number > 0
     assert device.subsystem == 'net'
     assert device.device_path == '/devices/virtual/net/dummy0'
     iterator.close()