r5944 - in trunk/eda/fped: . test
werner at docs.openmoko.org
werner at docs.openmoko.org
Tue Apr 27 01:11:22 CEST 2010
Author: werner
Date: 2010-04-27 01:11:22 +0200 (Tue, 27 Apr 2010)
New Revision: 5944
Added:
trunk/eda/fped/test/structure
Modified:
trunk/eda/fped/Makefile
trunk/eda/fped/README
trunk/eda/fped/fpd.y
trunk/eda/fped/fped.c
trunk/eda/fped/test/Common
trunk/eda/fped/test/tsort
Log:
Got rid of the requirement to have a "package" directive. Fixed a grammar error
found in the process. Also taught the regression test system a new trick: the
path to "fped" can be passed in the environment variable FPED. E.g.,
FPED=fped.r5943 make test
- fped.c (usage, main): duplicating the -T option produces a dump to stdout
before exiting (like %dump would)
- test/Common: new command fped_dump to invoked fped with a second -T option
- test/Common: if the environment variable FPED is set, use its content to
invoke fped (default is ../fped)
- test/Common: if the environment variable CWD_PREFIX is set, prepend it to
$FPED if the latter is a relative path
- Makefile (test, tests): set CWD_PREFIX to .., so that the path given in FPED
is valid at the point of invocation
- fpd.y: revised grammar to make "package" optional
- fpd.y: measurements were syntactically allowed inside non-root frame
(test/structure)
- test/structure: test various combinations of the grammatical file structure
- test/tsort: removed all the now unnecessary "package" directives
Modified: trunk/eda/fped/Makefile
===================================================================
--- trunk/eda/fped/Makefile 2010-04-26 21:30:21 UTC (rev 5943)
+++ trunk/eda/fped/Makefile 2010-04-26 23:11:22 UTC (rev 5944)
@@ -162,7 +162,7 @@
LANG= sh -c \
'passed=0 && cd test && \
for n in [a-z]*; do \
- SCRIPT=$$n . ./$$n; done; \
+ SCRIPT=$$n CWD_PREFIX=.. . ./$$n; done; \
echo "Passed all $$passed tests"'
valgrind:
Modified: trunk/eda/fped/README
===================================================================
--- trunk/eda/fped/README 2010-04-26 21:30:21 UTC (rev 5943)
+++ trunk/eda/fped/README 2010-04-26 23:11:22 UTC (rev 5944)
@@ -148,6 +148,8 @@
unit mil
unit auto
+If the "unit" directive is omitted, fped defaults to millimeters.
+
When saving a footprint definition, the default unit is set to the
unit set in the GUI.
@@ -301,8 +303,9 @@
Package name
- - - - - -
-The package name is a string of printable ASCII characters, including
-spaces.
+The package name is a non-empty string of printable ASCII characters,
+including spaces. If the "package" directive is omitted, fped defaults
+to using the name "_".
package "<name>"
Modified: trunk/eda/fped/fpd.y
===================================================================
--- trunk/eda/fped/fpd.y 2010-04-26 21:30:21 UTC (rev 5943)
+++ trunk/eda/fped/fpd.y 2010-04-26 23:11:22 UTC (rev 5944)
@@ -342,7 +342,10 @@
;
fpd:
- | frame_defs part_name opt_unit frame_items
+ frame_defs part_name opt_unit opt_frame_items opt_measurements
+ | frame_defs unit opt_frame_items opt_measurements
+ | frame_defs frame_items opt_measurements
+ | frame_defs opt_measurements
;
part_name:
@@ -364,7 +367,11 @@
;
opt_unit:
- | TOK_UNIT ID
+ | unit
+ ;
+
+unit:
+ TOK_UNIT ID
{
if (!strcmp($2, "mm"))
curr_unit = curr_unit_mm;
@@ -400,14 +407,18 @@
frames = curr_frame;
last_frame = curr_frame;
}
- frame_items '}'
+ opt_frame_items '}'
{
set_frame(root_frame);
}
;
+opt_frame_items:
+ | frame_items
+ ;
+
frame_items:
- | measurements
+ frame_item
| frame_item frame_items
;
@@ -763,6 +774,10 @@
}
;
+opt_measurements:
+ | measurements
+ ;
+
measurements:
meas
{
Modified: trunk/eda/fped/fped.c
===================================================================
--- trunk/eda/fped/fped.c 2010-04-26 21:30:21 UTC (rev 5943)
+++ trunk/eda/fped/fped.c 2010-04-26 23:11:22 UTC (rev 5944)
@@ -65,11 +65,12 @@
static void usage(const char *name)
{
fprintf(stderr,
-"usage: %s [-k] [-p|-P] [-T] [cpp_option ...] [in_file [out_file]]\n\n"
+"usage: %s [-k] [-p|-P] [-T [-T]] [cpp_option ...] [in_file [out_file]]\n\n"
" -k write KiCad output, then exit\n"
" -p write Postscript output, then exit\n"
" -P write Postscript output (full page), then exit\n"
" -T test mode. Load file, then exit\n"
+" -T -T test mode. Load file, dump to stdout, then exit\n"
" cpp_option -Idir, -Dname[=value], or -Uname\n"
, name);
exit(1);
@@ -85,6 +86,7 @@
char opt[] = "-?";
int error;
int batch = 0;
+ int test_mode = 0;
int batch_write_kicad = 0;
int batch_write_ps = 0, batch_write_ps_fullpage = 0;
int c;
@@ -102,6 +104,7 @@
break;
case 'T':
batch = 1;
+ test_mode++;
break;
case 'D':
case 'U':
@@ -167,6 +170,8 @@
if (error)
return error;
}
+ if (test_mode > 1)
+ dump(stdout);
purge();
inst_revert();
Modified: trunk/eda/fped/test/Common
===================================================================
--- trunk/eda/fped/test/Common 2010-04-26 21:30:21 UTC (rev 5943)
+++ trunk/eda/fped/test/Common 2010-04-26 23:11:22 UTC (rev 5944)
@@ -17,7 +17,7 @@
echo -n "$1: " 1>&2
shift
cat >_in
- $VALGRIND ../fped -T _in "$@" >_out 2>&1 || {
+ $VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 || {
echo FAILED "($SCRIPT)" 1>&2
cat _out
rm -f _in _out
@@ -27,12 +27,18 @@
}
+fped_dump()
+{
+ fped "$@" -T
+}
+
+
fped_fail()
{
echo -n "$1: " 1>&2
shift
cat >_in
- $VALGRIND ../fped -T _in "$@" >_out 2>&1 && {
+ $VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 && {
echo FAILED "($SCRIPT)" 1>&2
cat _out
rm -f _in _out
@@ -54,3 +60,8 @@
rm -f _out _diff
passed=`expr ${passed:-0} + 1`
}
+
+
+if [ ! -z "$CWD_PREFIX" -a ! -z "$FPED" -a "$FPED" = "${FPED#/}" ]; then
+ FPED="$CWD_PREFIX/$FPED"
+fi
Added: trunk/eda/fped/test/structure
===================================================================
--- trunk/eda/fped/test/structure (rev 0)
+++ trunk/eda/fped/test/structure 2010-04-26 23:11:22 UTC (rev 5944)
@@ -0,0 +1,103 @@
+#!/bin/sh
+. ./Common
+
+###############################################################################
+
+fped_dump "structure: empty file" <<EOF
+EOF
+expect <<EOF
+/* MACHINE-GENERATED ! */
+
+package "_"
+unit mm
+EOF
+
+#------------------------------------------------------------------------------
+
+fped_dump "structure: just an empty frame definition" <<EOF
+frame foo {
+}
+EOF
+expect <<EOF
+/* MACHINE-GENERATED ! */
+
+frame foo {
+}
+
+package "_"
+unit mm
+EOF
+
+#------------------------------------------------------------------------------
+
+fped_dump "structure: just the package name" <<EOF
+package "hello"
+EOF
+expect <<EOF
+/* MACHINE-GENERATED ! */
+
+package "hello"
+unit mm
+EOF
+
+#------------------------------------------------------------------------------
+
+fped_dump "structure: just the unit" <<EOF
+unit mil
+EOF
+expect <<EOF
+/* MACHINE-GENERATED ! */
+
+package "_"
+unit mil
+EOF
+
+#------------------------------------------------------------------------------
+
+fped_dump "structure: just one root frame item" <<EOF
+vec @(1mm, 1mm)
+EOF
+expect <<EOF
+/* MACHINE-GENERATED ! */
+
+package "_"
+unit mm
+__0: vec @(1mm, 1mm)
+EOF
+
+#------------------------------------------------------------------------------
+
+fped_dump "structure: frame plus measurement" <<EOF
+frame f {
+ a: vec @(0mm, 0mm)
+ b: vec @(1mm, 1mm)
+}
+meas f.a -> f.b
+EOF
+expect <<EOF
+/* MACHINE-GENERATED ! */
+
+frame f {
+ a: vec @(0mm, 0mm)
+ b: vec @(1mm, 1mm)
+}
+
+package "_"
+unit mm
+meas f.a -> f.b
+EOF
+
+#------------------------------------------------------------------------------
+
+fped_fail "structure: measurement in frame" <<EOF
+frame f {
+ a: vec @(0mm, 0mm)
+ b: vec @(1mm, 1mm)
+ meas f.a -> f.b
+}
+EOF
+expect <<EOF
+4: syntax error near "meas"
+EOF
+
+###############################################################################
Property changes on: trunk/eda/fped/test/structure
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/eda/fped/test/tsort
===================================================================
--- trunk/eda/fped/test/tsort 2010-04-26 21:30:21 UTC (rev 5943)
+++ trunk/eda/fped/test/tsort 2010-04-26 23:11:22 UTC (rev 5944)
@@ -4,8 +4,6 @@
###############################################################################
fped "tsort: total order" <<EOF
-package "_"
-
%tsort {
a b
a c
@@ -25,8 +23,6 @@
#------------------------------------------------------------------------------
fped "tsort: partial order change (1)" <<EOF
-package "_"
-
%tsort {
a b
a c
@@ -44,8 +40,6 @@
#------------------------------------------------------------------------------
fped "tsort: partial order change (2)" <<EOF
-package "_"
-
%tsort {
b c
c d
@@ -62,8 +56,6 @@
#------------------------------------------------------------------------------
fped "tsort: old order differs from resolution order" <<EOF
-package "_"
-
%tsort {
+a +b +c +d
a c
@@ -81,8 +73,6 @@
#------------------------------------------------------------------------------
fped "tsort: order change due to priority" <<EOF
-package "_"
-
%tsort {
a b
a c 1
@@ -99,8 +89,6 @@
#------------------------------------------------------------------------------
fped "tsort: priority accumulation without decay" <<EOF
-package "_"
-
%tsort {
+a +b +c +d
a b 1
@@ -117,8 +105,6 @@
#------------------------------------------------------------------------------
fped "tsort: priority accumulation with decay" <<EOF
-package "_"
-
%tsort {
+a -b +c +d
a b 1
@@ -135,8 +121,6 @@
#------------------------------------------------------------------------------
fped_fail "tsort: cycle" <<EOF
-package "_"
-
%tsort {
a b
b a
More information about the commitlog
mailing list