Beispiel #1
0
    def verify(self, fname, info):
        mcl = translate_property(info, self.cli.externs)
        mcl_fname = self._mcl_fname(fname)
        log.debug(f"Writing MCL query to {mcl_fname}...")
        with open(mcl_fname, "w") as f:
            f.write(mcl)
        self.temp_files.append(mcl_fname)
        self.verbose_output(mcl, "MCL property")

        try:
            cmd = ["lnt.open", fname, "generator", f"{fname}.bcg"]
            log_call(cmd)
            out = check_output(cmd, stderr=STDOUT, cwd=self.cwd).decode()
            self.verbose_output(out, "BCG generation ourput:")
            # ###### WARNING ##########
            # Here we can use divbranching because the properties we support
            # so far are preserved by it. Extensions to the property language
            # may require sharp or strong reduction.
            cmd = [
                "bcg_min", "-divbranching", f"{fname}.bcg", f"{fname}.min.bcg"
            ]
            log_call(cmd)
            check_output(cmd, stderr=STDOUT, cwd=self.cwd).decode()
            self.temp_files.append(f"{fname}.bcg")
            self.temp_files.append(f"{fname}.min.bcg")
            return Backend.verify(self, fname, info)
        except CalledProcessError as err:
            log.error(err.output.decode())
            return ExitStatus.BACKEND_ERROR
Beispiel #2
0
 def extract_trace(self):
     cmd = ["bcg_open", "evaluator.bcg", "executor", "100", "2"]
     log_call(cmd)
     try:
         out = check_output(cmd, stderr=STDOUT, cwd=self.cwd,
                            timeout=180).decode()
         self.verbose_output(out, "Trace from counterexample BCG")
         return out
     except TimeoutExpired:
         log.info("Could not extract a counterexample.")
         return ""
Beispiel #3
0
    def simulate(self, fname, info):
        if not (self.check_cadp()):
            return ExitStatus.BACKEND_ERROR
        cmd = ["lnt.open", fname, "executor", str(self.cli[Args.STEPS]), "2"]
        if self.cli[Args.TIMEOUT]:
            cmd = [self.timeout_cmd, str(self.cli[Args.TIMEOUT]), *cmd]

        try:
            for i in range(self.cli[Args.SIMULATE]):
                log_call(cmd)
                out = check_output(cmd, stderr=STDOUT, cwd=self.cwd).decode()
                self.verbose_output(out, "Backend output")
                header = f"====== Trace #{i+1} ======"
                print(header)
                for ln in self.translate_cex(out, info):
                    print(ln, sep="", end="")
                print(f'{"" :=<{len(header)}}')
            return ExitStatus.SUCCESS
        except CalledProcessError as err:
            self.verbose_output(err.output.decode(), "Backend output")
            return ExitStatus.BACKEND_ERROR
Beispiel #4
0
 def cleanup(self, fname):
     svl_fname = self._svl_fname(fname)
     sweep = ["svl", "-sweep", svl_fname]
     clean = ["svl", "-clean", svl_fname]
     if not (self.cli[Args.KEEP_FILES]):
         for cmd in (sweep, clean):
             try:
                 log_call(cmd)
                 cmd_out = check_output(cmd).decode()
                 log.debug(cmd_out)
             except CalledProcessError:
                 continue
     else:
         log.debug("Keeping SVL intermediate files. To remove them, use:")
         log.debug("    " + " ".join(sweep))
         log.debug("    " + " ".join(clean))
     self._safe_remove((
         self.cwd / f"{fname}@1.o",
         self.cwd / "svl001_composition_1.err#0",
     ))
     super().cleanup(fname)
Beispiel #5
0
 def simulate(self, fname, info):
     cmd = self.get_cmdline(fname, info)
     c = Concretizer(info, self.cli, True)
     for i in range(self.cli[Args.SIMULATE]):
         try:
             c.concretize_file(fname)  # Concretization step
             if self.cli[Args.TIMEOUT] > 0:
                 cmd = [self.timeout_cmd, str(self.cli[Args.TIMEOUT]), *cmd]
             log_call(cmd)
             out = check_output(cmd, stderr=STDOUT, cwd=self.cwd).decode()
             self.verbose_output(out, "Backend output")
         except CalledProcessError as err:
             out = err.output.decode("utf-8")
             self.verbose_output(out, "Backend output")
             try:
                 header = f"====== Trace #{i+1} ======"
                 print(header)
                 for x in self.translate_cex(out, info):
                     print(x, sep="", end="")
                 print(f'{"" :=<{len(header)}}')
             except Exception as e:
                 print(f"Counterexample translation failed: {e}")
     return ExitStatus.SUCCESS