Exemplo n.º 1
0
def libnative_libfuncs_close_library_test():
    machine = Machine()
    mem = machine.get_mem()
    cpu = machine.get_cpu()
    traps = machine.get_traps()
    sp = machine.get_ram_begin() - 4
    alloc = MemoryAlloc.for_machine(machine)
    segloader = SegmentLoader(alloc)
    # new lib
    lib = Library.alloc(alloc, name="my.library", id_string="bla", neg_size=36)
    lib.new_lib()
    # setup seglist
    seglist = SegList.alloc(alloc, [64])
    segloader.register_seglist(seglist.get_baddr())

    # setup expunge func

    def close_func(op, pc):
        # return my seglist
        cpu.w_reg(REG_D0, seglist.get_baddr())

    trap_id = traps.setup(close_func, auto_rts=True)
    exp_addr = lib.get_addr() - 12
    mem.w16(exp_addr, trap_id | 0xA000)
    # add lib
    lf = LibFuncs(machine, alloc)
    sl = lf.close_library(lib.get_addr(), segloader, run_sp=sp)
    assert seglist.get_baddr() == sl
    # cleanup
    lib.free()
    assert alloc.is_all_free()
    assert segloader.shutdown() == 0
Exemplo n.º 2
0
def libnative_libfuncs_close_library_test():
  machine = Machine()
  mem = machine.get_mem()
  cpu = machine.get_cpu()
  traps = machine.get_traps()
  sp = machine.get_ram_begin() - 4
  alloc = MemoryAlloc.for_machine(machine)
  segloader = SegmentLoader(alloc)
  # new lib
  lib = Library.alloc(alloc, "my.library", "bla", 36)
  lib.setup()
  # setup seglist
  seglist = SegList.alloc(alloc, [64])
  segloader.register_seglist(seglist.get_baddr())
  # setup expunge func

  def close_func(op, pc):
    # return my seglist
    cpu.w_reg(REG_D0, seglist.get_baddr())
  trap_id = traps.setup(close_func, auto_rts=True)
  exp_addr = lib.get_addr() - 12
  mem.w16(exp_addr, trap_id | 0xa000)
  # add lib
  lf = LibFuncs(machine, alloc)
  sl = lf.close_library(lib.get_addr(), segloader, run_sp=sp)
  assert seglist.get_baddr() == sl
  # cleanup
  lib.free()
  assert alloc.is_all_free()
  assert segloader.shutdown() == 0
Exemplo n.º 3
0
def loader_segload_register(mem_alloc):
    mem, alloc = mem_alloc
    loader = SegmentLoader(alloc)
    # my seglist
    seglist = SegList.alloc(mem, [64])
    baddr = seglist.get_baddr()
    loader.register_seglist(baddr)
    # unload registered seglist
    assert loader.unload_seglist(baddr)
    assert loader.shutdown() == 0
    assert alloc.is_all_free()
Exemplo n.º 4
0
def loader_segload_register(mem_alloc):
  mem, alloc = mem_alloc
  loader = SegmentLoader(alloc)
  # my seglist
  seglist = SegList.alloc(mem, [64])
  baddr = seglist.get_baddr()
  loader.register_seglist(baddr)
  # unload registered seglist
  assert loader.unload_seglist(baddr)
  assert loader.shutdown() == 0
  assert alloc.is_all_free()
Exemplo n.º 5
0
def loader_segload_sys_load_unload_test(buildlibnix, mem_alloc):
    mem, alloc = mem_alloc
    lib_file = buildlibnix.make_lib('testnix')
    loader = SegmentLoader(alloc)
    # load
    baddr = loader.load_sys_seglist(lib_file)
    assert baddr > 0
    info = loader.get_info(baddr)
    assert info.seglist.get_baddr() == baddr
    # unload
    ok = loader.unload_seglist(baddr)
    assert ok
    info = loader.get_info(baddr)
    assert info is None
    assert loader.shutdown() == 0
    assert alloc.is_all_free()
Exemplo n.º 6
0
def loader_segload_sys_load_unload_test(buildlibnix, mem_alloc):
  mem, alloc = mem_alloc
  lib_file = buildlibnix.make_lib('testnix')
  loader = SegmentLoader(alloc)
  # load
  baddr = loader.load_sys_seglist(lib_file)
  assert baddr > 0
  info = loader.get_info(baddr)
  assert info.seglist.get_baddr() == baddr
  # unload
  ok = loader.unload_seglist(baddr)
  assert ok
  info = loader.get_info(baddr)
  assert info is None
  assert loader.shutdown() == 0
  assert alloc.is_all_free()
Exemplo n.º 7
0
def loader_segload_ami_load_unload_test(buildlibnix, mem_alloc):
  mem, alloc = mem_alloc
  lib_file = buildlibnix.make_lib('testnix')

  class PathMgrMock:
    def ami_to_sys_path(self, lock, ami_path, mustExist=True):
      if ami_path == "blu":
        return lib_file
  pm = PathMgrMock()
  loader = SegmentLoader(alloc, path_mgr=pm)
  # load
  baddr = loader.load_ami_seglist("blu")
  assert baddr > 0
  info = loader.get_info(baddr)
  assert info.seglist.get_baddr() == baddr
  # unload
  ok = loader.unload_seglist(baddr)
  assert ok
  info = loader.get_info(baddr)
  assert info is None
  assert loader.shutdown() == 0
  assert alloc.is_all_free()
Exemplo n.º 8
0
def loader_segload_ami_load_unload_test(buildlibnix, mem_alloc):
    mem, alloc = mem_alloc
    lib_file = buildlibnix.make_lib('testnix')

    class PathMgrMock:
        def ami_to_sys_path(self, lock, ami_path, mustExist=True):
            if ami_path == "blu":
                return lib_file

    pm = PathMgrMock()
    loader = SegmentLoader(alloc, path_mgr=pm)
    # load
    baddr = loader.load_ami_seglist("blu")
    assert baddr > 0
    info = loader.get_info(baddr)
    assert info.seglist.get_baddr() == baddr
    # unload
    ok = loader.unload_seglist(baddr)
    assert ok
    info = loader.get_info(baddr)
    assert info is None
    assert loader.shutdown() == 0
    assert alloc.is_all_free()