mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +01:00
daemon: first unit test, infrastructure.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
39
daemon/test/scripts/mockup.sh
Executable file
39
daemon/test/scripts/mockup.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#! /bin/sh
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
# With no args, read stdin to scrape compiler output.
|
||||
set -- $(while read LINE; do
|
||||
case "$LINE" in
|
||||
*undefined\ reference\ to*)
|
||||
LINE=${LINE#*undefined reference to \`}
|
||||
echo ${LINE%\'*}
|
||||
;;
|
||||
*)
|
||||
continue
|
||||
;;
|
||||
esac; done | sort -u)
|
||||
fi
|
||||
|
||||
for SYMBOL; do
|
||||
WHERE=$(grep -nH "^[a-z0-9_ ]* [*]*$SYMBOL(" daemon/*.h)
|
||||
if [ x"$WHERE" != x ]; then
|
||||
STUB='\n{ fprintf(stderr, "'$SYMBOL' called!\\n"); abort(); }'
|
||||
else
|
||||
WHERE=$(grep -nH "^extern \(const \)\?struct [a-zA-Z0-9_]* $SYMBOL;$" daemon/*.h)
|
||||
if [ x"$WHERE" != x ]; then
|
||||
STUB=';'
|
||||
else
|
||||
echo "/* Could not find declaration for $SYMBOL */"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "/* Generated stub for $SYMBOL */"
|
||||
FILE=${WHERE%%:*}
|
||||
FILE_AND_LINE=${WHERE%:*}
|
||||
LINE=${FILE_AND_LINE#*:}
|
||||
END=$(tail -n +$LINE < $FILE | grep -n ';$');
|
||||
NUM=${END%%:*}
|
||||
|
||||
tail -n +$LINE < $FILE | head -n $NUM | sed 's/^extern *//' | sed 's/PRINTF_FMT([^)]*)//' | sed "s/;\$/$STUB/"
|
||||
done
|
||||
Reference in New Issue
Block a user