From 4d4c5d807baa7d0ebdd2dca6a0a147c8d0b68593 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Sun, 4 Jan 2015 11:24:31 +0100 Subject: [PATCH] ltl2tgba, randaut: better error reporting * src/bin/ltl2tgba.cc, src/bin/randaut.cc: Catch exceptions in main loop. * src/tgbatest/ltl2tgba.test, src/tgbatest/randaut.test: Test errors with unknown --dot argument. --- src/bin/ltl2tgba.cc | 13 ++++++++++--- src/bin/randaut.cc | 11 +++++++++-- src/tgbatest/ltl2tgba.test | 8 ++++++-- src/tgbatest/randaut.test | 3 +++ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/bin/ltl2tgba.cc b/src/bin/ltl2tgba.cc index 11e99230c..35b786aaf 100644 --- a/src/bin/ltl2tgba.cc +++ b/src/bin/ltl2tgba.cc @@ -60,7 +60,7 @@ static const argp_option options[] = /**************************************************/ { "%f", 0, 0, OPTION_DOC | OPTION_NO_USAGE, "the formula, in Spot's syntax", 4 }, - /**************************************************/ + /**************************************************/ { 0, 0, 0, 0, "Miscellaneous options:", -1 }, { "extra-options", 'x', "OPTS", 0, "fine-tuning options (see spot-x (7))", 0 }, @@ -182,7 +182,14 @@ main(int argc, char** argv) trans.set_level(level); trans_processor processor(trans); - if (processor.run()) - return 2; + try + { + if (processor.run()) + return 2; + } + catch (const std::runtime_error& e) + { + error(2, 0, "%s", e.what()); + } return 0; } diff --git a/src/bin/randaut.cc b/src/bin/randaut.cc index 6d545bada..e8824a2a4 100644 --- a/src/bin/randaut.cc +++ b/src/bin/randaut.cc @@ -298,8 +298,15 @@ main(int argc, char** argv) auto runtime = sw.stop(); - printer.print(aut, nullptr, - opt_seed_str, automaton_num, runtime, nullptr); + try + { + printer.print(aut, nullptr, + opt_seed_str, automaton_num, runtime, nullptr); + } + catch (const std::runtime_error& e) + { + error(2, 0, "%s", e.what()); + } ++automaton_num; if (opt_automata > 0 && automaton_num >= opt_automata) diff --git a/src/tgbatest/ltl2tgba.test b/src/tgbatest/ltl2tgba.test index 991cd0400..89fad6a68 100755 --- a/src/tgbatest/ltl2tgba.test +++ b/src/tgbatest/ltl2tgba.test @@ -1,7 +1,7 @@ #!/bin/sh # -*- coding: utf-8 -*- -# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Laboratoire de Recherche et -# Développement de l'Epita (LRDE). +# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Laboratoire +# de Recherche et Développement de l'Epita (LRDE). # Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6), # département Systèmes Répartis Coopératifs (SRC), Université Pierre # et Marie Curie. @@ -201,3 +201,7 @@ grep 'states: 4$' stdout ../../bin/ltlfilt -r -f '!{{a;b}[*]}' --equivalent-to '!a | X!b' ../../bin/ltlfilt -f '{a[*];b[*]}' --equivalent-to 'a | b' ../../bin/ltlfilt -r -f '{a[*];b[*]}' --equivalent-to 'a | b' + +# test unknown dot options +../../bin/ltl2tgba --dot=@ a 2>stderr && exit 1 +grep 'ltl2tgba: unknown option.*@' stderr diff --git a/src/tgbatest/randaut.test b/src/tgbatest/randaut.test index 0fcc4fb0a..5f45cf498 100755 --- a/src/tgbatest/randaut.test +++ b/src/tgbatest/randaut.test @@ -68,3 +68,6 @@ diff out expected $randaut -n 5 --stats='name: "%F-%L-%s-%c-%e"' a >out2 diff out2 expected + +$randaut -n 5 --dot=@ a 2>stderr && exit 1 +grep 'randaut: unknown option.*@' stderr