class TestMemoryAdmin(unittest.TestCase):
    def setUp(self):
        self.memory = Memory()
        self.strategy = AsignacionContinua(self.memory)
        self.admin = MemoryAdmin(self.strategy)
        self.pcb = PCB(3, 4, 20, 40, 4)
        self.progr = Programa("un_programa")
        self.instr = Instruccion('Instruccion 1')
        self.progr.agregarInstruccion(self.instr)

    def test_save(self):
        self.admin.save(self.pcb, self.progr)
        self.assertEqual(511, self.memory.free_cells)

    def test_has_room_for(self):
        self.assertTrue(self.admin.has_room_for(12))

    def test_next_post_free(self):
        self.assertEqual(0, self.admin.next_post_free())

    def test_next_post(self):
        self.admin.save(self.pcb, self.progr)
        self.assertEqual(0, self.admin.next_post(self.pcb))

    def test_read_memory(self):
        self.admin.save(self.pcb, self.progr)
        self.assertEqual(self.instr, self.admin.read_memory(self.pcb))

    def test_delete_memory(self):
        self.admin.save(self.pcb, self.progr)
        self.admin.delete_memory(self.progr)
        self.assertEqual(512, self.memory.free_cells)
class TestMemoryAdmin(unittest.TestCase):
    def setUp(self):
        self.memory = Memory()
        self.strategy = AsignacionContinua(self.memory)
        self.admin = MemoryAdmin(self.strategy)
        self.pcb = PCB(3, 4, 20, 40, 4)
        self.progr = Programa("un_programa")
        self.instr = Instruccion('Instruccion 1')
        self.progr.agregarInstruccion(self.instr)

    def test_save(self):
        self.admin.save(self.pcb, self.progr)
        self.assertEqual(511, self.memory.free_cells)

    def test_has_room_for(self):
        self.assertTrue(self.admin.has_room_for(12))

    def test_next_post_free(self):
        self.assertEqual(0, self.admin.next_post_free())

    def test_next_post(self):
        self.admin.save(self.pcb, self.progr)
        self.assertEqual(0, self.admin.next_post(self.pcb))

    def test_read_memory(self):
        self.admin.save(self.pcb, self.progr)
        self.assertEqual(self.instr, self.admin.read_memory(self.pcb))

    def test_delete_memory(self):
        self.admin.save(self.pcb, self.progr)
        self.admin.delete_memory(self.progr)
        self.assertEqual(512, self.memory.free_cells)
 def setUp(self):
     self.memory = Memory()
     self.strategy = AsignacionContinua(self.memory)
     self.admin = MemoryAdmin(self.strategy)
     self.pcb = PCB(3, 4, 20, 40, 4)
     self.progr = Programa("un_programa")
     self.instr = Instruccion('Instruccion 1')
     self.progr.agregarInstruccion(self.instr)
Exemple #4
0
    def setUp(self):
        self.memory = Memory()
        self.asignacion_continua = AsignacionContinua(self.memory)
        self.paginacion = Paginacion(self.memory)
        self.pcb = PCB(2, 3, 6, 40, 4)

        self.progr = Programa("un_programa")
        self.instr = Instruccion('Instruccion 1')
        self.progr.agregarInstruccion(self.instr)
 def setUp(self):
     self.memory = Memory()
     self.strategy = AsignacionContinua(self.memory)
     self.admin = MemoryAdmin(self.strategy)
     self.pcb = PCB(3, 4, 20, 40, 4)
     self.progr = Programa("un_programa")
     self.instr = Instruccion('Instruccion 1')
     self.progr.agregarInstruccion(self.instr)
Exemple #6
0
class TestMemoryOrganize(unittest.TestCase):
    def setUp(self):
        self.memory = Memory()
        self.asignacion_continua = AsignacionContinua(self.memory)
        self.paginacion = Paginacion(self.memory)
        self.pcb = PCB(2, 3, 6, 40, 4)

        self.progr = Programa("un_programa")
        self.instr = Instruccion('Instruccion 1')
        self.progr.agregarInstruccion(self.instr)

    def test_has_run_for_asignacion_continua(self):
        self.assertTrue(self.asignacion_continua.has_room_for(10))

    def test_save_asignacion_continua(self):
        self.asignacion_continua.save(self.pcb, self.progr)
        self.assertEqual(511, self.memory.free_cells)

    def test_next_position_asignacion_continua(self):
        self.asignacion_continua.save(self.pcb, self.progr)
        result = self.asignacion_continua.next_position(self.pcb)
        self.assertEqual(0, result)

    def test_next_post_free_asignacion_continua(self):
        self.assertEqual(0, self.asignacion_continua.next_post_free())

    def test_compact(self):
        self.asignacion_continua.save(self.pcb, self.progr)
        self.asignacion_continua.next_position(self.pcb)
        self.asignacion_continua.has_room_for(1)
        self.assertEqual(512, self.memory.free_cells)

    def test_has_run_for_paginacion(self):
        self.assertTrue(self.paginacion.has_room_for(12))

    def test_next_position_paginacion(self):
        self.assertEqual(0, self.paginacion.next_position(self.pcb))

    def test_next_post_free_paginacion(self):
        self.assertEqual(0, self.paginacion.next_post_free())

    def test_save_paginacion(self):
        self.paginacion.save(self.pcb, self.progr)
        self.assertEqual(511, self.memory.free_cells)
Exemple #7
0
    def __init__(self):
        self.clock = Clock(2)
        self.clock.start()
        self.disc = Disc()
        self.program = Programa("a_program_name")
        self.program2 = Programa("another_program_name")
        self.program3 = Programa("yes_another_program_name")
        self.program4 = Programa("Hm.. blah")
        self.instruction1 = Instruccion("Instruccion 1")
        self.instruction2 = Instruccion("Instruccion 2")
        self.instruction3 = Instruccion("Instruccion 3")

        self.instruction4 = Instruccion("Instruccion 4")
        self.instruction5 = Instruccion("Instruccion 5")
        self.instruction6 = Instruccion("Instruccion 6")

        self.instruction7 = Instruccion("Instruccion 7")
        self.instruction8 = Instruccion("Instruccion 8")
        self.instruction9 = Instruccion("Instruccion 9")

        self.instruction10 = Instruccion("Instruccion 10")
        self.instruction11 = Instruccion("Instruccion 11")
        self.instruction12 = Instruccion("Instruccion 12")

        self.program.agregarInstruccion(self.instruction1)
        self.program.agregarInstruccion(self.instruction2)
        self.program.agregarInstruccion(self.instruction3)

        self.program2.agregarInstruccion(self.instruction4)
        self.program2.agregarInstruccion(self.instruction5)
        self.program2.agregarInstruccion(self.instruction6)

        self.program3.agregarInstruccion(self.instruction7)
        self.program3.agregarInstruccion(self.instruction8)
        self.program3.agregarInstruccion(self.instruction9)

        self.program4.agregarInstruccion(self.instruction10)
        self.program4.agregarInstruccion(self.instruction11)
        self.program4.agregarInstruccion(self.instruction12)

        self.memory = Memory()
        self.kernel = Kernel(self.memory, FileSystem(self.disc), self.clock)
        self.kernel.set_scheduler_policy()
        self.kernel.create_pcb(self.program, 0)
        self.kernel.create_pcb(self.program2, 1)
        self.kernel.create_pcb(self.program3, 2)
        self.kernel.create_pcb(self.program4, 3)
        self.cpu = Cpu(self.kernel)
class TestsCpu(unittest.TestCase):

    def setUp(self):
        self.clock = Clock(4)
        self.clock.start()
        self.disc = Disc()
        self.program = Programa("a_program_name")
        self.program2 = Programa("another_program_name")
        self.program3 = Programa("yes_another_program_name")
        self.program4 = Programa("Hm.. blah")
        self.instruction1 = Instruccion("Instruccion 1")
        self.instruction2 = Instruccion("Instruccion 2")
        self.instruction3 = Instruccion("Instruccion 3")

        self.instruction4 = Instruccion("Instruccion 4")
        self.instruction5 = Instruccion("Instruccion 5")
        self.instruction6 = Instruccion("Instruccion 6")

        self.instruction7 = Instruccion("Instruccion 7")
        self.instruction8 = Instruccion("Instruccion 8")
        self.instruction9 = Instruccion("Instruccion 9")

        self.instruction10 = Instruccion("Instruccion 10")
        self.instruction11 = Instruccion("Instruccion 11")
        self.instruction12 = Instruccion("Instruccion 12")

        self.program.agregarInstruccion(self.instruction1)
        self.program.agregarInstruccion(self.instruction2)
        self.program.agregarInstruccion(self.instruction3)

        self.program2.agregarInstruccion(self.instruction4)
        self.program2.agregarInstruccion(self.instruction5)
        self.program2.agregarInstruccion(self.instruction6)

        self.program3.agregarInstruccion(self.instruction7)
        self.program3.agregarInstruccion(self.instruction8)
        self.program3.agregarInstruccion(self.instruction9)

        self.program4.agregarInstruccion(self.instruction10)
        self.program4.agregarInstruccion(self.instruction11)
        self.program4.agregarInstruccion(self.instruction12)

        self.memory = Memory()
        self.kernel = Kernel(self.memory, FileSystem(self.disc), self.clock)
        self.kernel.set_scheduler_policy()
        self.kernel.create_pcb(self.program, 0)
        self.kernel.create_pcb(self.program2, 1)
        self.kernel.create_pcb(self.program3, 2)
        self.kernel.create_pcb(self.program4, 3)
        self.cpu = Cpu(self.kernel)

    def test_cpu_run_instruction(self):
        self.cpu.run()
        self.assertTrue(self.cpu.output.contains("Instruccion 1"))
class TestsCpu(unittest.TestCase):
    def setUp(self):
        self.clock = Clock(4)
        self.clock.start()
        self.disc = Disc()
        self.program = Programa("a_program_name")
        self.program2 = Programa("another_program_name")
        self.program3 = Programa("yes_another_program_name")
        self.program4 = Programa("Hm.. blah")
        self.instruction1 = Instruccion("Instruccion 1")
        self.instruction2 = Instruccion("Instruccion 2")
        self.instruction3 = Instruccion("Instruccion 3")

        self.instruction4 = Instruccion("Instruccion 4")
        self.instruction5 = Instruccion("Instruccion 5")
        self.instruction6 = Instruccion("Instruccion 6")

        self.instruction7 = Instruccion("Instruccion 7")
        self.instruction8 = Instruccion("Instruccion 8")
        self.instruction9 = Instruccion("Instruccion 9")

        self.instruction10 = Instruccion("Instruccion 10")
        self.instruction11 = Instruccion("Instruccion 11")
        self.instruction12 = Instruccion("Instruccion 12")

        self.program.agregarInstruccion(self.instruction1)
        self.program.agregarInstruccion(self.instruction2)
        self.program.agregarInstruccion(self.instruction3)

        self.program2.agregarInstruccion(self.instruction4)
        self.program2.agregarInstruccion(self.instruction5)
        self.program2.agregarInstruccion(self.instruction6)

        self.program3.agregarInstruccion(self.instruction7)
        self.program3.agregarInstruccion(self.instruction8)
        self.program3.agregarInstruccion(self.instruction9)

        self.program4.agregarInstruccion(self.instruction10)
        self.program4.agregarInstruccion(self.instruction11)
        self.program4.agregarInstruccion(self.instruction12)

        self.memory = Memory()
        self.kernel = Kernel(self.memory, FileSystem(self.disc), self.clock)
        self.kernel.set_scheduler_policy()
        self.kernel.create_pcb(self.program, 0)
        self.kernel.create_pcb(self.program2, 1)
        self.kernel.create_pcb(self.program3, 2)
        self.kernel.create_pcb(self.program4, 3)
        self.cpu = Cpu(self.kernel)

    def test_cpu_run_instruction(self):
        self.cpu.run()
        self.assertTrue(self.cpu.output.contains("Instruccion 1"))