示例#1
0
    def run(self):
        builder = build.Builder(self.project,
            os.path.join("/tmp", self.project.get_name() + ".h"))

        build.write_header_file(builder)
        builder.write_to_file()

        tester = base.tester.Tester()
        tester.prepare_writer = self.prepare_writer
        tester.args = [ "-I", os.path.join(paths.KAIRA_ROOT, paths.CAILIE_INCLUDE_DIR),
                        "-I", self.project.root_directory ]

        if self.project.get_build_with_octave():
            import ptp # To avoid cyclic import
            tester.args += [ "-I", os.path.join(paths.KAIRA_ROOT, paths.CAOCTAVE_INCLUDE_DIR) ]
            tester.args += ptp.get_config("Octave", "INCFLAGS").split()

        if self.project.build_target == "simrun":
            tester.args += [ "-I", os.path.join(paths.KAIRA_ROOT, paths.CASIMRUN_INCLUDE_DIR) ]

        tester.args += self.project.get_build_option("CFLAGS").split()
        tester.run()

        if tester.stderr:
            raise utils.PtpException(tester.stderr)

        for t in self.types.values():
            t.add_checks(tester)

        for check in self.checks:
            tester.add(check)

        check = tester.run()
        if check is not None:
            check.throw_exception()
示例#2
0
文件: checker.py 项目: Palasekm/Kaira
    def run(self):
        builder = build.Builder(self.project,
            os.path.join("/tmp", self.project.get_name() + ".h"))

        build.write_header_file(builder)
        builder.write_to_file()

        tester = base.tester.Tester()
        tester.prepare_writer = self.prepare_writer
        tester.args = [ "-I", os.path.join(paths.KAIRA_ROOT, paths.CAILIE_INCLUDE_DIR),
                        "-I", self.project.root_directory ]

        if self.project.get_build_with_octave():
            import ptp # To avoid cyclic import
            tester.args += [ "-I", os.path.join(paths.KAIRA_ROOT, paths.CAOCTAVE_INCLUDE_DIR) ]
            tester.args += ptp.get_config("Octave", "INCFLAGS").split()

        if self.project.build_target == "simrun":
            tester.args += [ "-I", os.path.join(paths.KAIRA_ROOT, paths.CASIMRUN_INCLUDE_DIR) ]

        tester.args += self.project.get_build_option("CFLAGS").split()
        tester.run()

        if tester.stderr:
            raise utils.PtpException(tester.stderr)

        for t in self.types.values():
            t.add_checks(tester)

        for expr, decls, return_type, source, message in self.expressions:
            check = CheckStatement(expr + ";", decls, source=source)
            if message:
                check.own_message = message
            tester.add(check)
            check = CheckStatement("return (" + expr + ");", decls, return_type, source)
            if message:
                check.own_message = message
            else:
                check.own_message = "Invalid type of expression"
            tester.add(check)

        check = tester.run()
        if check is not None:
            check.throw_exception()
示例#3
0
文件: checker.py 项目: Kobzol/kaira
    def run(self):
        builder = build.Builder(self.project, os.path.join("/tmp", self.project.get_name() + ".h"))

        build.write_header_file(builder)
        builder.write_to_file()

        tester = base.tester.Tester()
        tester.prepare_writer = self.prepare_writer
        tester.args = [
            "-I",
            os.path.join(paths.KAIRA_ROOT, paths.CAILIE_INCLUDE_DIR),
            "-I",
            self.project.root_directory,
        ]

        if self.project.get_build_with_octave():
            import ptp  # To avoid cyclic import

            tester.args += ["-I", os.path.join(paths.KAIRA_ROOT, paths.CAOCTAVE_INCLUDE_DIR)]
            tester.args += ptp.get_config("Octave", "INCFLAGS").split()

        if self.project.build_target == "simrun":
            tester.args += ["-I", os.path.join(paths.KAIRA_ROOT, paths.CASIMRUN_INCLUDE_DIR)]

        tester.args += self.project.get_build_option("CFLAGS").split()
        tester.run()

        if tester.stderr:
            raise utils.PtpException(tester.stderr)

        for t in self.types.values():
            t.add_checks(tester)

        for check in self.checks:
            tester.add(check)

        check = tester.run()
        if check is not None:
            check.throw_exception()
示例#4
0
文件: checker.py 项目: Palasekm/Kaira
    def add_checks(self, tester):
        var = tester.new_id()

        source = min(self.sources)
        check = CheckStatement("{0} *{1};".format(self.name, tester.new_id()), source=source)
        check.own_message = "Invalid type '{0}'".format(self.name)
        tester.add(check)

        message = "Function '{0}' not defined for type '{1}'"
        if "token_name" in self.functions:
            decls = Declarations()
            decls.set(var, self.name + " &")
            check = CheckStatement("ca::token_name({0});".format(var),
                                   decls, source=source)
            check.own_message = message.format("token_name", self.name)
            tester.add(check)

        if "pack" in self.functions:
            decls = Declarations()
            decls.set(var, self.name + "&")
            decls.set("packer", "ca::Packer &")
            check = CheckStatement("ca::pack(packer, {0});".format(var),
                                   decls,
                                   source=source)
            check.own_message = message.format("ca::pack", self.name)
            tester.add(check)

        if "pack" in self.functions:
            decls = Declarations()
            decls.set(var, self.name + "&")
            decls.set("unpacker", "ca::Unpacker &")
            check = CheckStatement("return ca::unpack<{0} >(unpacker);".format(self.name),
                                   decls,
                                   self.name,
                                   source=source)
            check.own_message = message.format("ca::unpack", self.name)
            tester.add(check)

        if "from_octave_value" in self.functions:
            decls = Declarations()
            decls.set(var, self.name + "&")
            ovalue = tester.new_id()
            decls.set(ovalue, "octave_value&")
            check = CheckStatement("caoctave::from_octave_value({0},{1});".format(var, ovalue),
                                   decls,
                                   source=source)
            check.own_message = message.format("caoctave::from_octave_value", self.name)
            tester.add(check)

        if "to_octave_value" in self.functions:
            decls = Declarations()
            decls.set(var, self.name + "&")
            check = CheckStatement("return caoctave::to_octave_value({0});".format(var),
                                   decls,
                                   "octave_value",
                                   source=source)
            check.own_message = message.format("caoctave::to_octave_value", self.name)
            tester.add(check)
示例#5
0
    def add_checks(self, tester):
        var = base.tester.new_id()

        source = min(self.sources)
        check = CheckStatement("{0} *{1};".format(self.name, base.tester.new_id()), source=source)
        check.own_message = "Invalid type '{0}'".format(self.name)
        tester.add(check)

        message = "Function '{0}' not defined for type '{1}'"
        if "token_name" in self.functions:
            decls = Declarations()
            decls.set(var, self.name + " &")
            check = CheckStatement("ca::token_name({0});".format(var),
                                   decls, source=source)
            check.own_message = message.format("token_name", self.name)
            tester.add(check)

        if "pack" in self.functions:
            decls = Declarations()
            decls.set(var, self.name + "&")
            decls.set("packer", "ca::Packer &")
            check = CheckStatement("ca::pack(packer, {0});".format(var),
                                   decls,
                                   source=source)
            check.own_message = message.format("ca::pack", self.name)
            tester.add(check)

        if "unpack" in self.functions:
            decls = Declarations()
            decls.set(var, self.name + "&")
            decls.set("unpacker", "ca::Unpacker &")
            check = CheckStatement("ca::unpack(unpacker, {0});".format(var),
                                   decls,
                                   source=source)
            check.own_message = message.format("ca::unpack", self.name)
            tester.add(check)

        if "from_octave_value" in self.functions:
            decls = Declarations()
            decls.set(var, self.name + "&")
            ovalue = base.tester.new_id()
            decls.set(ovalue, "octave_value&")
            check = CheckStatement("caoctave::from_octave_value({0},{1});".format(var, ovalue),
                                   decls,
                                   source=source)
            check.own_message = message.format("caoctave::from_octave_value", self.name)
            tester.add(check)

        if "to_octave_value" in self.functions:
            decls = Declarations()
            decls.set(var, self.name + "&")
            check = CheckStatement("return caoctave::to_octave_value({0});".format(var),
                                   decls,
                                   "octave_value",
                                   source=source)
            check.own_message = message.format("caoctave::to_octave_value", self.name)
            tester.add(check)