Example #1
0
 def test_12(self):
     fake_target("target1")
     # T = 1, timeout = 2, we'll run twice
     e = expecter.expecter_c(debug_log, 1, 2)
     # add some bad code, raises an exception
     e.add(self.bad_code, None)
     with self.assertRaises(Exception):
         e.run()
Example #2
0
 def test_02(self):
     e = expecter.expecter_c(debug_log, 10, 1)
     e.add(
         expecter.console_rx_eval,
         ("console1", 43, "fail"),
     )
     e.add(
         expecter.console_rx_eval,
         ("console1", 43, "fail"),
     )
     self.assertEqual(len(e.functors), 1)
Example #3
0
 def test_05(self):
     t = fake_target("target1")
     # T = 1, timeout = 2, we'll run once
     e = expecter.expecter_c(debug_log, 1, 2)
     e.add(
         expecter.console_rx_poller,
         (t, "console-1"),
     )
     e.add(
         expecter.console_rx_eval,
         (t, "Lorem ipsum dolor", "console-1"),
     )
     with self.assertRaises(tc.pass_e):
         e.run()
Example #4
0
 def test_13(self):
     r = re.compile("^ Lorem ipsum dolor sit amet, c$")
     t = fake_target("target1")
     # T = 1, timeout = 2, we'll run once
     e = expecter.expecter_c(debug_log, 1, 2)
     e.add(
         expecter.console_rx_poller,
         (t, "console-1"),
     )
     e.add(
         expecter.console_rx_eval,
         (t, r, "console-1"),
     )
     with self.assertRaises(tc.pass_e):
         e.run()
Example #5
0
 def test_11(self):
     t = fake_target("target1")
     # T = 1, timeout = 2, we'll run twice
     e = expecter.expecter_c(debug_log, 1, 2)
     e.add(
         expecter.console_rx_poller,
         (t, "console-1"),
     )
     # Will get a skip, as we said so
     e.add(
         expecter.console_rx_eval,
         (t, "nsectetuer adipiscing ", "console-1", None, "blck"),
     )
     with self.assertRaises(tc.blocked_e):
         e.run()
Example #6
0
 def test_07(self):
     t = fake_target("target1")
     # T = 1, timeout = 2, we'll run twice
     e = expecter.expecter_c(debug_log, 1, 2)
     e.add(
         expecter.console_rx_poller,
         (t, "console-1"),
     )
     # Will pass as we did the second run
     e.add(
         expecter.console_rx_eval,
         (t, "nsectetuer adipiscing ", "console-1"),
     )
     with self.assertRaises(tc.pass_e):
         e.run()
Example #7
0
 def test_04(self):
     t = fake_target("target1")
     # T = 1, timeout = 2, we'll run twice before timing out
     e = expecter.expecter_c(debug_log, 1, 2)
     _, id_str = expecter.console_mk_code(t, "console-1")
     e.add(
         debug_rx_poller,
         (t, "console-1"),
     )
     with self.assertRaises(tc.failed_e):
         # We fail with timeout
         e.run()
     # Read twice, so 60 chars off our block of text
     self.assertEqual(e.buffers[id_str + "-data"], text[:60])
     self.assertEqual(e.buffers[id_str], 60)
Example #8
0
 def test_06(self):
     t = fake_target("target1")
     # T = 1, timeout = 1, we'll run once
     e = expecter.expecter_c(debug_log, 1, 1)
     e.add(
         expecter.console_rx_poller,
         (t, "console-1"),
     )
     # Will fail because the text we are expecting is on for the
     # second run only
     e.add(
         expecter.console_rx_eval,
         (t, "nsectetuer adipiscing ", "console-1"),
     )
     with self.assertRaises(tc.failed_e):
         e.run()
Example #9
0
 def test_03(self):
     t = fake_target("target1")
     # T = 10, timeout = 1, we'll only run once before timing out
     e = expecter.expecter_c(debug_log, 10, 1)
     _, id_str = expecter.console_mk_code(t, "console-1")
     e.add(
         debug_rx_poller,
         (t, "console-1"),
     )
     with self.assertRaises(tc.failed_e):
         # We fail with timeout
         e.run()
     # Read only 30 chars
     self.assertEqual(e.buffers[id_str + "-data"], text[:30])
     self.assertEqual(e.buffers[id_str], 30)
     # When we repeat, the buffers are cleared, so we shall fail
     # the same and get the same in the buffers.
     with self.assertRaises(tc.failed_e):
         e.run()
     self.assertEqual(e.buffers[id_str + "-data"], text[:30])
     self.assertEqual(e.buffers[id_str], 30)