Add text I/O for Kripke structures.

* src/kripke/kripkeexplicit.cc, src/kripke/kripkeexplicit.hh,
src/kripke/kripkeprint.cc, src/kripke/kripkeprint.hh: New files.
* src/kripke/Makefile.am: Add them.
* src/kripkeparse/fmterror.cc, src/kripkeparse/kripkeparse.yy,
src/kripkeparse/kripkescan.ll, src/kripkeparse/parsedecl.hh,
src/kripkeparse/public.hh, src/kripkeparse/scankripke.ll: New
files.
* src/kripkeparse/Makefile.am: Add them.
* src/kripketest/bad_parsing.test, src/kripketest/defs.in,
src/kripketest/kripke.test, src/kripketest/origin,
src/kripketest/parse_print_test.cc: New files.
* src/kripketest/Makefile.am: Add them.
* src/Makefile.am (SUBDIRS): Add kripkeparse and kripketest.
* README: Document src/kripketest/ and src/kripkeparse/.
* configure.ac: Generate src/kripkeparse/Makefile,
src/kripketest/Makefile, src/kripketest/defs.
* iface/dve2/defs.in (run2): New function.
* iface/dve2/dve2check.cc (syntax, main): Add option -gK.
* iface/dve2/kripke.test: New file.
* iface/dve2/Makefile.am (TESTS): Add kripke.test.
This commit is contained in:
Thomas Badie 2011-11-24 22:47:41 +01:00 committed by Alexandre Duret-Lutz
parent 71d1a4fe25
commit bb5949f6de
28 changed files with 1824 additions and 7 deletions

2
src/kripketest/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
Makefile
Makefile.in

View file

@ -0,0 +1,42 @@
## Copyright (C) 2011 Laboratoire de Recherche et Developpement de l'Epita
##
## This file is part of Spot, a model checking library.
##
## Spot is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## Spot is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
## License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Spot; see the file COPYING. If not, write to the Free
## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
AM_CPPFLAGS = -I$(srcdir)/.. $(BUDDY_CPPFLAGS)
kripketestdir = $(pkgincludedir)/kripketest
kripketest_HEADERS =
LDADD = ../libspot.la ../../buddy/src/.libs/libbdd.so
check_SCRIPTS = defs
parse_print_SOURCES = parse_print_test.cc
check_PROGRAMS = \
parse_print
TESTS = \
kripke.test \
bad_parsing.test
EXTRA_DIST = $(TESTS)
distclean-local:
rm -rf $(TESTS:.test=.dir)

91
src/kripketest/bad_parsing.test Executable file
View file

@ -0,0 +1,91 @@
#! /bin/sh
# Copyright (C) 2011 Laboratoire de Recherche et Developpement
# de l'Epita (LRDE)
#
# This file is part of Spot, a model checking library.
#
# Spot is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Spot is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Spot; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
. ./defs
set -e
cat >input <<\EOF
state;
EOF
cat >expected <<\EOF
input:1.6: syntax error, unexpected ;, expecting ","
EOF
run 1 ../parse_print input 2> output
cat output | grep -v + > res
diff expected res
rm -f output res expected
cat >input <<\EOF
state1, "a & b, state2;
EOF
cat >expected <<\EOF
input:1.9-24: unterminated string
input:1.25-24: syntax error, unexpected $end, expecting ","
EOF
run 1 ../parse_print input 2> output
cat output | grep -v + > res
diff expected res
rm -f output res expected
cat >input <<\EOF
state, "", ;
,,;
EOF
cat >expected <<\EOF
input:1.9-8: empty input
input:2.1: syntax error, unexpected ",", expecting $end
EOF
run 1 ../parse_print input 2> output
cat output | grep -v + > res
diff expected res
rm -f output res expected
cat >input <<\EOF
state,, state3
state2, "a & b", state2;
EOF
s="input:2.7: syntax error, unexpected \",\", expecting STRING"
s2=" or UNTERMINATED_STRING or IDENT or ;"
string="$s$s2";
echo $string > expected
run 1 ../parse_print input 2> output
cat output | grep -v + > res
diff expected res
rm -f output res expected

128
src/kripketest/defs.in Normal file
View file

@ -0,0 +1,128 @@
# -*- shell-script -*-
# Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
# Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de Paris 6 (LIP6),
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
# et Marie Curie.
#
# This file is part of Spot, a model checking library.
#
# Spot is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Spot is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Spot; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# Ensure we are running from the right directory.
test -f ./defs || {
echo "defs: not found in current directory" 1>&2
exit 1
}
# If srcdir is not set, then we are not running from `make check'.
if test -z "$srcdir"; then
# compute $srcdir.
srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
test $srcdir = $0 && srcdir=.
fi
# Ensure $srcdir is set correctly.
test -f $srcdir/defs.in || {
echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
exit 1
}
echo "== Running test $0"
me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
testSubDir=$me.dir
chmod -R a+rwx $testSubDir > /dev/null 2>&1
rm -rf $testSubDir > /dev/null 2>&1
mkdir $testSubDir
cd $testSubDir
# Adjust srcdir now that we are in a subdirectory. We still want to
# source directory corresponding to the build directory that contains
# $testSubDir.
case $srcdir in
# I
[\\/$]* | ?:[\\/]* );;
*) srcdir=../$srcdir
esac
DOT='@DOT@'
top_builddir='../@top_builddir@'
LBTT="@LBTT@"
LBTT_TRANSLATE="@LBTT_TRANSLATE@"
VALGRIND='@VALGRIND@'
SPIN='@SPIN@'
LTL2BA='@LTL2BA@'
top_srcdir='../@top_srcdir@'
run()
{
expected_exitcode=$1
shift
exitcode=0
if test -n "$VALGRIND"; then
exec 6>valgrind.err
GLIBCPP_FORCE_NEW=1 \
../../../libtool --mode=execute \
$VALGRIND --tool=memcheck --leak-check=yes --log-fd=6 -q "$@" ||
exitcode=$?
cat valgrind.err 1>&2
test -z "`sed 1q valgrind.err`" || exit 50
rm -f valgrind.err
else
"$@" || exitcode=$?
fi
test $exitcode = $expected_exitcode || exit 1
}
run2()
{
expected_exitcode=$1
shift
exitcode=0
if test -n "$VALGRIND"; then
exec 6>valgrind.err
GLIBCPP_FORCE_NEW=1 \
../../../libtool --mode=execute \
$VALGRIND --tool=memcheck --leak-check=yes --log-fd=6 -q "$@" | grep -v + > log ||
exitcode=$?
cat valgrind.err 1>&2
test -z "`sed 1q valgrind.err`" || exit 50
rm -f valgrind.err
else
"$@" || exitcode=$?
fi
test $exitcode = $expected_exitcode || exit 1
exec 6>valgrind.err
../../../libtool --mode=execute \
$VALGRIND --tool=memcheck --leak-check=yes --log-fd=6 -q $1 log \
| grep -v + > log2 ||
exitcode=$?
cat valgrind.err 1>&2
test -z "`sed 1q valgrind.err`" || exit 50
rm -f valgrind.err
test $exitcode = $expected_exitcode || exit 1
diff log log2 || exit 42
rm -f log log2
}
set -x

71
src/kripketest/kripke.test Executable file
View file

@ -0,0 +1,71 @@
#! /bin/sh
# Copyright (C) 2011 Laboratoire de Recherche et Developpement
# de l'Epita (LRDE)
#
# This file is part of Spot, a model checking library.
#
# Spot is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Spot is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Spot; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
. ./defs
set -e
cat >input <<\EOF
state1, "!b", state2;
state2, "a&b", state3;
state3, "a", state4 state1;
state4, "b", state1;
EOF
run2 0 ../parse_print input
cat >input <<\EOF
state1, , state1 state2;
state2, , state1 state2;
EOF
run2 0 ../parse_print input
cat >input <<\EOF
state42, "!b & !a", state40;
state40, "!a | b", state42;
EOF
run2 0 ../parse_print input
cat >input <<\EOF
state1, "a&b", state1;
EOF
run2 0 ../parse_print input
cat >input <<\EOF
state51,,state60 state17 state3 state18 state62;
EOF
run2 0 ../parse_print input
cat >input <<\EOF
s42, "a&b|c&d", s51 s69 s73 s7;
s7, "a&a&a&!a", s42 s51 s69 s73 s42;
EOF
run2 0 ../parse_print input

4
src/kripketest/origin Normal file
View file

@ -0,0 +1,4 @@
state1, "!b", state2;
state2, "a&b", state3;
state3, "a", state4 state1;
state4, "b", state1;

View file

@ -0,0 +1,58 @@
// Copyright (C) 2011 Laboratoire de Recherche et Developpement
// de l'Epita (LRDE)
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include "../kripkeparse/public.hh"
#include "../kripkeparse/parsedecl.hh"
#include "../kripke/kripkeprint.hh"
#include "../tgba/bddprint.hh"
#include "ltlast/allnodes.hh"
using namespace spot;
int main(int argc, char** argv)
{
int returnValue = 0;
kripke_parse_error_list pel;
bdd_dict* dict = new bdd_dict;
kripke_explicit* k = kripke_parse(argv[1], pel, dict);
if (!pel.empty())
{
format_kripke_parse_errors(std::cerr, argv[1], pel);
returnValue = 1;
}
if (!returnValue)
{
KripkePrinter* kp = new KripkePrinter(k, std::cout);
kp->run();
delete kp;
}
delete k;
delete dict;
assert(ltl::atomic_prop::instance_count() == 0);
assert(ltl::unop::instance_count() == 0);
assert(ltl::binop::instance_count() == 0);
assert(ltl::multop::instance_count() == 0);
return returnValue;
}