Date:2010-04-27 01:11:22 (9 years 4 months ago)
Author:werner
Commit:39fef16d1c4629dfad5feed05e0faaf7f91d08ca
Message: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



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5944 99fdad57-331a-0410-800a-d7fa5415bdb3
Files: Makefile (1 diff)
README (2 diffs)
fpd.y (4 diffs)
fped.c (4 diffs)
test/Common (3 diffs)
test/structure (1 diff)
test/tsort (8 diffs)

Change Details

Makefile
162162        LANG= sh -c \
163163          'passed=0 && cd test && \
164164          for n in [a-z]*; do \
165          SCRIPT=$$n . ./$$n; done; \
165          SCRIPT=$$n CWD_PREFIX=.. . ./$$n; done; \
166166          echo "Passed all $$passed tests"'
167167
168168valgrind:
README
148148unit mil
149149unit auto
150150
151If the "unit" directive is omitted, fped defaults to millimeters.
152
151153When saving a footprint definition, the default unit is set to the
152154unit set in the GUI.
153155
...... 
301303Package name
302304- - - - - -
303305
304The package name is a string of printable ASCII characters, including
305spaces.
306The package name is a non-empty string of printable ASCII characters,
307including spaces. If the "package" directive is omitted, fped defaults
308to using the name "_".
306309
307310package "<name>"
308311
fpd.y
342342    ;
343343
344344fpd:
345    | frame_defs part_name opt_unit frame_items
345    frame_defs part_name opt_unit opt_frame_items opt_measurements
346    | frame_defs unit opt_frame_items opt_measurements
347    | frame_defs frame_items opt_measurements
348    | frame_defs opt_measurements
346349    ;
347350
348351part_name:
...... 
364367    ;
365368
366369opt_unit:
367    | TOK_UNIT ID
370    | unit
371    ;
372
373unit:
374    TOK_UNIT ID
368375        {
369376            if (!strcmp($2, "mm"))
370377                curr_unit = curr_unit_mm;
...... 
400407                frames = curr_frame;
401408            last_frame = curr_frame;
402409        }
403        frame_items '}'
410        opt_frame_items '}'
404411        {
405412            set_frame(root_frame);
406413        }
407414    ;
408415
416opt_frame_items:
417    | frame_items
418    ;
419
409420frame_items:
410    | measurements
421    frame_item
411422    | frame_item frame_items
412423    ;
413424
...... 
763774        }
764775    ;
765776
777opt_measurements:
778    | measurements
779    ;
780
766781measurements:
767782    meas
768783        {
fped.c
6565static void usage(const char *name)
6666{
6767    fprintf(stderr,
68"usage: %s [-k] [-p|-P] [-T] [cpp_option ...] [in_file [out_file]]\n\n"
68"usage: %s [-k] [-p|-P] [-T [-T]] [cpp_option ...] [in_file [out_file]]\n\n"
6969" -k write KiCad output, then exit\n"
7070" -p write Postscript output, then exit\n"
7171" -P write Postscript output (full page), then exit\n"
7272" -T test mode. Load file, then exit\n"
73" -T -T test mode. Load file, dump to stdout, then exit\n"
7374" cpp_option -Idir, -Dname[=value], or -Uname\n"
7475    , name);
7576    exit(1);
...... 
8586    char opt[] = "-?";
8687    int error;
8788    int batch = 0;
89    int test_mode = 0;
8890    int batch_write_kicad = 0;
8991    int batch_write_ps = 0, batch_write_ps_fullpage = 0;
9092    int c;
...... 
102104            break;
103105        case 'T':
104106            batch = 1;
107            test_mode++;
105108            break;
106109        case 'D':
107110        case 'U':
...... 
167170        if (error)
168171            return error;
169172    }
173    if (test_mode > 1)
174        dump(stdout);
170175
171176    purge();
172177    inst_revert();
test/Common
1717    echo -n "$1: " 1>&2
1818    shift
1919    cat >_in
20    $VALGRIND ../fped -T _in "$@" >_out 2>&1 || {
20    $VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 || {
2121    echo FAILED "($SCRIPT)" 1>&2
2222    cat _out
2323    rm -f _in _out
...... 
2727}
2828
2929
30fped_dump()
31{
32    fped "$@" -T
33}
34
35
3036fped_fail()
3137{
3238    echo -n "$1: " 1>&2
3339    shift
3440    cat >_in
35    $VALGRIND ../fped -T _in "$@" >_out 2>&1 && {
41    $VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 && {
3642    echo FAILED "($SCRIPT)" 1>&2
3743    cat _out
3844    rm -f _in _out
...... 
5460    rm -f _out _diff
5561    passed=`expr ${passed:-0} + 1`
5662}
63
64
65if [ ! -z "$CWD_PREFIX" -a ! -z "$FPED" -a "$FPED" = "${FPED#/}" ]; then
66    FPED="$CWD_PREFIX/$FPED"
67fi
test/structure
1#!/bin/sh
2. ./Common
3
4###############################################################################
5
6fped_dump "structure: empty file" <<EOF
7EOF
8expect <<EOF
9/* MACHINE-GENERATED ! */
10
11package "_"
12unit mm
13EOF
14
15#------------------------------------------------------------------------------
16
17fped_dump "structure: just an empty frame definition" <<EOF
18frame foo {
19}
20EOF
21expect <<EOF
22/* MACHINE-GENERATED ! */
23
24frame foo {
25}
26
27package "_"
28unit mm
29EOF
30
31#------------------------------------------------------------------------------
32
33fped_dump "structure: just the package name" <<EOF
34package "hello"
35EOF
36expect <<EOF
37/* MACHINE-GENERATED ! */
38
39package "hello"
40unit mm
41EOF
42
43#------------------------------------------------------------------------------
44
45fped_dump "structure: just the unit" <<EOF
46unit mil
47EOF
48expect <<EOF
49/* MACHINE-GENERATED ! */
50
51package "_"
52unit mil
53EOF
54
55#------------------------------------------------------------------------------
56
57fped_dump "structure: just one root frame item" <<EOF
58vec @(1mm, 1mm)
59EOF
60expect <<EOF
61/* MACHINE-GENERATED ! */
62
63package "_"
64unit mm
65__0: vec @(1mm, 1mm)
66EOF
67
68#------------------------------------------------------------------------------
69
70fped_dump "structure: frame plus measurement" <<EOF
71frame f {
72    a: vec @(0mm, 0mm)
73    b: vec @(1mm, 1mm)
74}
75meas f.a -> f.b
76EOF
77expect <<EOF
78/* MACHINE-GENERATED ! */
79
80frame f {
81    a: vec @(0mm, 0mm)
82    b: vec @(1mm, 1mm)
83}
84
85package "_"
86unit mm
87meas f.a -> f.b
88EOF
89
90#------------------------------------------------------------------------------
91
92fped_fail "structure: measurement in frame" <<EOF
93frame f {
94    a: vec @(0mm, 0mm)
95    b: vec @(1mm, 1mm)
96    meas f.a -> f.b
97}
98EOF
99expect <<EOF
1004: syntax error near "meas"
101EOF
102
103###############################################################################
test/tsort
44###############################################################################
55
66fped "tsort: total order" <<EOF
7package "_"
8
97%tsort {
108    a b
119    a c
...... 
2523#------------------------------------------------------------------------------
2624
2725fped "tsort: partial order change (1)" <<EOF
28package "_"
29
3026%tsort {
3127    a b
3228    a c
...... 
4440#------------------------------------------------------------------------------
4541
4642fped "tsort: partial order change (2)" <<EOF
47package "_"
48
4943%tsort {
5044    b c
5145    c d
...... 
6256#------------------------------------------------------------------------------
6357
6458fped "tsort: old order differs from resolution order" <<EOF
65package "_"
66
6759%tsort {
6860    +a +b +c +d
6961    a c
...... 
8173#------------------------------------------------------------------------------
8274
8375fped "tsort: order change due to priority" <<EOF
84package "_"
85
8676%tsort {
8777    a b
8878    a c 1
...... 
9989#------------------------------------------------------------------------------
10090
10191fped "tsort: priority accumulation without decay" <<EOF
102package "_"
103
10492%tsort {
10593    +a +b +c +d
10694    a b 1
...... 
117105#------------------------------------------------------------------------------
118106
119107fped "tsort: priority accumulation with decay" <<EOF
120package "_"
121
122108%tsort {
123109    +a -b +c +d
124110    a b 1
...... 
135121#------------------------------------------------------------------------------
136122
137123fped_fail "tsort: cycle" <<EOF
138package "_"
139
140124%tsort {
141125    a b
142126    b a

Archive Download the corresponding diff file

Branches:
master



interactive