示例#1
0
 def _check_unserialize_sum(cls, state):
     codegen = JITCPUCodegen('other_codegen')
     library = codegen.unserialize_library(state)
     ptr = library.get_pointer_to_function("sum")
     assert ptr, ptr
     cfunc = ctypes_sum_ty(ptr)
     res = cfunc(2, 3)
     assert res == 5, res
示例#2
0
    def test_cache_disabled_inspection(self):
        """
        """
        library = self.compile_module(asm_sum_outer, asm_sum_inner)
        library.enable_object_caching()
        state = library.serialize_using_object_code()

        # exercise the valid behavior
        with warnings.catch_warnings(record=True) as w:
            old_llvm = library.get_llvm_str()
            old_asm = library.get_asm_str()
            library.get_function_cfg('sum')
        self.assertEqual(len(w), 0)

        # unserialize
        codegen = JITCPUCodegen('other_codegen')
        library = codegen.unserialize_library(state)

        # the inspection methods would warn and give incorrect result
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            self.assertNotEqual(old_llvm, library.get_llvm_str())
        self.assertEqual(len(w), 1)
        self.assertIn("Inspection disabled", str(w[0].message))

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            self.assertNotEqual(library.get_asm_str(), old_asm)
        self.assertEqual(len(w), 1)
        self.assertIn("Inspection disabled", str(w[0].message))

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            with self.assertRaises(NameError) as raises:
                library.get_function_cfg('sum')
        self.assertEqual(len(w), 1)
        self.assertIn("Inspection disabled", str(w[0].message))
        self.assertIn("sum", str(raises.exception))
示例#3
0
 def setUp(self):
     global_compiler_lock.acquire()
     self.codegen = JITCPUCodegen('test_codegen')
示例#4
0
 def test_magic_tuple(self):
     tup = self.codegen.magic_tuple()
     pickle.dumps(tup)
     cg2 = JITCPUCodegen('xxx')
     self.assertEqual(cg2.magic_tuple(), tup)
示例#5
0
 def setUp(self):
     self.codegen = JITCPUCodegen('test_codegen')