cairo/test/make-cairo-test-constructors.sh
Andrea Canciani b19b06c463 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>
2015-03-13 13:18:32 -07:00

31 lines
490 B
Bash

#! /bin/sh
set -e
if test $# -eq 0; then
echo "$0: no input files." >&2
exit 1
fi
cat <<HERE
/* WARNING: Autogenerated file - see $0! */
#include "cairo-test-private.h"
void _cairo_test_runner_register_tests (void);
HERE
cat "$@" | sed '/^CAIRO_TEST/!d; s/CAIRO_TEST.*(\(.*\),.*/extern void _register_\1 (void);/'
cat <<HERE
void
_cairo_test_runner_register_tests (void)
{
HERE
cat "$@" | sed '/^CAIRO_TEST/!d; s/CAIRO_TEST.*(\(.*\),.*/ _register_\1 ();/'
echo "}"