[PATCH v2 libinput] add simple symbols leak checker
Peter Hutterer
peter.hutterer at who-t.net
Mon Feb 2 14:48:54 PST 2015
On Mon, Feb 02, 2015 at 01:16:23PM +0100, Marek Chalupa wrote:
> This patch adds simple script that compares libinput.sym file to the
> functions that are marked by LIBINPUT_EXPORT. This script is added
> to make check target.
>
> v2. use noinst_SCRIPTS instead of dummy target
> drop .sh suffix
> generate the script from .in file
> use -u swich when running diff
>
> Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
> ---
> test/Makefile.am | 8 +++++++-
> test/symbols-leak-test.in | 20 ++++++++++++++++++++
> 2 files changed, 27 insertions(+), 1 deletion(-)
> create mode 100755 test/symbols-leak-test.in
>
> diff --git a/test/Makefile.am b/test/Makefile.am
> index 5b9c7ab..51a0798 100644
> --- a/test/Makefile.am
> +++ b/test/Makefile.am
> @@ -50,7 +50,13 @@ build_tests = \
> test-build-std-gnuc90
>
> noinst_PROGRAMS = $(build_tests) $(run_tests)
> -TESTS = $(run_tests)
> +noinst_SCRIPTS = symbols-leak-test
> +TESTS = $(run_tests) symbols-leak-test
> +
> +symbols-leak-test: symbols-leak-test.in
> + $(AM_V_GEN)$(SED) \
> + -e 's|@top_srcdir[@]|$(top_srcdir)|g' $< > $@
> + chmod +x $@
this shouldn't be needed, if you add test/symbols-leak-test to the
AC_CONFIG_FILE automake will do the sed for you (see libinput.doxygen.in for
example). you can add the chmod +x there too.
http://www.gnu.org/software/automake/manual/html_node/Scripts.html
> .NOTPARALLEL:
>
> diff --git a/test/symbols-leak-test.in b/test/symbols-leak-test.in
> new file mode 100755
> index 0000000..98f3fd9
> --- /dev/null
> +++ b/test/symbols-leak-test.in
> @@ -0,0 +1,20 @@
> +#!/bin/sh
> +
> +### simple check for exported symbols
> +
> +# make sure the paths are alright
> +cd `dirname $0`
> +
> +cat @top_srcdir@/src/libinput.sym | \
> + grep '^\s\+libinput_.*' | \
> + sed -e 's/^\s\+\(.*\);/\1/' | sort > libinput.sym.symbols
> +cat @top_srcdir@/src/*.c | \
> + grep LIBINPUT_EXPORT -A 1 | grep '^libinput_.*' | \
> + sed -e 's/(.*//' | sort > exported.symbols
> +
> +diff -a -u libinput.sym.symbols exported.symbols
> +CODE=$?
> +
> +rm libinput.sym.symbols exported.symbols
> +
> +exit $CODE
> --
> 2.2.2
have you thought about using anonymous pipes/process substitution for this?
that would make this a simpler and remove the need for temp files though it
does add a requirement on bash over sh. we can live with that, I reckon.
basically the approach is
diff <(echo foo) <(echo bar)
http://en.wikipedia.org/wiki/Process_substitution
so the script after substitution becomes:
diff -a -u \
<(cat ../src/libinput.sym | \
grep '^\s\+libinput_.*' | \
sed -e 's/^\s\+\(.*\);/\1/' | sort) \
<(cat ../src/*.c | \
grep LIBINPUT_EXPORT -A 1 | grep '^libinput_.*' | \
sed -e 's/(.*//' | sort)
Cheers,
Peter
More information about the wayland-devel
mailing list