ltldo: improve error messages

Use ltldo:... instead of error:... and warning:... and also improve
the diagnostic displayed after a translation failure to mention the
tool and formula.

Incidentally, this fixes a spurious test case failure observed by
Philipp Schlehuber on CentOS7.7 where glibc 2.17 is installed.  With
this system, when posix_spawn() starts a binary that does not exist,
it returns success and let the child die with exit code 127.  On more
recent glibc, posix_spawn() manages to return execve()'s errno, as if
the child had not been created.  We handle those two different ways to
fail, but before this patch one used to print "error:..." and the
other "ltldo:...".

* bin/ltldo.cc: Display the program_name in error message.  Display
the command name and formula on translation failure.
* tests/core/ltldo.test: Adjust test case.
* NEWS: Mention the fix.
This commit is contained in:
Alexandre Duret-Lutz 2020-05-31 16:19:51 +02:00
parent 8e9e706003
commit b7abe6f4b4
3 changed files with 31 additions and 27 deletions

3
NEWS
View file

@ -58,6 +58,9 @@ New in spot 2.9.0.dev (not yet released)
every place where 0 occur, and then the acceptance would be every place where 0 occur, and then the acceptance would be
renumbered to Fin(0)|Fin(1)|Fin(2). This is now fixed. renumbered to Fin(0)|Fin(1)|Fin(2). This is now fixed.
- Improve ltldo diagnostics to fix spurious test-suite failure on
systems with antique GNU libc.
New in spot 2.9 (2020-04-30) New in spot 2.9 (2020-04-30)
Command-line tools: Command-line tools:

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2015-2019 Laboratoire de Recherche et Développement // Copyright (C) 2015-2020 Laboratoire de Recherche et Développement
// de 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.
@ -39,6 +39,7 @@
#include "common_hoaread.hh" #include "common_hoaread.hh"
#include <spot/tl/relabel.hh> #include <spot/tl/relabel.hh>
#include <spot/tl/print.hh>
#include <spot/misc/bareword.hh> #include <spot/misc/bareword.hh>
#include <spot/misc/timer.hh> #include <spot/misc/timer.hh>
#include <spot/twaalgos/lbtt.hh> #include <spot/twaalgos/lbtt.hh>
@ -233,18 +234,13 @@ namespace
problem = false; problem = false;
if (timed_out) if (timed_out)
{ {
// A timeout is considered benign // A timeout is considered benign, unless --fail-on-timeout.
if (fail_on_timeout) if (fail_on_timeout)
{ problem = true;
std::cerr << "error:";
problem = true;
}
else else
{ ++timeout_count;
std::cerr << "warning:"; std::cerr << program_name
++timeout_count; << ": timeout during execution of command \""
}
std::cerr << " timeout during execution of command \""
<< cmd << "\"\n"; << cmd << "\"\n";
} }
else if (WIFSIGNALED(es)) else if (WIFSIGNALED(es))
@ -253,7 +249,7 @@ namespace
{ {
problem = true; problem = true;
es = WTERMSIG(es); es = WTERMSIG(es);
std::cerr << "error: execution of command \"" << cmd std::cerr << program_name << ": execution of command \"" << cmd
<< "\" terminated by signal " << es << ".\n"; << "\" terminated by signal " << es << ".\n";
} }
} }
@ -263,7 +259,7 @@ namespace
{ {
problem = true; problem = true;
es = WEXITSTATUS(es); es = WEXITSTATUS(es);
std::cerr << "error: execution of command \"" << cmd std::cerr << program_name << ": execution of command \"" << cmd
<< "\" returned exit code " << es << ".\n"; << "\" returned exit code " << es << ".\n";
} }
} }
@ -275,14 +271,14 @@ namespace
if (!aut->errors.empty() && errors_opt != errors_ignore) if (!aut->errors.empty() && errors_opt != errors_ignore)
{ {
problem = true; problem = true;
std::cerr << "error: failed to parse the automaton " std::cerr << program_name << ": failed to parse the automaton "
"produced by \"" << cmd << "\".\n"; "produced by \"" << cmd << "\".\n";
aut->format_errors(std::cerr); aut->format_errors(std::cerr);
} }
else if (aut->aborted && errors_opt != errors_ignore) else if (aut->aborted && errors_opt != errors_ignore)
{ {
problem = true; problem = true;
std::cerr << "error: command \"" << cmd std::cerr << program_name << ": command \"" << cmd
<< "\" aborted its output.\n"; << "\" aborted its output.\n";
} }
else else
@ -410,11 +406,14 @@ namespace
auto aut = runner.translate(t, problem, timer); auto aut = runner.translate(t, problem, timer);
if (problem) if (problem)
{ {
if (errors_opt == errors_abort) // An error message already occurred about the problem,
error_at_line(2, 0, filename, linenum, "aborting here"); // but this additional one will print filename &
else // linenum, and possibly exit.
error_at_line(0, 0, filename, linenum, std::string sf = spot::str_psl(f);
"failed to translate this input"); error_at_line(errors_opt == errors_abort ? 2 : 0, 0,
filename, linenum,
"failed to run `%s' on `%s'",
tools[t].name, sf.c_str());
} }
if (aut) if (aut)
{ {

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2015-2019 Laboratoire de Recherche et Développement de # Copyright (C) 2015-2020 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.
@ -43,21 +43,23 @@ genltl --or-g=1..2 |
run 0 ltldo -t 'sleep 10; echo %f' -T1 -t 'sleep 10; echo %f' \ run 0 ltldo -t 'sleep 10; echo %f' -T1 -t 'sleep 10; echo %f' \
>output 2>stderr >output 2>stderr
test -z "`cat output`" test -z "`cat output`"
test 4 = `grep -c warning: stderr` test 4 = `grep -c ltldo: stderr`
grep -q 'failed to' stderr && exit 1
genltl --or-g=1..2 | genltl --or-g=1..2 |
run 0 ltldo -t 'sleep 10; echo %f' -T1 -t 'sleep 10; echo %f' \ run 0 ltldo -t 'sleep 10; echo %f' -T1 -t 'sleep 10; echo %f' \
--fail-on-timeout --error=warn >output 2>stderr --fail-on-timeout --error=warn >output 2>stderr
test -z "`cat output`" test -z "`cat output`"
test 4 = `grep -c error: stderr` test 8 = `grep -c ltldo: stderr`
grep -q 'aborting here' stderr && exit 1 test 4 = `grep -c ltldo:-: stderr`
grep -q 'failed to' stderr
genltl --or-g=1..2 | genltl --or-g=1..2 |
run 2 ltldo -t 'sleep 10; echo %f' -T1 -t 'sleep 10; echo %f' \ run 2 ltldo -t 'sleep 10; echo %f' -T1 -t 'sleep 10; echo %f' \
--fail-on-timeout >output 2>stderr --fail-on-timeout >output 2>stderr
test -z "`cat output`" test -z "`cat output`"
test 1 = `grep -c error: stderr` test 2 = `grep -c ltldo: stderr`
grep -q 'aborting here' stderr grep -q 'failed to' stderr
test "`echo 1,a,3,4 | ltldo -F-/2 ltl2tgba --stats='%<,%s,%>'`" = '1,2,3,4' test "`echo 1,a,3,4 | ltldo -F-/2 ltl2tgba --stats='%<,%s,%>'`" = '1,2,3,4'
@ -143,7 +145,7 @@ diff output expected
ltldo ': %s; true>%O' -f GFa 2>stderr && exit 1 ltldo ': %s; true>%O' -f GFa 2>stderr && exit 1
test $? = 2 test $? = 2
grep ':.*empty input' stderr grep ':.*empty input' stderr
grep 'ltldo: aborting' stderr grep 'ltldo: failed to run' stderr
ltldo ': %s; true>%O' --errors=ignore -f GFa 2>stderr ltldo ': %s; true>%O' --errors=ignore -f GFa 2>stderr
test $? = 0 test $? = 0