Exemple #1
0
def run_benchmark(python_script_relative_path, benchmark,
                  is_realizable) -> bool:
    cmd_args = _BENCHMARKS_DIR + benchmark
    exec_cmd = '{python3} {program} {args}'.format(python3=sys.executable,
                                                   program=get_root_dir() +
                                                   python_script_relative_path,
                                                   args=cmd_args)
    result, out, err = execute_shell(exec_cmd)

    if (result != 0 and result != 1) or not is_empty_str(err):
        _failed('error while executing the command', exec_cmd, result, out,
                err)
        return False

    else:
        actual_is_realizable = result is 0

        if is_realizable == actual_is_realizable:
            _ok(cmd_args)
            return True
        else:
            _failed(
                'invalid realizability status(should be {status})'.format(
                    status=['unrealizable', 'realizable'][is_realizable]),
                exec_cmd, result, out, err)
            return False
Exemple #2
0
def synthesize(aiger_spec: str, is_moore: bool,
               bad_out_name: str) -> str or None:
    aiger_file = create_unique_file(aiger_spec)
    logging.debug("synthesize: using %s to store aiger_spec" % aiger_file)

    logging.info('executing sdf...')

    rc, out, err = execute_shell('{sdf} {aiger_file} -f {is_moore}'.format(
        sdf=SDF_PATH,
        aiger_file=aiger_file,
        is_moore='-moore' if is_moore else ''))
    assert is_empty_str(err), rc_out_err_to_str(rc, out, err)
    assert rc in (REALIZABLE_RC,
                  UNREALIZABLE_RC), rc_out_err_to_str(rc, out, err)

    logging.info('sdf completed')
    logging.debug('sdf returned:\n' + out)

    out_split = out.splitlines()
    status = out_split[0]
    if status == REALIZABLE_STR:
        full_model = convert_aiger_model_to_tlsf_model(
            '\n'.join(out_split[1:]), bad_out_name)
        os.remove(aiger_file)
        return full_model

    os.remove(aiger_file)
    return None
Exemple #3
0
def run_benchmark(python_script_relative_path, benchmark, rc_expected, size_expected) -> bool:
    cmd_args = BENCHMARKS_DIR + benchmark
    exec_cmd = '{python3} {program} {args}'.format(python3=sys.executable,
                                                   program=get_root_dir() + python_script_relative_path,
                                                   args=cmd_args)
    result, out, err = execute_shell(exec_cmd)

    if not is_empty_str(err):
        _print_failed('error while executing the command', exec_cmd, result, out, err)
        return False
    else:
        size_actual = _extract_model_size(out)
        if result == rc_expected and (not size_expected or size_expected == size_actual):
            _print_ok(cmd_args)
            return True
        else:
            _print_failed('invalid exit status or model size: \n'\
                          '  rc_actual vs rc_expected: {rc_act} vs. {rc_exp}\n'\
                          '  size_actual vs size_expected: {size_act} vs. {size_exp}'.
                          format(rc_act=result,
                                 rc_exp=rc_expected,
                                 size_act=size_actual,
                                 size_exp=size_expected),
                          exec_cmd, result, out, err)
            return False
Exemple #4
0
    def _convert_raw(property_: str,
                     signal_by_name: Dict[str, Signal],
                     states_prefix,
                     timeout=None) -> Automaton:
        """ :param property_: in the LTL2BA format (we do NOT negate it!) """

        rc, ba, err = execute_shell('{0} "{1}"'.format(
            LTLToAtmViaLTL3BA._execute_cmd, property_),
                                    timeout=timeout)
        assert rc == 0, str(rc) + ', err: ' + str(err) + ', out: ' + str(ba)
        assert is_empty_str(err), err
        logging.debug(ba)

        aut = spot.automaton(ba + '\n')  # type: spot.twa
        # (when SPOT sees `\n` it treats input as the string)
        atm = spotAtm_to_automaton(aut, states_prefix, signal_by_name,
                                   property_)
        atm.name = property_
        return atm
Exemple #5
0
def run_benchmark(python_script_relative_path, benchmark, rc_expected) -> bool:
    cmd_args = _BENCHMARKS_DIR + benchmark
    exec_cmd = '{python3} {program} {args}'.format(python3=sys.executable,
                                                   program=get_root_dir() + python_script_relative_path,
                                                   args=cmd_args)
    result, out, err = execute_shell(exec_cmd)

    if not is_empty_str(err):
        _print_failed('error while executing the command', exec_cmd, result, out, err)
        return False

    else:
        if result == rc_expected:
            _print_ok(cmd_args)
            return True
        else:
            _print_failed('invalid exit status (actual != expected: {act} != {exp})'.
                          format(act=result, exp=rc_expected),
                          exec_cmd, result, out, err)
            return False
Exemple #6
0
def run_benchmark(python_script_relative_path, benchmark, is_realizable) -> bool:
    cmd_args = _BENCHMARKS_DIR + benchmark
    exec_cmd = '{python3} {program} {args}'.format(python3=sys.executable,
                                                   program=get_root_dir() + python_script_relative_path,
                                                   args=cmd_args)
    result, out, err = execute_shell(exec_cmd)

    if (result != 0 and result != 1) or not is_empty_str(err):
        _failed('error while executing the command', exec_cmd, result, out, err)
        return False

    else:
        actual_is_realizable = result is 0

        if is_realizable == actual_is_realizable:
            _ok(cmd_args)
            return True
        else:
            _failed('invalid realizability status(should be {status})'.
                    format(status=['unrealizable', 'realizable'][is_realizable]),
                    exec_cmd, result, out, err)
            return False
Exemple #7
0
def assert_exec_strict(rc, out, err):
    assert rc==0 and is_empty_str(err), rc_out_err_to_str(rc, out, err)
Exemple #8
0
def assert_exec_strict(rc, out, err):
    assert rc == 0 and is_empty_str(err), rc_out_err_to_str(rc, out, err)