mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
test: generalize update-mocks
So we can use it in other directories. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
dec3b9d030
commit
d30b67a3fe
15
Makefile
15
Makefile
@ -350,6 +350,21 @@ clean: daemon-clean wire-clean
|
|||||||
|
|
||||||
include daemon/Makefile
|
include daemon/Makefile
|
||||||
|
|
||||||
|
update-mocks/%: %
|
||||||
|
@set -e; BASE=/tmp/mocktmp.$$$$.`echo $* | tr / _`; trap "rm -f $$BASE.*" EXIT; \
|
||||||
|
START=`fgrep -n '/* AUTOGENERATED MOCKS START */' $< | cut -d: -f1`;\
|
||||||
|
END=`fgrep -n '/* AUTOGENERATED MOCKS END */' $< | cut -d: -f1`; \
|
||||||
|
if [ -n "$$START" ]; then \
|
||||||
|
echo $<: ; \
|
||||||
|
head -n $$START $< > $$BASE.new; \
|
||||||
|
(cat $$BASE.new; tail -n +$$END $<) > $$BASE.test.c; \
|
||||||
|
if ! $(CC) $(CFLAGS) $$BASE.test.c -o $$BASE.out $(HELPER_OBJS) $(CCAN_OBJS) $(LDLIBS) 2>$$BASE.err; then \
|
||||||
|
daemon/test/scripts/mockup.sh < $$BASE.err >> $$BASE.new; \
|
||||||
|
sed -n 's,.*Generated stub for \(.*\) .*,\t\1,p' < $$BASE.new; \
|
||||||
|
fi; \
|
||||||
|
tail -n +$$END $< >> $$BASE.new; mv $$BASE.new $<; \
|
||||||
|
fi
|
||||||
|
|
||||||
unittest/%: %
|
unittest/%: %
|
||||||
$(VALGRIND) $(VALGRIND_TEST_ARGS) $*
|
$(VALGRIND) $(VALGRIND_TEST_ARGS) $*
|
||||||
|
|
||||||
|
@ -61,22 +61,7 @@ DAEMON_TEST_SRC := $(wildcard daemon/test/run-*.c)
|
|||||||
DAEMON_TEST_OBJS := $(DAEMON_TEST_SRC:.c=.o)
|
DAEMON_TEST_OBJS := $(DAEMON_TEST_SRC:.c=.o)
|
||||||
DAEMON_TEST_PROGRAMS := $(DAEMON_TEST_OBJS:.o=)
|
DAEMON_TEST_PROGRAMS := $(DAEMON_TEST_OBJS:.o=)
|
||||||
|
|
||||||
update-mocks-daemon/test/%: daemon/test/%
|
update-mocks: $(DAEMON_TEST_SRC:%=update-mocks/%)
|
||||||
@set -e; trap "rm -f mocktmp.$*.*" EXIT; \
|
|
||||||
START=`fgrep -n '/* AUTOGENERATED MOCKS START */' $< | cut -d: -f1`;\
|
|
||||||
END=`fgrep -n '/* AUTOGENERATED MOCKS END */' $< | cut -d: -f1`; \
|
|
||||||
if [ -n "$$START" ]; then \
|
|
||||||
echo $<: ; \
|
|
||||||
head -n $$START $< > mocktmp.$*.new; \
|
|
||||||
(cat mocktmp.$*.new; tail -n +$$END $<) > mocktmp.$*.test.c; \
|
|
||||||
if ! $(CC) $(CFLAGS) mocktmp.$*.test.c -o mocktmp.$*.out $(HELPER_OBJS) $(CCAN_OBJS) $(LDLIBS) 2>mocktmp.$*.err; then \
|
|
||||||
daemon/test/scripts/mockup.sh < mocktmp.$*.err >> mocktmp.$*.new; \
|
|
||||||
sed -n 's,.*Generated stub for \(.*\) .*,\t\1,p' < mocktmp.$*.new; \
|
|
||||||
fi; \
|
|
||||||
tail -n +$$END $< >> mocktmp.$*.new; mv mocktmp.$*.new $<; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
update-mocks: $(DAEMON_TEST_SRC:%=update-mocks-%)
|
|
||||||
|
|
||||||
$(DAEMON_TEST_PROGRAMS): $(CCAN_OBJS) $(BITCOIN_OBJS) $(CORE_OBJS) libsecp256k1.a utils.o
|
$(DAEMON_TEST_PROGRAMS): $(CCAN_OBJS) $(BITCOIN_OBJS) $(CORE_OBJS) libsecp256k1.a utils.o
|
||||||
|
|
||||||
|
@ -35,5 +35,5 @@ for SYMBOL; do
|
|||||||
END=$(tail -n +$LINE < $FILE | grep -n ';$');
|
END=$(tail -n +$LINE < $FILE | grep -n ';$');
|
||||||
NUM=${END%%:*}
|
NUM=${END%%:*}
|
||||||
|
|
||||||
tail -n +$LINE < $FILE | head -n $NUM | sed 's/^extern *//' | sed 's/PRINTF_FMT([^)]*)//' | sed 's/,/ UNNEEDED,/g' | sed 's/\([a-z0-9A-Z*_]* [a-z0-9A-Z*_]*\));/\1 UNNEEDED);/' | sed "s/;\$/$STUB/"
|
tail -n +$LINE < $FILE | head -n $NUM | sed 's/^extern *//' | sed 's/PRINTF_FMT([^)]*)//' | sed 's/,/ UNNEEDED,/g' | sed 's/\([a-z0-9A-Z*_]* [a-z0-9A-Z*_]*\));/\1 UNNEEDED);/' | sed "s/;\$/$STUB/" | sed 's/\s*$//'
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user