class KernelTest(unittest.TestCase):

    def setUp(self):
        self.IO = Mock()
        self.clock = Mock()
        self.sem = Mock()
        self.kernel = Kernel(1000)
        self.kernel.disc = Mock()
        self.kernel.memory = Mock()
        self.kernel.scheduler = Mock()
        self.kernel.handler = Mock()
        self.kernel.cpu = Mock()
        self.kernel.clock = Mock()
        
    def test_startUp(self):
        self.kernel.startUp()
        verify(self.kernel.clock,times(1)).startUp()

    def test_getProgramasDelDisco(self):
        self.program = Mock()
        when(self.kernel.disc).getProgram("program").thenReturn(self.program)
        self.kernel.getProgramasDelDisco("program")
        verify(self.kernel.disc,times(1)).getProgram("program")
        assert (self.kernel.getProgramasDelDisco("program") == self.program)

    def test_run(self):
        self.kernel.run("program")
        verify(self.kernel.handler,times(1)).newIrq("program")     
Beispiel #2
0
instructionsP2 = [instruction3,instruction4]
instructionsP3 = [instruction5,instruction6]
instructionsP4 = [instruction7,instruction8]

prog1 = Program("Programa 1",instructionsP1)
##########################################

prog2 = Program("Programa 2",instructionsP2)
##########################################

prog3 = Program("Programa 3",instructionsP3)
##########################################

prog4 = Program("Programa 4",instructionsP4)
##########################################

kernel.getDisc().addProgram(prog1)
kernel.getDisc().addProgram(prog2)
kernel.getDisc().addProgram(prog3)
kernel.getDisc().addProgram(prog4)

kernel.startUp()
kernel.run("Programa 1")
kernel.run("Programa 2")
kernel.run("Programa 3")
kernel.run("Programa 4")
#time.sleep(1)
#kernel.getTable()[3].changePriority(2)
time.sleep(20)
kernel.shutDown()