# Path: sibyl/commons.py
# class HeaderFile(object):
#     """Abstract representation of a Header file"""
# 
#     def __init__(self, header_data, ctype_manager):
#         """Parse @header_data to fill @ctype_manager
#         @header_data: str of a C-like header file
#         @ctype_manager: miasm2.core.objc.CTypesManager instance"""
#         self.data = header_data
#         self.ctype_manager = ctype_manager
# 
#         self.ast = self.parse_header(header_data)
#         self.ctype_manager.types_ast.add_c_decl(header_data)
#         self.functions = {} # function name -> FuncPrototype
# 
#         if pycparser is None:
#             raise ImportError("pycparser module is needed to parse header file")
#         self.parse_functions()
# 
#     @staticmethod
#     def parse_header(header_data):
#         """Return the AST corresponding to @header_data
#         @header_data: str of a C-like header file
#         """
#         # We can't use add_c_decl, because we need the AST to get back
#         # function's arguments name
#         parser = pycparser.c_parser.CParser()
#         return c_to_ast(parser, header_data)
# 
#     def parse_functions(self):
#         """Search for function declarations"""
# 
#         for ext in self.ast.ext:
#             if not (isinstance(ext, pycparser.c_ast.Decl) and
#                     isinstance(ext.type, (pycparser.c_ast.FuncDecl,
#                                           pycparser.c_ast.FuncDef))):
#                 continue
#             func_name = ext.name
#             objc_func = self.ctype_manager.get_objc(CTypeFunc(func_name))
# 
#             args_order = []
#             args = {}
#             for i, param in enumerate(ext.type.args.params):
#                 args_order.append(param.name)
#                 args[param.name] = objc_func.args[i][1]
# 
#             self.functions[func_name] = FuncPrototype(func_name,
#                                                       objc_func.type_ret,
#                                                       *args_order, **args)


import random
    import pycparser
from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE
from miasm2.expression.modint import mod_size2int
from miasm2.expression.simplifications import expr_simp
    from miasm2.core.objc import CTypesManagerNotPacked, CHandler
    from miasm2.core.ctypesmngr import CAstTypes
    from miasm2.arch.x86.ctype import CTypeAMD64_unk
from sibyl.commons import HeaderFile
#
# You should have received a copy of the GNU General Public License
# along with Sibyl. If not, see <http://www.gnu.org/licenses/>.


try:
except ImportError:
    pycparser = None
else:



class Test(object):
    "Main class for tests"

    # Elements to override

    func = ""   # Possible function if test passes
    tests = [] # List of tests (init, check) to pass
    reset_mem = True # Reset memory between tests

    def init(self):
        "Called for setting up the test case"
        pass

    def check(self):
        """Called to check test result
        Return True if all checks are passed"""
        return True


# Path: sibyl/commons.py
# class HeaderFile(object):
#     """Abstract representation of a Header file"""
# 
#     def __init__(self, header_data, ctype_manager):
#         """Parse @header_data to fill @ctype_manager
#         @header_data: str of a C-like header file
#         @ctype_manager: miasm2.core.objc.CTypesManager instance"""
#         self.data = header_data
#         self.ctype_manager = ctype_manager
# 
#         self.ast = self.parse_header(header_data)
#         self.ctype_manager.types_ast.add_c_decl(header_data)
#         self.functions = {} # function name -> FuncPrototype
# 
#         if pycparser is None:
#             raise ImportError("pycparser module is needed to parse header file")
#         self.parse_functions()
# 
#     @staticmethod
#     def parse_header(header_data):
#         """Return the AST corresponding to @header_data
#         @header_data: str of a C-like header file
#         """
#         # We can't use add_c_decl, because we need the AST to get back
#         # function's arguments name
#         parser = pycparser.c_parser.CParser()
#         return c_to_ast(parser, header_data)
# 
#     def parse_functions(self):
#         """Search for function declarations"""
# 
#         for ext in self.ast.ext:
#             if not (isinstance(ext, pycparser.c_ast.Decl) and
#                     isinstance(ext.type, (pycparser.c_ast.FuncDecl,
#                                           pycparser.c_ast.FuncDef))):
#                 continue
#             func_name = ext.name
#             objc_func = self.ctype_manager.get_objc(CTypeFunc(func_name))
# 
#             args_order = []
#             args = {}
#             for i, param in enumerate(ext.type.args.params):
#                 args_order.append(param.name)
#                 args[param.name] = objc_func.args[i][1]
# 
#             self.functions[func_name] = FuncPrototype(func_name,
#                                                       objc_func.type_ret,
#                                                       *args_order, **args)


# Path: sibyl/test/test.py
import random
    import pycparser
from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE
from miasm2.expression.modint import mod_size2int
from miasm2.expression.simplifications import expr_simp
    from miasm2.core.objc import CTypesManagerNotPacked, CHandler
    from miasm2.core.ctypesmngr import CAstTypes
    from miasm2.arch.x86.ctype import CTypeAMD64_unk
from sibyl.commons import HeaderFile

#
# You should have received a copy of the GNU General Public License
# along with Sibyl. If not, see <http://www.gnu.org/licenses/>.


try:
except ImportError:
    pycparser = None
else:



class Test(object):
    "Main class for tests"

    # Elements to override

    func = ""   # Possible function if test passes
    tests = [] # List of tests (init, check) to pass
    reset_mem = True # Reset memory between tests

    def init(self):
        "Called for setting up the test case"
        pass

    def check(self):
        """Called to check test result
        Return True if all checks are passed"""
        return True


    def reset_full(self):