def setUp(self): self.memory = RAM(65535) self.mmu = MMU(1,self.memory) self.scheduler = Mock() self.hdd = Mock() self.queue = Mock() self.interruptor2 = Mock() self.interruptor = Mock() self.logger = Mock() self.semaphore = RLock() self.cpu = CPU(self.memory,self.interruptor, self.semaphore,self.mmu) self.cpu.setLogger(self.logger) self.clock = Clock(self.cpu) self.mov = InstCPU("Matar a Flanders") self.Instruction2 = InstCPU("Y Tambien A Selma") self.instructionIO = InstIO("Soy de IO", 0) self.memory.putDir(0, self.mov) self.memory.putDir(1, self.Instruction2) self.memory.putDir(2, self.instructionIO) page0 = Page(0) page1 = Page(1) page2 = Page(2) page0.changeMemoryFlag() page1.changeMemoryFlag() page2.changeMemoryFlag() self.aPcb = PCB(0,[page0,page1,page2],3,4,1,[Page(123)])
def test_load_a_program_pcb_creation_with_1_page(self): when(self.disco).getProgram("programa").thenReturn(self.program) when(self.mmu).getFrameSize().thenReturn(2) self.scope = Scope([Page(23)], [Page(45)]) when(self.mmu).getMemoryScope(self.program).thenReturn(self.scope) when(self.mmu).fromPageToAbsolutePosition(23).thenReturn(46) when(self.disco).getProgram("programa").thenReturn(self.program) self.progLoader.loadProcess("programa") self.assertEquals(self.progLoader.getNextId(), 2) verify(self.mmu, 1).getMemoryScope(self.program) self.assertEquals(self.ram.getDir(46), self.instruccion1) self.assertEquals(self.ram.getDir(47), self.instruccion2)
def test_when_fetching_last_instruction_then_pcbEnd_interruption(self): page0 = Page(0) page1 = Page(1) page0.changeMemoryFlag() page1.changeMemoryFlag() self.anotherPcb = PCB( 0, [page0, page1], 2, 4, 1, [123]) #The difference with aPcb, are their sizes... Arrange self.anotherPcb.runing() self.cpu.setPCB(self.anotherPcb) self.cpu.tick() # Act self.cpu.tick() self.cpu.tick() verify(self.interruptor, 1).kill(self.anotherPcb.getPid()) # Assert
def test_when_fetching_last_instruction_then_pcbEnd_interruption(self): page0 = Page(0) page1 = Page(1) page0.changeMemoryFlag() page1.changeMemoryFlag() self.anotherPcb = PCB(0,[page0,page1],2,4,1,[123]) #The difference with aPcb, are their sizes... Arrange self.anotherPcb.runing() self.cpu.setPCB(self.anotherPcb) self.cpu.tick() # Act self.cpu.tick() self.cpu.tick() verify(self.interruptor, 1).kill(self.anotherPcb.getPid()) # Assert
def setUp(self): self.memory = RAM(65535) self.mmu = MMU(1, self.memory) self.scheduler = Mock() self.hdd = Mock() self.queue = Mock() self.interruptor2 = Mock() self.interruptor = Mock() self.logger = Mock() self.semaphore = RLock() self.cpu = CPU(self.memory, self.interruptor, self.semaphore, self.mmu) self.cpu.setLogger(self.logger) self.clock = Clock(self.cpu) self.mov = InstCPU("Matar a Flanders") self.Instruction2 = InstCPU("Y Tambien A Selma") self.instructionIO = InstIO("Soy de IO", 0) self.memory.putDir(0, self.mov) self.memory.putDir(1, self.Instruction2) self.memory.putDir(2, self.instructionIO) page0 = Page(0) page1 = Page(1) page2 = Page(2) page0.changeMemoryFlag() page1.changeMemoryFlag() page2.changeMemoryFlag() self.aPcb = PCB(0, [page0, page1, page2], 3, 4, 1, [Page(123)])