update-mocks: fix stubs generation for fatal().

We're going to need this, and the PRINTF_FMT(1,2) in front of it caused
mockup.sh to miss the declaration.

We also eliminate the obviously-unused fallback case (which referred
to daemon/*.h).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-10-29 21:29:04 +10:30
parent 82f252c79a
commit ee1fb07c8e

View file

@ -15,18 +15,13 @@ if [ $# -eq 0 ]; then
fi fi
for SYMBOL; do for SYMBOL; do
WHERE=$(grep -nH "^[a-z0-9_ ]* [*]*$SYMBOL(" */*.h ) WHERE=$(grep -nH "^[a-zA-Z0-9_ (),]* [*]*$SYMBOL(" */*.h )
if [ x"$WHERE" != x ]; then if [ x"$WHERE" != x ]; then
STUB='\n{ fprintf(stderr, "'$SYMBOL' called!\\n"); abort(); }' 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 else
echo "/* Could not find declaration for $SYMBOL */" echo "/* Could not find declaration for $SYMBOL */"
continue continue
fi fi
fi
echo "/* Generated stub for $SYMBOL */" echo "/* Generated stub for $SYMBOL */"
FILE=${WHERE%%:*} FILE=${WHERE%%:*}
@ -35,5 +30,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/" | sed 's/\s*$//' tail -n +$LINE < $FILE | head -n $NUM | sed 's/^extern *//' | sed 's/PRINTF_FMT([^)]*)//' | sed 's/NORETURN//g' | sed 's/,/ UNNEEDED,/g' | sed 's/\([a-z0-9A-Z*_]* [a-z0-9A-Z*_]*\));/\1 UNNEEDED);/' | sed "s/;\$/$STUB/" | sed 's/\s*$//'
done done