mirror of
git://projects.qi-hardware.com/fped.git
synced 2025-04-21 12:27:27 +03:00
With a little help from m8cutils and abyss, we now have regression tests for
the topological sort. "make test" or "make tests" invokes the regression tests, "make valgrind" runs them under valgrind's watchful eyes. - fped.c (usage, main): added option -T to force batch mode (for regression testing) - Makefile, test/Common: added regression test infrastructure - test/tsort: test cases for the topological sort - README: added pointer to test/tsort git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5943 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
56
test/Common
Executable file
56
test/Common
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Common - Elements shared by all regression tests for fped
|
||||
#
|
||||
# Written 2010 by Werner Almesberger
|
||||
# Copyright 2010 Werner Almesberger
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
|
||||
|
||||
fped()
|
||||
{
|
||||
echo -n "$1: " 1>&2
|
||||
shift
|
||||
cat >_in
|
||||
$VALGRIND ../fped -T _in "$@" >_out 2>&1 || {
|
||||
echo FAILED "($SCRIPT)" 1>&2
|
||||
cat _out
|
||||
rm -f _in _out
|
||||
exit 1
|
||||
}
|
||||
rm -f _in
|
||||
}
|
||||
|
||||
|
||||
fped_fail()
|
||||
{
|
||||
echo -n "$1: " 1>&2
|
||||
shift
|
||||
cat >_in
|
||||
$VALGRIND ../fped -T _in "$@" >_out 2>&1 && {
|
||||
echo FAILED "($SCRIPT)" 1>&2
|
||||
cat _out
|
||||
rm -f _in _out
|
||||
exit 1
|
||||
}
|
||||
rm -f _in
|
||||
}
|
||||
|
||||
|
||||
expect()
|
||||
{
|
||||
diff -u - "$@" _out >_diff || {
|
||||
echo FAILED "($SCRIPT)" 1>&2
|
||||
cat _diff 1>&2
|
||||
rm -f _out _diff
|
||||
exit 1
|
||||
}
|
||||
echo PASSED 1>&2
|
||||
rm -f _out _diff
|
||||
passed=`expr ${passed:-0} + 1`
|
||||
}
|
||||
155
test/tsort
Normal file
155
test/tsort
Normal file
@@ -0,0 +1,155 @@
|
||||
#!/bin/sh
|
||||
. ./Common
|
||||
|
||||
###############################################################################
|
||||
|
||||
fped "tsort: total order" <<EOF
|
||||
package "_"
|
||||
|
||||
%tsort {
|
||||
a b
|
||||
a c
|
||||
a d
|
||||
b c
|
||||
b d
|
||||
c d
|
||||
}
|
||||
EOF
|
||||
expect <<EOF
|
||||
a
|
||||
b
|
||||
c
|
||||
d
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
fped "tsort: partial order change (1)" <<EOF
|
||||
package "_"
|
||||
|
||||
%tsort {
|
||||
a b
|
||||
a c
|
||||
a d
|
||||
d b
|
||||
}
|
||||
EOF
|
||||
expect <<EOF
|
||||
a
|
||||
c
|
||||
d
|
||||
b
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
fped "tsort: partial order change (2)" <<EOF
|
||||
package "_"
|
||||
|
||||
%tsort {
|
||||
b c
|
||||
c d
|
||||
a b
|
||||
}
|
||||
EOF
|
||||
expect <<EOF
|
||||
a
|
||||
b
|
||||
c
|
||||
d
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
fped "tsort: old order differs from resolution order" <<EOF
|
||||
package "_"
|
||||
|
||||
%tsort {
|
||||
+a +b +c +d
|
||||
a c
|
||||
a b
|
||||
a d
|
||||
}
|
||||
EOF
|
||||
expect <<EOF
|
||||
a
|
||||
b
|
||||
c
|
||||
d
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
fped "tsort: order change due to priority" <<EOF
|
||||
package "_"
|
||||
|
||||
%tsort {
|
||||
a b
|
||||
a c 1
|
||||
a d
|
||||
}
|
||||
EOF
|
||||
expect <<EOF
|
||||
a
|
||||
c
|
||||
b
|
||||
d
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
fped "tsort: priority accumulation without decay" <<EOF
|
||||
package "_"
|
||||
|
||||
%tsort {
|
||||
+a +b +c +d
|
||||
a b 1
|
||||
a d 1
|
||||
}
|
||||
EOF
|
||||
expect <<EOF
|
||||
a
|
||||
b
|
||||
d
|
||||
c
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
fped "tsort: priority accumulation with decay" <<EOF
|
||||
package "_"
|
||||
|
||||
%tsort {
|
||||
+a -b +c +d
|
||||
a b 1
|
||||
a d 1
|
||||
}
|
||||
EOF
|
||||
expect <<EOF
|
||||
a
|
||||
b
|
||||
c
|
||||
d
|
||||
EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
fped_fail "tsort: cycle" <<EOF
|
||||
package "_"
|
||||
|
||||
%tsort {
|
||||
a b
|
||||
b a
|
||||
}
|
||||
EOF
|
||||
expect <<EOF
|
||||
cycle detected in partial order
|
||||
Aborted (core dumped)
|
||||
EOF
|
||||
|
||||
# not entirely comfortable about the "Aborted (core dumped)". It's a system
|
||||
# message (from the shell) that may get mangled. Also, since few people keep
|
||||
# their cores these days, "(core dumped)" shouldn't really appear. Wonder why
|
||||
# it does. strace agrees that __WCOREFLAG is set ...
|
||||
|
||||
###############################################################################
|
||||
Reference in New Issue
Block a user