2
# This thing may be better off incorporated in Makefile.am.
4
# FIXME: sed implementation dependency
6
# This script does not work on some sed implementations, at least BSD sed.
7
# So GNU sed is explicitly used as temporary solution.
9
# $ ./collect.sh test-storage.c
10
# line 1 "test-storage.c"
11
# sed: 25: "259 { p; s/^.*$/vector/ ...": unexpected EOF (pending }'s)
14
# > The ``{'' can be preceded by white space and can be followed by white
15
# > space. The function can be preceded by white space. The terminating
16
# > ``}'' must be preceded by a newline or optional white space.
19
[ "x$2" = "x" ] || { echo >&2 "usage: collect.sh <c source>"; exit 1; }
23
decls=`grep -n '^TST_CASE[[:space:]]*(' "$1" | \
24
sed 's/^\([0-9]*:\)TST_CASE[[:space:]]*(/\1/'`
25
have_id=`echo "$decls" | sed -n '
26
/^\([0-9]*\):\([_[:alnum:]]*\),.*$/ {
27
s||\1 { p; s/^.*$/\2/; H; b skip_print; };|
31
need_id=`echo "$decls" | \
32
grep -n '^[0-9]*:[[:space:]]*"' | \
34
's|^\([0-9]*\):\([0-9]*\):.*$|\2 { s/(/(tst_\1, /; p; s/^.*$/tst_\1/; H; b skip_print; };|'`
36
@SED@ -n "$have_id""$need_id;p;"'
39
s/\n\([[:alnum:]_]*\)/\n TST_REGISTER(\1)/g