コード例 #1
0
def libcore_info_date_test():
  date = datetime.date(day=24, month=12, year=2008)
  info = LibInfo('test.library', 42, 3, date, 36, 42)
  txt = str(info)
  assert txt == "'test.library' 42.3 +36 -42 (24.12.2008)"
  assert info.get_id_string() == 'test.library 42.3 (24.12.2008)\r\n'
  assert info.get_date() == date
コード例 #2
0
def libcore_info_idstr_test():
  id_string = 'test.library 42.3 (24.12.2008)\r\n'
  info = LibInfo.parse_id_string(id_string, 36, 42)
  txt = str(info)
  assert txt == "'test.library' 42.3 +36 -42 (24.12.2008)"
  assert info.get_id_string() == id_string
  date = datetime.date(day=24, month=12, year=2008)
  assert info.get_date() == date
  date2 = LibInfo.extract_date(id_string)
  assert info.get_date() == date2
  info2 = LibInfo.parse_id_string(id_string, 36, 42)
  assert info == info2
コード例 #3
0
ファイル: mgr.py プロジェクト: krutten/amitools
 def make_lib_name(self,
                   name,
                   version=0,
                   revision=0,
                   fake=False,
                   lib_cfg=None):
     date = datetime.date(day=7, month=7, year=2007)
     info = LibInfo(name, version, revision, date)
     return self.make_lib(info, fake, lib_cfg)
コード例 #4
0
def libcore_create_lib_fake_with_fd_test():
    mem, traps, alloc, ctx = setup()
    impl = None
    # create info for lib
    date = datetime.date(2012, 11, 12)
    info = LibInfo('vamostest.library', 42, 3, date)
    # create lib
    creator = LibCreator(alloc, traps)
    lib = creator.create_lib(info, ctx, impl)
    # free lib
    lib.free()
    assert alloc.is_all_free()
コード例 #5
0
ファイル: mgr.py プロジェクト: jukeks/amitools
 def bootstrap_exec(self, exec_info=None, version=0, revision=0):
     """setup exec library"""
     if exec_info is None:
         date = datetime.date(day=7, month=7, year=2007)
         exec_info = LibInfo('exec.library', version, revision, date)
     # make sure its an exec info
     assert exec_info.get_name() == 'exec.library'
     # create vlib
     vlib = self._create_vlib(exec_info, False)
     assert vlib
     assert vlib.impl
     # setup exec_lib
     lib_base = vlib.get_library().get_addr()
     self.exec_lib = ExecLibrary(self.mem, lib_base)
     # store lib base
     self.machine.set_zero_mem(0, lib_base)
     # with exec_lib in place we can add exec's vlib
     self._add_vlib(vlib)
     # inc exec's open cnt so lib gets never expunged
     self.exec_lib.lib_node.inc_open_cnt()
     return vlib
コード例 #6
0
def libcore_create_lib_profile_test():
    mem, traps, alloc, ctx = setup()
    impl = VamosTestLibrary()
    # create info for lib
    date = datetime.date(2012, 11, 12)
    info = LibInfo('vamostest.library', 42, 3, date)
    # create lib
    creator = LibCreator(alloc, traps)
    lib = creator.create_lib(info, ctx, impl, do_profile=True)
    # free lib
    lib.free()
    assert alloc.is_all_free()
コード例 #7
0
def libcore_create_lib_label_mgr_test():
    mem, traps, alloc, ctx = setup()
    impl = VamosTestLibrary()
    label_mgr = LabelManager()
    # create info for lib
    date = datetime.date(2012, 11, 12)
    info = LibInfo('vamostest.library', 42, 3, date)
    # create lib
    creator = LibCreator(alloc, traps, label_mgr)
    lib = creator.create_lib(info, ctx, impl)
    # free lib
    lib.free()
    assert alloc.is_all_free()
コード例 #8
0
def libcore_create_lib_fake_without_fd_test():
    mem, traps, alloc, ctx = setup()
    impl = None
    # create info for lib
    date = datetime.date(2012, 11, 12)
    info = LibInfo('foo.library', 42, 3, date)
    # create lib
    creator = LibCreator(alloc, traps)
    lib = creator.create_lib(info, ctx, impl)
    assert lib.get_fd().get_neg_size() == 30
    assert lib.get_library().neg_size == 32
    # free lib
    lib.free()
    assert alloc.is_all_free()
コード例 #9
0
ファイル: libcore_create.py プロジェクト: kowoba/amitools
def libcore_create_lib_profile_test():
    mem, traps, alloc, ctx = setup()
    impl = VamosTestLibrary()
    # create info for lib
    date = datetime.date(2012, 11, 12)
    info = LibInfo('vamostest.library', 42, 3, date)
    # create lib
    pc = LibProfilerConfig(profiling=True, all_libs=True)
    profiler = LibProfiler(pc)
    creator = LibCreator(alloc, traps, profiler=profiler)
    lib = creator.create_lib(info, ctx, impl)
    prof = profiler.get_profile('vamostest.library')
    assert prof
    # free lib
    lib.free()
    assert alloc.is_all_free()
コード例 #10
0
def libcore_create_lib_label_test():
    mem, traps, alloc, ctx = setup()
    impl = None
    # create info for lib
    date = datetime.date(2012, 11, 12)
    info = LibInfo('vamostest.library', 42, 3, date)
    # create lib
    creator = LibCreator(alloc, traps)
    lib = creator.create_lib(info, ctx, impl)
    # check label
    assert alloc.get_label_mgr()
    label = lib.get_library()._label
    assert label
    assert label.fd == lib.get_fd()
    # free lib
    lib.free()
    assert alloc.is_all_free()
コード例 #11
0
def libcore_create_lib_fake_without_fd_cfg_test():
    mem, traps, alloc, ctx = setup()
    impl = None
    # create info for lib
    date = datetime.date(2012, 11, 12)
    info = LibInfo('foo.library', 42, 3, date)
    # lib_cfg
    Cfg = collections.namedtuple('Cfg', ['num_fake_funcs'])
    lib_cfg = Cfg(10)
    # create lib
    creator = LibCreator(alloc, traps)
    lib = creator.create_lib(info, ctx, impl, lib_cfg)
    assert lib.get_fd().get_neg_size() == 66
    assert lib.get_library().neg_size == 68
    # free lib
    lib.free()
    assert alloc.is_all_free()
コード例 #12
0
def libcore_create_lib_profile_test():
    mem, traps, alloc, ctx = setup()
    impl = VamosTestLibrary()
    # create info for lib
    date = datetime.date(2012, 11, 12)
    info = LibInfo('vamostest.library', 42, 3, date)
    # create lib
    lib_profiler = LibProfiler(names=["all"])
    creator = LibCreator(alloc, traps, lib_profiler=lib_profiler)
    lib_profiler.setup()
    lib = creator.create_lib(info, ctx, impl)
    profiler = creator.get_profiler()
    prof = profiler.get_profile('vamostest.library')
    assert prof
    assert lib.profile
    # free lib
    lib.free()
    assert alloc.is_all_free()
コード例 #13
0
def libcore_create_lib_default_test():
    mem, traps, alloc, ctx = setup()
    impl = VamosTestLibrary()
    # create info for lib
    date = datetime.date(2012, 11, 12)
    info = LibInfo('vamostest.library', 42, 3, date)
    # create lib
    creator = LibCreator(alloc, traps)
    vlib = creator.create_lib(info, ctx, impl)
    assert impl.get_cnt() == 0
    # open
    vlib.open()
    assert impl.get_cnt() == 1
    # close
    vlib.close()
    assert impl.get_cnt() == 0
    # free lib
    vlib.free()
    assert impl.get_cnt() is None
    assert alloc.is_all_free()