bin: teach conversion options to report about the options
* bin/common_conv.cc, bin/common_conv.hh: Here. * bin/autfilt.cc, bin/common_trans.cc, bin/ltlcross.cc, bin/ltldo.cc, bin/ltlfilt.cc, bin/ltlgrind.cc, bin/randaut.cc, bin/randltl.cc: Pass the name of the argumennt to the conversion function. * tests/core/ltlcross3.test, tests/core/ltldo.test, tests/core/randaut.test: Add test cases.
This commit is contained in:
parent
1f9f3c77ea
commit
c369f899a3
13 changed files with 67 additions and 54 deletions
|
|
@ -647,7 +647,7 @@ parse_opt(int key, char* arg, struct argp_state*)
|
||||||
jobs.emplace_back(arg, true);
|
jobs.emplace_back(arg, true);
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
opt_max_count = to_pos_int(arg);
|
opt_max_count = to_pos_int(arg, "-n/--max-count");
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
opt->uniq =
|
opt->uniq =
|
||||||
|
|
@ -794,15 +794,17 @@ parse_opt(int key, char* arg, struct argp_state*)
|
||||||
break;
|
break;
|
||||||
case OPT_HIGHLIGHT_NONDET:
|
case OPT_HIGHLIGHT_NONDET:
|
||||||
{
|
{
|
||||||
int v = arg ? to_pos_int(arg) : 1;
|
int v = arg ? to_pos_int(arg, "--highlight-nondet") : 1;
|
||||||
opt_highlight_nondet_edges = opt_highlight_nondet_states = v;
|
opt_highlight_nondet_edges = opt_highlight_nondet_states = v;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OPT_HIGHLIGHT_NONDET_STATES:
|
case OPT_HIGHLIGHT_NONDET_STATES:
|
||||||
opt_highlight_nondet_states = arg ? to_pos_int(arg) : 1;
|
opt_highlight_nondet_states =
|
||||||
|
arg ? to_pos_int(arg, "--highlight-nondet-states") : 1;
|
||||||
break;
|
break;
|
||||||
case OPT_HIGHLIGHT_NONDET_EDGES:
|
case OPT_HIGHLIGHT_NONDET_EDGES:
|
||||||
opt_highlight_nondet_edges = arg ? to_pos_int(arg) : 1;
|
opt_highlight_nondet_edges =
|
||||||
|
arg ? to_pos_int(arg, "--highlight-nondet-edges") : 1;
|
||||||
break;
|
break;
|
||||||
case OPT_HIGHLIGHT_WORD:
|
case OPT_HIGHLIGHT_WORD:
|
||||||
{
|
{
|
||||||
|
|
@ -1021,7 +1023,7 @@ parse_opt(int key, char* arg, struct argp_state*)
|
||||||
opt_sccs = parse_range(arg, 0, std::numeric_limits<int>::max());
|
opt_sccs = parse_range(arg, 0, std::numeric_limits<int>::max());
|
||||||
break;
|
break;
|
||||||
case OPT_SEED:
|
case OPT_SEED:
|
||||||
opt_seed = to_int(arg);
|
opt_seed = to_int(arg, "--seed");
|
||||||
break;
|
break;
|
||||||
case OPT_SEP_SETS:
|
case OPT_SEP_SETS:
|
||||||
opt_sep_sets = true;
|
opt_sep_sets = true;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
// Copyright (C) 2015 Laboratoire de Recherche et Développement de
|
// Copyright (C) 2015, 2018 Laboratoire de Recherche et Développement
|
||||||
// l'Epita (LRDE).
|
// de l'Epita (LRDE).
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
//
|
//
|
||||||
|
|
@ -22,50 +22,54 @@
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
to_int(const char* s)
|
to_int(const char* s, const char* where)
|
||||||
{
|
{
|
||||||
char* endptr;
|
char* endptr;
|
||||||
int res = strtol(s, &endptr, 10);
|
int res = strtol(s, &endptr, 10);
|
||||||
if (*endptr)
|
if (*endptr)
|
||||||
error(2, 0, "failed to parse '%s' as an integer.", s);
|
error(2, 0, "failed to parse '%s' as an integer (in argument of %s).",
|
||||||
|
s, where);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
to_pos_int(const char* s)
|
to_pos_int(const char* s, const char* where)
|
||||||
{
|
{
|
||||||
int res = to_int(s);
|
int res = to_int(s, where);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
error(2, 0, "%d is not positive", res);
|
error(2, 0, "%d is not positive (in argument of %s)", res, where);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
to_unsigned (const char *s)
|
to_unsigned (const char *s, const char* where)
|
||||||
{
|
{
|
||||||
char* endptr;
|
char* endptr;
|
||||||
unsigned res = strtoul(s, &endptr, 10);
|
unsigned res = strtoul(s, &endptr, 10);
|
||||||
if (*endptr)
|
if (*endptr)
|
||||||
error(2, 0, "failed to parse '%s' as an unsigned integer.", s);
|
error(2, 0,
|
||||||
|
"failed to parse '%s' as an unsigned integer (in argument of %s).",
|
||||||
|
s, where);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
to_float(const char* s)
|
to_float(const char* s, const char* where)
|
||||||
{
|
{
|
||||||
char* endptr;
|
char* endptr;
|
||||||
float res = strtof(s, &endptr);
|
float res = strtof(s, &endptr);
|
||||||
if (*endptr)
|
if (*endptr)
|
||||||
error(2, 0, "failed to parse '%s' as a float.", s);
|
error(2, 0, "failed to parse '%s' as a float (in argument of %s)",
|
||||||
|
s, where);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
to_probability(const char* s)
|
to_probability(const char* s, const char* where)
|
||||||
{
|
{
|
||||||
float res = to_float(s);
|
float res = to_float(s, where);
|
||||||
if (res < 0.0 || res > 1.0)
|
if (res < 0.0 || res > 1.0)
|
||||||
error(2, 0, "%f is not between 0 and 1.", res);
|
error(2, 0, "%f is not between 0 and 1 (in argument of %s).", res, where);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
// Copyright (C) 2015 Laboratoire de Recherche et Développement de
|
// Copyright (C) 2015, 2018 Laboratoire de Recherche et Développement
|
||||||
// l'Epita (LRDE).
|
// de l'Epita (LRDE).
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
//
|
//
|
||||||
|
|
@ -22,11 +22,11 @@
|
||||||
#include "common_sys.hh"
|
#include "common_sys.hh"
|
||||||
#include <spot/twa/twagraph.hh>
|
#include <spot/twa/twagraph.hh>
|
||||||
|
|
||||||
int to_int(const char* s);
|
int to_int(const char* s, const char* where);
|
||||||
int to_pos_int(const char* s);
|
int to_pos_int(const char* s, const char* where);
|
||||||
unsigned to_unsigned (const char *s);
|
unsigned to_unsigned (const char *s, const char* where);
|
||||||
float to_float(const char* s);
|
float to_float(const char* s, const char* where);
|
||||||
float to_probability(const char* s);
|
float to_probability(const char* s, const char* where);
|
||||||
|
|
||||||
// Parse the comma or space seperate string of numbers.
|
// Parse the comma or space seperate string of numbers.
|
||||||
std::vector<long> to_longs(const char* s);
|
std::vector<long> to_longs(const char* s);
|
||||||
|
|
|
||||||
|
|
@ -802,7 +802,7 @@ static int parse_opt_trans(int key, char* arg, struct argp_state*)
|
||||||
tools_push_trans(arg);
|
tools_push_trans(arg);
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
timeout = to_pos_int(arg);
|
timeout = to_pos_int(arg, "-T/--timeout");
|
||||||
#if !ENABLE_TIMEOUT
|
#if !ENABLE_TIMEOUT
|
||||||
std::cerr << "warning: setting a timeout is not supported "
|
std::cerr << "warning: setting a timeout is not supported "
|
||||||
<< "on your platform" << std::endl;
|
<< "on your platform" << std::endl;
|
||||||
|
|
@ -865,7 +865,7 @@ static int parse_opt_autproc(int key, char* arg, struct argp_state*)
|
||||||
tools_push_autproc(arg);
|
tools_push_autproc(arg);
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
timeout = to_pos_int(arg);
|
timeout = to_pos_int(arg, "-T/--timeout");
|
||||||
#if !ENABLE_TIMEOUT
|
#if !ENABLE_TIMEOUT
|
||||||
std::cerr << "warning: setting a timeout is not supported "
|
std::cerr << "warning: setting a timeout is not supported "
|
||||||
<< "on your platform" << std::endl;
|
<< "on your platform" << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -448,7 +448,7 @@ parse_opt(int key, char* arg, struct argp_state*)
|
||||||
csv_output = arg ? arg : "-";
|
csv_output = arg ? arg : "-";
|
||||||
break;
|
break;
|
||||||
case OPT_DENSITY:
|
case OPT_DENSITY:
|
||||||
density = to_probability(arg);
|
density = to_probability(arg, "---density");
|
||||||
break;
|
break;
|
||||||
case OPT_DUPS:
|
case OPT_DUPS:
|
||||||
allow_dups = true;
|
allow_dups = true;
|
||||||
|
|
@ -472,7 +472,7 @@ parse_opt(int key, char* arg, struct argp_state*)
|
||||||
products_avg = false;
|
products_avg = false;
|
||||||
++arg;
|
++arg;
|
||||||
}
|
}
|
||||||
products = to_pos_int(arg);
|
products = to_pos_int(arg, "--products");
|
||||||
if (products == 0)
|
if (products == 0)
|
||||||
products_avg = false;
|
products_avg = false;
|
||||||
break;
|
break;
|
||||||
|
|
@ -490,10 +490,10 @@ parse_opt(int key, char* arg, struct argp_state*)
|
||||||
tools_push_trans(arg, true);
|
tools_push_trans(arg, true);
|
||||||
break;
|
break;
|
||||||
case OPT_SEED:
|
case OPT_SEED:
|
||||||
seed = to_pos_int(arg);
|
seed = to_pos_int(arg, "--seed");
|
||||||
break;
|
break;
|
||||||
case OPT_STATES:
|
case OPT_STATES:
|
||||||
states = to_pos_int(arg);
|
states = to_pos_int(arg, "--states");
|
||||||
break;
|
break;
|
||||||
case OPT_STOP_ERR:
|
case OPT_STOP_ERR:
|
||||||
stop_on_error = true;
|
stop_on_error = true;
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ parse_opt(int key, char* arg, struct argp_state*)
|
||||||
best_format = arg;
|
best_format = arg;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
opt_max_count = to_pos_int(arg);
|
opt_max_count = to_pos_int(arg, "-n/--max-count");
|
||||||
break;
|
break;
|
||||||
case ARGP_KEY_ARG:
|
case ARGP_KEY_ARG:
|
||||||
if (arg[0] == '-' && !arg[1])
|
if (arg[0] == '-' && !arg[1])
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ parse_opt(int key, char* arg, struct argp_state*)
|
||||||
output_format = count_output;
|
output_format = count_output;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
opt_max_count = to_pos_int(arg);
|
opt_max_count = to_pos_int(arg, "-n/--max-count");
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
output_format = quiet_output;
|
output_format = quiet_output;
|
||||||
|
|
@ -385,10 +385,10 @@ parse_opt(int key, char* arg, struct argp_state*)
|
||||||
bsize = parse_range(arg, 0, std::numeric_limits<int>::max());
|
bsize = parse_range(arg, 0, std::numeric_limits<int>::max());
|
||||||
break;
|
break;
|
||||||
case OPT_BSIZE_MIN:
|
case OPT_BSIZE_MIN:
|
||||||
bsize.min = to_int(arg);
|
bsize.min = to_int(arg, "--bsize-min");
|
||||||
break;
|
break;
|
||||||
case OPT_BSIZE_MAX:
|
case OPT_BSIZE_MAX:
|
||||||
bsize.max = to_int(arg);
|
bsize.max = to_int(arg, "--bsize-max");
|
||||||
break;
|
break;
|
||||||
case OPT_DEFINE:
|
case OPT_DEFINE:
|
||||||
opt->output_define.reset(new output_file(arg ? arg : "-"));
|
opt->output_define.reset(new output_file(arg ? arg : "-"));
|
||||||
|
|
@ -487,10 +487,10 @@ parse_opt(int key, char* arg, struct argp_state*)
|
||||||
size = parse_range(arg, 0, std::numeric_limits<int>::max());
|
size = parse_range(arg, 0, std::numeric_limits<int>::max());
|
||||||
break;
|
break;
|
||||||
case OPT_SIZE_MIN:
|
case OPT_SIZE_MIN:
|
||||||
size.min = to_int(arg);
|
size.min = to_int(arg, "--size-min");
|
||||||
break;
|
break;
|
||||||
case OPT_SIZE_MAX:
|
case OPT_SIZE_MAX:
|
||||||
size.max = to_int(arg);
|
size.max = to_int(arg, "--size-max");
|
||||||
break;
|
break;
|
||||||
case OPT_SKIP_ERRORS:
|
case OPT_SKIP_ERRORS:
|
||||||
error_style = skip_errors;
|
error_style = skip_errors;
|
||||||
|
|
|
||||||
|
|
@ -134,10 +134,10 @@ parse_opt(int key, char* arg, struct argp_state*)
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case 'm':
|
case 'm':
|
||||||
mutation_nb = to_unsigned(arg);
|
mutation_nb = to_unsigned(arg, "-m/--mutations");
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
max_output = to_int(arg);
|
max_output = to_int(arg, "-n/--max-count");
|
||||||
break;
|
break;
|
||||||
case ARGP_KEY_ARG:
|
case ARGP_KEY_ARG:
|
||||||
// FIXME: use stat() to distinguish filename from string?
|
// FIXME: use stat() to distinguish filename from string?
|
||||||
|
|
|
||||||
|
|
@ -189,10 +189,7 @@ parse_opt(int key, char* arg, struct argp_state* as)
|
||||||
spot::enable_utf8();
|
spot::enable_utf8();
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
opt_acc_prob = to_float(arg);
|
opt_acc_prob = to_probability(arg, "-a/--acc-probability");
|
||||||
if (opt_acc_prob < 0.0 || opt_acc_prob > 1.0)
|
|
||||||
error(2, 0, "probability of acceptance set membership "
|
|
||||||
"should be between 0.0 and 1.0");
|
|
||||||
break;
|
break;
|
||||||
case 'A':
|
case 'A':
|
||||||
if (looks_like_a_range(arg))
|
if (looks_like_a_range(arg))
|
||||||
|
|
@ -215,15 +212,13 @@ parse_opt(int key, char* arg, struct argp_state* as)
|
||||||
ba_wanted = true;
|
ba_wanted = true;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
opt_density = to_float(arg);
|
opt_density = to_probability(arg, "-e/--density");
|
||||||
if (opt_density < 0.0 || opt_density > 1.0)
|
|
||||||
error(2, 0, "density should be between 0.0 and 1.0");
|
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
opt_deterministic = true;
|
opt_deterministic = true;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
opt_automata = to_int(arg);
|
opt_automata = to_int(arg, "-n/--automata");
|
||||||
break;
|
break;
|
||||||
case 'Q':
|
case 'Q':
|
||||||
opt_states = parse_range(arg);
|
opt_states = parse_range(arg);
|
||||||
|
|
@ -243,7 +238,7 @@ parse_opt(int key, char* arg, struct argp_state* as)
|
||||||
opt_colored = true;
|
opt_colored = true;
|
||||||
break;
|
break;
|
||||||
case OPT_SEED:
|
case OPT_SEED:
|
||||||
opt_seed = to_int(arg);
|
opt_seed = to_int(arg, "--seed");
|
||||||
opt_seed_str = arg;
|
opt_seed_str = arg;
|
||||||
break;
|
break;
|
||||||
case ARGP_KEY_ARG:
|
case ARGP_KEY_ARG:
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ parse_opt(int key, char* arg, struct argp_state* as)
|
||||||
output = spot::randltlgenerator::LTL;
|
output = spot::randltlgenerator::LTL;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
opt_formulas = to_int(arg);
|
opt_formulas = to_int(arg, "-n/--formulas");
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
output = spot::randltlgenerator::PSL;
|
output = spot::randltlgenerator::PSL;
|
||||||
|
|
@ -196,7 +196,7 @@ parse_opt(int key, char* arg, struct argp_state* as)
|
||||||
opt_pS = arg;
|
opt_pS = arg;
|
||||||
break;
|
break;
|
||||||
case OPT_SEED:
|
case OPT_SEED:
|
||||||
opt_seed = to_int(arg);
|
opt_seed = to_int(arg, "--seed");
|
||||||
break;
|
break;
|
||||||
case OPT_TREE_SIZE:
|
case OPT_TREE_SIZE:
|
||||||
opt_tree_size = parse_range(arg);
|
opt_tree_size = parse_range(arg);
|
||||||
|
|
|
||||||
|
|
@ -296,9 +296,12 @@ test `grep '"aborted",-1' out.csv | wc -l` -eq 4
|
||||||
test 5 = `wc -l < out.csv`
|
test 5 = `wc -l < out.csv`
|
||||||
check_csv out.csv
|
check_csv out.csv
|
||||||
|
|
||||||
|
# Diagnose empty automata, and make sure %% is correctly replaced by %
|
||||||
|
ltlcross --density 2.01 ltl2tgba 2>stderr && exit 1
|
||||||
|
grep 'not between 0 and 1' stderr
|
||||||
|
|
||||||
# Diagnose empty automata, and make sure %% is correctly replaced by %
|
# Diagnose empty automata, and make sure %% is correctly replaced by %
|
||||||
run 1 ltlcross ': %f >%O; echo %%>foo' -f a 2>stderr
|
run 1 ltlcross --density 0.01 ': %f >%O; echo %%>foo' -f a 2>stderr
|
||||||
test 2 = `grep -c ':.*empty input' stderr`
|
test 2 = `grep -c ':.*empty input' stderr`
|
||||||
cat foo
|
cat foo
|
||||||
cat >expected<<EOF
|
cat >expected<<EOF
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (C) 2015-2017 Laboratoire de Recherche et Développement de
|
# Copyright (C) 2015-2018 Laboratoire de Recherche et Développement de
|
||||||
# l'Epita (LRDE).
|
# l'Epita (LRDE).
|
||||||
#
|
#
|
||||||
# This file is part of Spot, a model checking library.
|
# This file is part of Spot, a model checking library.
|
||||||
|
|
@ -161,6 +161,8 @@ grep 'error:.*foo/bar/ltl2baextended -f .*>.*' stderr
|
||||||
test 2 = `genltl --and-gf=1..4 | ltldo ltl2tgba -n2 | autfilt -c`
|
test 2 = `genltl --and-gf=1..4 | ltldo ltl2tgba -n2 | autfilt -c`
|
||||||
test 3 = `genltl --and-gf=1..2 | ltldo ltl2tgba 'ltl2tgba -s' -n3 | autfilt -c`
|
test 3 = `genltl --and-gf=1..2 | ltldo ltl2tgba 'ltl2tgba -s' -n3 | autfilt -c`
|
||||||
|
|
||||||
|
ltldo ltl2tgba -n2a 2>err && exit 1
|
||||||
|
grep "ltldo: failed to parse '2a'.*-n" err
|
||||||
|
|
||||||
genltl --rv-counter=9 | ltldo ltl2tgba --stats='
|
genltl --rv-counter=9 | ltldo ltl2tgba --stats='
|
||||||
print("%[up]R + %[uc]R + %[sp]R + %[sc]R - %R\n");
|
print("%[up]R + %[uc]R + %[sp]R + %[sc]R - %R\n");
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (C) 2014, 2015, 2016, 2017 Laboratoire de Recherche et
|
# Copyright (C) 2014, 2015, 2016, 2017, 2018 Laboratoire de Recherche et
|
||||||
# Développement de l'Epita (LRDE).
|
# Développement de l'Epita (LRDE).
|
||||||
#
|
#
|
||||||
# This file is part of Spot, a model checking library.
|
# This file is part of Spot, a model checking library.
|
||||||
|
|
@ -22,6 +22,13 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
randaut -e foo 2>err && exit 1
|
||||||
|
grep "randaut: failed to parse 'foo' as a float (in argument of -e" err
|
||||||
|
randaut -e 3.14 2>err && exit 1
|
||||||
|
grep "randaut: 3.1.*is not between 0 and 1 (in argument of -e" err
|
||||||
|
randaut -n1a 3 2>err && exit 1
|
||||||
|
grep "randaut: failed to parse '1a' as an integer.* -n/--automata)" err
|
||||||
|
|
||||||
randaut --spin -Q4 a b | ../ikwiad -H -XN - >out
|
randaut --spin -Q4 a b | ../ikwiad -H -XN - >out
|
||||||
grep 'States: 4' out
|
grep 'States: 4' out
|
||||||
grep 'AP: 2' out
|
grep 'AP: 2' out
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue