From a1cc964c6c428537dc8fd961815f556d24effe14 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 29 Jun 2016 11:44:42 +0800 Subject: [PATCH] test/scheduler: test check_pause --- artiq/test/test_scheduler.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/artiq/test/test_scheduler.py b/artiq/test/test_scheduler.py index 728980ae3..b95a97d9b 100644 --- a/artiq/test/test_scheduler.py +++ b/artiq/test/test_scheduler.py @@ -138,6 +138,7 @@ class SchedulerCase(unittest.TestCase): expect = _get_basic_steps(1, expid) background_running = asyncio.Event() + empty_ready = asyncio.Event() empty_completed = asyncio.Event() background_completed = asyncio.Event() expect_idx = 0 @@ -151,8 +152,13 @@ class SchedulerCase(unittest.TestCase): if mod == {"path": [0], "value": "deleting", "key": "status", - "action": "setitem"}: + "action": "setitem"}: background_completed.set() + if mod == {"path": [1], + "value": "prepare_done", + "key": "status", + "action": "setitem"}: + empty_ready.set() if mod["path"] == [1] or (mod["path"] == [] and mod["key"] == 1): self.assertEqual(mod, expect[expect_idx]) expect_idx += 1 @@ -163,11 +169,17 @@ class SchedulerCase(unittest.TestCase): scheduler.start() scheduler.submit("main", expid_bg, -99, None, False) loop.run_until_complete(background_running.wait()) + self.assertFalse(scheduler.check_pause(0)) scheduler.submit("main", expid, 0, None, False) + self.assertFalse(scheduler.check_pause(0)) + loop.run_until_complete(empty_ready.wait()) + self.assertTrue(scheduler.check_pause(0)) loop.run_until_complete(empty_completed.wait()) + self.assertFalse(scheduler.check_pause(0)) self.assertFalse(termination_ok) scheduler.request_termination(0) + self.assertTrue(scheduler.check_pause(0)) loop.run_until_complete(background_completed.wait()) self.assertTrue(termination_ok)