Commit 7e5b336f authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

tests: divide the run time of parse.test by 20

* tests/core/readltl.cc: Process many formulas from a
file instead of one arg at a time.
* tests/core/parse.test, tests/core/parseerr.test, tests/core/utf8.test:
Adjust to supply a file as input.
parent ad515256
...@@ -28,82 +28,72 @@ ...@@ -28,82 +28,72 @@
. ./defs || exit 1 . ./defs || exit 1
for f in \ set -e
'0' \
'1' \
'true' \
'false' \
'a' \
'p11011' \
'(p11011)' \
'a & b' \
'a * _b12' \
'a && .b.' \
'a + b' \
'a3214 | b' \
'a /\ b' \
'a || b' \
'a \/ b' \
'a | b' \
'_a_ U b' \
'a R b' \
'a <=> b' \
'a <-> b' \
'a ^ b' \
'a xor b' \
'a => b' \
'a -> b' \
'F b' \
'Gb' \
'G(b)' \
'!G(!b)' \
'!b' \
'[]b' \
'<>b' \
'X b' \
'()b' \
'X"X"' \
'X"F"' \
'X"G"' \
'X"U"' \
'X"W"' \
'X"R"' \
'X"M"' \
'long_atomic_proposition_1 U long_atomic_proposition_2' \
' ab & ac | ad ^ af' \
'((b & a) + a) & d' \
'(ab & ac | ad ) <=> af ' \
'a U b U c U d U e U f U g U h U i U j U k U l U m' \
'(ab & !Xad + ad U ab) & FG p12 /\ GF p13' \
'((([]<>()p12)) )' \
'a R ome V anille' \
'p=0Uq=1' \
'((p=1Rq=1)+p=0)UXq=0' \
'((p=1Rq=1)*p=0)UXq=0' \
'(Gq=1*Fp=0)UXq=0' \
'((p=1Mq=1)Wx+p=0)RXq=0' \
'((p=1Vq=1)Rx+p=0)WXq=0' \
'((X(p2=0))U(X(p2=0)))+((Xp1=0)UFALSE)'
do cat >input <<EOF
if ../ltl2text "$f"; then 0
: 1
else true
echo "ltl2text failed to parse '$f'" false
exit 1 a
fi p11011
(p11011)
a & b
a * _b12
a && .b.
a + b
a3214 | b
a /\ b
a || b
a \/ b
a | b
_a_ U b
a R b
a <=> b
a <-> b
a ^ b
a xor b
a => b
a -> b
F b
Gb
G(b)
!G(!b)
!b
[]b
<>b
X b
()b
X"X"
X"F"
X"G"
X"U"
X"W"
X"R"
X"M"
long_atomic_proposition_1 U long_atomic_proposition_2
ab & ac | ad ^ af
((b & a) + a) & d
(ab & ac | ad ) <=> af
a U b U c U d U e U f U g U h U i U j U k U l U m
(ab & !Xad + ad U ab) & FG p12 /\ GF p13
((([]<>()p12)) )
a R ome V anille
p=0Uq=1
((p=1Rq=1)+p=0)UXq=0
((p=1Rq=1)*p=0)UXq=0
(Gq=1*Fp=0)UXq=0
((p=1Mq=1)Wx+p=0)RXq=0
((p=1Vq=1)Rx+p=0)WXq=0
((X(p2=0))U(X(p2=0)))+((Xp1=0)UFALSE)
EOF
if test -n "$DOT"; then run 0 ../ltl2text input
run 0 ../ltl2dot "$f" > parse.dot
if $DOT -o /dev/null parse.dot; then if test -n "$DOT"; then
rm -f parse.dot run 0 ../ltl2dot "input" > parse.dot
else $DOT -o /dev/null parse.dot
rm -f parse.dot fi
echo "dot failed to parse ltl2dot output for '$f'"
exit 1
fi
fi
done
# Make sure running the parser in debug mode does not crash # Make sure running the parser in debug mode does not crash
run 0 ../ikwiad -d 'a U b' run 0 ../ikwiad -d 'a U b'
#! /bin/sh #! /bin/sh
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2009, 2010, 2011, 2013, 2014, 2015 Laboratoire de # Copyright (C) 2009, 2010, 2011, 2013, 2014, 2015, 2016 Laboratoire
# Recherche et Développement de l'Epita (LRDE). # de Recherche et Développement de l'Epita (LRDE).
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6), # Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
# département Systèmes Répartis Coopératifs (SRC), Université Pierre # département Systèmes Répartis Coopératifs (SRC), Université Pierre
# et Marie Curie. # et Marie Curie.
...@@ -28,42 +28,54 @@ ...@@ -28,42 +28,54 @@
. ./defs || exit 1 . ./defs || exit 1
set -e set -e
check() cat >input <<EOF
{
set +x; run 1 ../ltl2text "$1" >stdout 2>stderr; set -x +
if test -n "$2"; then /2/3/4/5 a + b /6/7/8/
echo "$2" >expect a - b
else {a[*9999999999]}
: >expect EOF
fi
if cmp stdout expect; then run 1 ../ltl2text input >output
:
else sed 's/$$//' >expected<<\EOF
echo "'$1' parsed as" >>> $
cat stdout ^
echo "instead of" empty input
cat expect
exit 1 >>> +
fi ^
syntax error, unexpected or operator
if test -n "$3"; then
echo "$3" >expect >>> +
if cmp stderr expect; then ^
: ignoring trailing garbage
else
echo "==== Error output was ====" >>> /2/3/4/5 a + b /6/7/8/
cat stderr ^
echo "==== instead of ====" syntax error, unexpected $undefined
cat expect
exit 1 >>> /2/3/4/5 a + b /6/7/8/
fi ^^^^^^^^^^^^^^^^^^^^^^
fi ignoring trailing garbage
}
>>> a - b
# Empty or unparsable strings ^
check '' '' syntax error, unexpected $undefined
check '+' ''
check '/2/3/4/5 a + b /6/7/8/' '' >>> a - b
^^^
ignoring trailing garbage
ap(@3 #0 "a")
>>> {a[*9999999999]}
^^^^^^^^^^
value too large ignored
Closure(@6 #0 [Star(@5 #0 0.. [ap(@4 #0 "a")])])
EOF
diff output expected
cat >recover.txt <<EOF cat >recover.txt <<EOF
...@@ -95,18 +107,3 @@ a & (, a & 0 ...@@ -95,18 +107,3 @@ a & (, a & 0
{a[->..0];b}, {a[->0..1];b} {a[->..0];b}, {a[->0..1];b}
EOF EOF
run 0 ../equals -E recover.txt run 0 ../equals -E recover.txt
check 'a - b' 'ap(@3 #0 "a")' '>>> a - b
^
syntax error, unexpected $undefined
>>> a - b
^^^
ignoring trailing garbage
'
check '{a[*9999999999]}' 'Closure(@5 #0 [Star(@4 #0 0.. [ap(@3 #0 "a")])])' \
'>>> {a[*9999999999]}
^^^^^^^^^^
value too large ignored
'
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <iostream> #include <iostream>
#include <fstream>
#include <cassert> #include <cassert>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
...@@ -30,7 +31,7 @@ ...@@ -30,7 +31,7 @@
static void static void
syntax(char* prog) syntax(char* prog)
{ {
std::cerr << prog << " [-d] formula" << std::endl; std::cerr << prog << " [-d] filename\n";
exit(2); exit(2);
} }
...@@ -43,40 +44,52 @@ main(int argc, char** argv) ...@@ -43,40 +44,52 @@ main(int argc, char** argv)
syntax(argv[0]); syntax(argv[0]);
bool debug = false; bool debug = false;
int formula_index = 1; int filename_index = 1;
if (!strcmp(argv[1], "-d")) if (!strcmp(argv[1], "-d"))
{ {
debug = true; debug = true;
if (argc < 3) if (argc < 3)
syntax(argv[0]); syntax(argv[0]);
formula_index = 2; filename_index = 2;
} }
{ std::ifstream fin(argv[filename_index]);
spot::environment& env(spot::default_environment::instance()); if (!fin)
auto f = [&]()
{ {
auto pf = spot::parse_infix_psl(argv[formula_index], env, debug); std::cerr << "Cannot open " << argv[filename_index] << '\n';
exit_code = pf.format_errors(std::cerr); exit(2);
return pf.f; }
}();
if (f) std::string input;
while (std::getline(fin, input))
{
{ {
spot::environment& env(spot::default_environment::instance());
auto f = [&]()
{
auto pf = spot::parse_infix_psl(input, env, debug);
// We want the errors on std::cout for the test suite.
exit_code = pf.format_errors(std::cout);
return pf.f;
}();
if (f)
{
#ifdef DOTTY #ifdef DOTTY
spot::print_dot_psl(std::cout, f); spot::print_dot_psl(std::cout, f);
#else #else
f.dump(std::cout) << std::endl; f.dump(std::cout) << '\n';
#endif #endif
} }
else else
{ {
exit_code = 1; exit_code = 1;
} }
} }
assert(spot::fnode::instances_check()); assert(spot::fnode::instances_check());
}
return exit_code; return exit_code;
} }
#! /bin/sh #! /bin/sh
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2012, 2013, 2015 Laboratoire de Recherche et # Copyright (C) 2012, 2013, 2015, 2016 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.
...@@ -24,22 +24,18 @@ ...@@ -24,22 +24,18 @@
. ./defs || exit 1 . ./defs || exit 1
set -e set -e
# ---- cat >input <<EOF
run 0 ../ltl2text '□◯a' >out □◯a
echo 'G(@5 #0 [X(@4 #0 [ap(@3 #0 "a")])])' > exp □◯"αβγ"
cmp out exp )a
"αβγ"X
# ---- EOF
run 0 ../ltl2text '□◯"αβγ"' >out
echo 'G(@5 #0 [X(@4 #0 [ap(@3 #0 "αβγ")])])' > exp
cmp out exp
run 1 ../ltl2text input >output
# ---- cat >expected <<EOF
set +x G(@5 #0 [X(@4 #0 [ap(@3 #0 "a")])])
run 1 ../ltl2text '□)◯a' 2>err G(@8 #0 [X(@7 #0 [ap(@6 #0 "αβγ")])])
set -x
cat >exp <<EOF
>>> )a >>> )a
^ ^
syntax error, unexpected closing parenthesis syntax error, unexpected closing parenthesis
...@@ -52,14 +48,7 @@ missing right operand for "always operator" ...@@ -52,14 +48,7 @@ missing right operand for "always operator"
^^^ ^^^
ignoring trailing garbage ignoring trailing garbage
EOF ff(@0 #0)
cmp exp err
# ----
set +x
run 1 ../ltl2text '"αβγ"X' 2>err
set -x
cat >exp <<EOF
>>> "αβγ"X >>> "αβγ"X
^ ^
syntax error, unexpected next operator syntax error, unexpected next operator
...@@ -68,9 +57,10 @@ syntax error, unexpected next operator ...@@ -68,9 +57,10 @@ syntax error, unexpected next operator
^ ^
ignoring trailing garbage ignoring trailing garbage
ap(@9 #0 "αβγ")
EOF EOF
cmp exp err
diff expected output
randltl --psl -8 --seed 0 --tree-size 16 a b c -n 100 > formulae randltl --psl -8 --seed 0 --tree-size 16 a b c -n 100 > formulae
../reduc -f -h 0 formulae ../reduc -f -h 0 formulae
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment