mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
update-mocks: allow a function to specify that mock should not abort.
We're going to add memleak_add_helper_, and we want the mock to be a noop, not an abort. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
837e6232c3
commit
17541e22a3
@ -19,22 +19,27 @@ for SYMBOL; do
|
|||||||
# If there are multiple declarations, pick first (eg. common/memleak.h
|
# If there are multiple declarations, pick first (eg. common/memleak.h
|
||||||
# has notleak_ as a declaration, and then an inline).
|
# has notleak_ as a declaration, and then an inline).
|
||||||
WHERE=$(grep -nH "^[a-zA-Z0-9_ (),]* [*]*$SYMBOL(" ./*/*.h | head -n1)
|
WHERE=$(grep -nH "^[a-zA-Z0-9_ (),]* [*]*$SYMBOL(" ./*/*.h | head -n1)
|
||||||
if [ x"$WHERE" != x ]; then
|
if [ x"$WHERE" = x ]; then
|
||||||
# \n on RHS is a GNU extension, and we want to work on FreeBSD
|
|
||||||
# shellcheck disable=SC1004
|
|
||||||
STUB='\
|
|
||||||
{ fprintf(stderr, "'$SYMBOL' called!\\n"); abort(); }'
|
|
||||||
else
|
|
||||||
echo "/* Could not find declaration for $SYMBOL */"
|
echo "/* Could not find declaration for $SYMBOL */"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "/* Generated stub for $SYMBOL */"
|
|
||||||
FILE=${WHERE%%:*}
|
FILE=${WHERE%%:*}
|
||||||
FILE_AND_LINE=${WHERE%:*}
|
FILE_AND_LINE=${WHERE%:*}
|
||||||
LINE=${FILE_AND_LINE#*:}
|
LINE=${FILE_AND_LINE#*:}
|
||||||
END=$(tail -n "+${LINE}" < "$FILE" | grep -n ';$');
|
END=$(tail -n "+${LINE}" < "$FILE" | grep -n ';$');
|
||||||
NUM=${END%%:*}
|
NUM=${END%%:*}
|
||||||
|
|
||||||
|
if grep -q "$SYMBOL.*mock empty" "$FILE"; then
|
||||||
|
STUB="{ }"
|
||||||
|
else
|
||||||
|
# \n on RHS is a GNU extension, and we want to work on FreeBSD
|
||||||
|
# shellcheck disable=SC1004
|
||||||
|
STUB='\
|
||||||
|
{ fprintf(stderr, "'$SYMBOL' called!\\n"); abort(); }'
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "/* Generated stub for $SYMBOL */"
|
||||||
|
|
||||||
tail -n "+${LINE}" < "$FILE" | head -n "$NUM" | sed 's/^extern *//' | sed 's/PRINTF_FMT([^)]*)//' | sed 's/NON_NULL_ARGS([^)]*)//' | sed 's/NO_NULL_ARGS//g' | sed 's/NORETURN//g' | sed 's/LAST_ARG_NULL//g' | sed 's/WARN_UNUSED_RESULT//g' | 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/NON_NULL_ARGS([^)]*)//' | sed 's/NO_NULL_ARGS//g' | sed 's/NORETURN//g' | sed 's/LAST_ARG_NULL//g' | sed 's/WARN_UNUSED_RESULT//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
|
||||||
|
Loading…
Reference in New Issue
Block a user