Esempio n. 1
0
def libnative_loader_load_ami_lib_test(buildlibnix):
  # path mgr mock
  lib_file = buildlibnix.make_lib('testnix')

  class PathMgrMock:
    def ami_to_sys_path(self, lock, ami_path, mustExist=True):
      if ami_path == 'LIBS:testnix.library':
        return lib_file
  pm = PathMgrMock()
  loader, segload, alloc, mem, sp, exec_lib = setup(pm)
  # load
  lib_base, seglist_baddr = loader.load_ami_lib("testnix.library", run_sp=sp)
  assert lib_base > 0
  assert seglist_baddr > 0
  info = segload.get_info(seglist_baddr)
  assert info
  assert info.ami_file == 'LIBS:testnix.library'
  assert info.sys_file == lib_file
  # we have to manually clean the lib here (as Exec FreeMem() does not work)
  lib = Library(mem, lib_base, alloc)
  lib.free()
  # cleanup
  segload.unload_seglist(seglist_baddr)
  assert segload.shutdown() == 0
  exec_lib.free()
  assert alloc.is_all_free()
Esempio n. 2
0
def libnative_loader_load_ami_lib_test(buildlibnix):
    # path mgr mock
    lib_file = buildlibnix.make_lib('testnix')

    class PathMgrMock:
        def ami_to_sys_path(self, lock, ami_path, mustExist=True):
            if ami_path == 'LIBS:testnix.library':
                return lib_file

    pm = PathMgrMock()
    loader, segload, alloc, mem, sp, exec_lib = setup(pm)
    # load
    lib_base, seglist_baddr = loader.load_ami_lib("testnix.library", run_sp=sp)
    assert lib_base > 0
    assert seglist_baddr > 0
    info = segload.get_info(seglist_baddr)
    assert info
    assert info.ami_file == 'LIBS:testnix.library'
    assert info.sys_file == lib_file
    # we have to manually clean the lib here (as Exec FreeMem() does not work)
    lib = Library(mem, lib_base, alloc)
    lib.free()
    # cleanup
    segload.unload_seglist(seglist_baddr)
    assert segload.shutdown() == 0
    exec_lib.free()
    assert alloc.is_all_free()
Esempio n. 3
0
def libnative_loader_load_sys_lib_test(buildlibnix):
  loader, segload, alloc, mem, sp, exec_lib = setup()
  # load
  lib_file = buildlibnix.make_lib('testnix')
  lib_base, seglist_baddr = loader.load_sys_lib(lib_file, run_sp=sp)
  assert lib_base > 0
  assert seglist_baddr > 0
  # we have to manually clean the lib here (as Exec FreeMem() does not work)
  lib = Library(mem, lib_base, alloc)
  lib.free()
  # cleanup
  segload.unload_seglist(seglist_baddr)
  assert segload.shutdown() == 0
  exec_lib.free()
  assert alloc.is_all_free()
Esempio n. 4
0
def libnative_loader_load_sys_lib_test(buildlibnix):
    loader, segload, alloc, mem, sp, exec_lib = setup()
    # load
    lib_file = buildlibnix.make_lib('testnix')
    lib_base, seglist_baddr = loader.load_sys_lib(lib_file, run_sp=sp)
    assert lib_base > 0
    assert seglist_baddr > 0
    # we have to manually clean the lib here (as Exec FreeMem() does not work)
    lib = Library(mem, lib_base, alloc)
    lib.free()
    # cleanup
    segload.unload_seglist(seglist_baddr)
    assert segload.shutdown() == 0
    exec_lib.free()
    assert alloc.is_all_free()
Esempio n. 5
0
def libnative_mgr_test(buildlibnix):
  if buildlibnix.flavor not in ('gcc', 'gcc-dbg'):
    pytest.skip("only single base lib supported")
  log_libmgr.setLevel(logging.INFO)
  machine, alloc, sp, mem, exec_lib = setup()
  # load
  lib_file = buildlibnix.make_lib('testnix')

  class PathMgrMock:
    def ami_to_sys_path(self, lock, ami_path, mustExist=True):
      if ami_path == 'LIBS:testnix.library':
        return lib_file

  pm = PathMgrMock()
  segload = SegmentLoader(alloc, pm)
  mgr = ALibManager(machine, alloc, segload)
  # open_lib
  lib_base = mgr.open_lib("testnix.library", run_sp=sp)
  assert lib_base > 0
  assert mgr.is_base_addr(lib_base)
  lib_info = mgr.get_lib_info_for_name("testnix.library")
  assert lib_info
  assert lib_info.is_base_addr(lib_base)
  # close lib
  seglist = mgr.close_lib(lib_base, run_sp=sp)
  assert seglist == 0
  lib_info = mgr.get_lib_info_for_name("testnix.library")
  assert lib_info
  assert not lib_info.is_base_addr(lib_base)
  # expunge lib
  left = mgr.shutdown(run_sp=sp)
  assert left == 0
  assert not mgr.is_base_addr(lib_base)
  lib_info = mgr.get_lib_info_for_name("testnix.library")
  assert not lib_info
  # we have to manually clean the lib here (as Exec FreeMem() does not work)
  lib = Library(mem, lib_base, alloc)
  lib.free()
  # cleanup
  exec_lib.free()
  assert alloc.is_all_free()
Esempio n. 6
0
def libnative_mgr_test(buildlibnix):
    if buildlibnix.flavor not in ('gcc', 'gcc-dbg'):
        pytest.skip("only single base lib supported")
    log_libmgr.setLevel(logging.INFO)
    machine, alloc, sp, mem, exec_lib = setup()
    # load
    lib_file = buildlibnix.make_lib('testnix')

    class PathMgrMock:
        def ami_to_sys_path(self, lock, ami_path, mustExist=True):
            if ami_path == 'LIBS:testnix.library':
                return lib_file

    pm = PathMgrMock()
    segload = SegmentLoader(alloc, pm)
    mgr = ALibManager(machine, alloc, segload)
    # open_lib
    lib_base = mgr.open_lib("testnix.library", run_sp=sp)
    assert lib_base > 0
    assert mgr.is_base_addr(lib_base)
    lib_info = mgr.get_lib_info_for_name("testnix.library")
    assert lib_info
    assert lib_info.is_base_addr(lib_base)
    # close lib
    seglist = mgr.close_lib(lib_base, run_sp=sp)
    assert seglist == 0
    lib_info = mgr.get_lib_info_for_name("testnix.library")
    assert lib_info
    assert not lib_info.is_base_addr(lib_base)
    # expunge lib
    left = mgr.shutdown(run_sp=sp)
    assert left == 0
    assert not mgr.is_base_addr(lib_base)
    lib_info = mgr.get_lib_info_for_name("testnix.library")
    assert not lib_info
    # we have to manually clean the lib here (as Exec FreeMem() does not work)
    lib = Library(mem, lib_base, alloc)
    lib.free()
    # cleanup
    exec_lib.free()
    assert alloc.is_all_free()