def testRun_01(self): scheduler = Scheduler(FiFoStubStrategy()) scheduler.initialize("A") print 'run normal run 1...' scheduler.run() process = ProcessManager().getProcessByName("A") self.assertEqual(process.state, State.I)
class SchedulerNewTestCase(unittest.TestCase): def setUp(self): process2 = Process('02') process2.workplan = Workplan().work(90) self.pcb2 = PCB(process2, state=State.I) process1 = Process('01') process1.workplan = Workplan().launch('02').wait(20).work(10) self.pcb1 = PCB(process1, state=State.B) self.scheduler = Scheduler(FiFoStubStrategy()) def test_append_to_matching_queue_01(self): # test the processed get added to the right queues. self.pcb2.process.name = 'test_q_02' self.scheduler.addToMatchingQueue(self.pcb2) self.assertListEqual(self.scheduler.ready_queue, [self.pcb2]) # process should be in ready queue def test_append_to_matching_queue_02(self): # this time with launch section: self.scheduler.addToMatchingQueue(self.pcb1) # first section is a launch(pcb2), add pcb2 to ready_queue self.assertListEqual(self.scheduler.ready_queue, [self.pcb2]) def test_append_to_matching_queue_03(self): # process with empty workplan pcbX = PCB(Process("X")) self.assertRaises(IndexError, self.scheduler.addToMatchingQueue, pcbX) def test_append_to_matching_queue_04(self): # waiting section pcbX = PCB(Process("Wa_pro")) pcbX.process.workplan = Workplan().work(15).wait(20) pcbX.setReady() pcbX.process.doWork(15) # get rid of work section <--------| pcbX.setRunning() # <- this should be done during scheduling --| self.scheduler.addToMatchingQueue(pcbX) self.assertListEqual(self.scheduler.ea_queues[0].queue, [pcbX]) def test_scheduler_initialize_01(self): self.scheduler.initialize('01') self.scheduler.run() self.assertEqual(self.scheduler.cpu.running_process, None) # p1 section 1 is launch(02): should launch 02 def test_scheduler_run_01(self): self.scheduler.initialize(self.pcb1.process.name) self.scheduler.run() def tearDown(self): ProcessManager._drop() SystemTimer._drop()
class FiFoStrateyTestCase(BaseScenario): """ expected result: Foo|---- Bar| | -- 0 10 30 """ def setUp(self): super(FiFoStrateyTestCase, self).setUp() strategy = FiFo() self.scheduler = Scheduler(strategy=strategy) self.scheduler.initialize("FOO") def test_function01(self): self.scheduler.run()
def test_scheduler_02(self): """Scheduling terminates at 110ms""" scheduler = Scheduler(FiFoStubStrategy()) scheduler.initialize('01') scheduler.run() self.assertEqual(SystemTimer().timecounter, 110)
def test_scheduler_01(self): """If we schedule PCB02 only, it should terminate after 90ms""" scheduler = Scheduler(FiFoStubStrategy()) scheduler.initialize('02') scheduler.run() self.assertEqual(SystemTimer().timecounter, 90)
def test_MLsndFiFo_01(self): strategy = MLsecondFiFo() scheduler = Scheduler(strategy=strategy) scheduler.initialize("A") scheduler.run() pass
def run_scheduler(self): strategy = ShortesJobFirst() scheduler = Scheduler(strategy=strategy) scheduler.initialize("FOO") scheduler.run()
def _run_rr(self, quantum, timeslice): strategy = RoundRobin(quantum=quantum, timeslice=timeslice) scheduler = Scheduler(strategy=strategy) scheduler.initialize("FOO") scheduler.run()