Harden make-cairo-test-constructors.sh

The make-cairo-test-constructors.sh script executes several commands
without checking their success. This can lead to undetected errors,
like those fixed in 86fad78fcd.

The script now exits with an error status if no file is
input. Moreover, it sets the '-e' flag, so that if a command fails,
the whole script is immediately terminated with an error.

In the Makefile.am, the script result is now checked and the target
file is removed upon error. This ensures that the
'cairo-test-constructors.c' target completes succesfully only if no
error occurred.

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
This commit is contained in:
Andrea Canciani 2015-03-12 17:02:02 +01:00 committed by Bryce Harrington
parent ec0153940d
commit b19b06c463
2 changed files with 4 additions and 2 deletions

View file

@ -81,7 +81,7 @@ noinst_SCRIPTS = check-refs.sh
TESTS += cairo-test-suite$(EXEEXT)
cairo-test-constructors.c: Makefile $(test_sources) make-cairo-test-constructors.sh
(cd $(srcdir) && sh ./make-cairo-test-constructors.sh $(test_sources)) > $@
(cd $(srcdir) && sh ./make-cairo-test-constructors.sh $(test_sources)) > $@ || (rm $@ ; exit 1)
cairo_test_suite_SOURCES = \
$(cairo_test_suite_sources) \

View file

@ -1,8 +1,10 @@
#! /bin/sh
set -e
if test $# -eq 0; then
echo "$0: no input files." >&2
exit 0
exit 1
fi
cat <<HERE