diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2019-12-11 11:34:42 -0800 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2019-12-16 15:26:29 -0500 |
commit | b5a6bf5c3ca11452580dd86f9c756e91c246cee1 (patch) | |
tree | 24d0ebe891adccab385016fd014494fc07f02935 /tests | |
parent | b2c8c2877e001a00579e2fa4dfd8be47f4169ba2 (diff) |
tests: Handle srcdir that is relative to builddir
If $srcdir is a relative path, for example starts with "../", then the
temp files in this script will escape their temp dir. To prevent this,
use $(mktemp -d)/$abs_top_builddir as the temp dir, so that the relative
path has somewhere to go.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rwxr-xr-x | tests/wrapper-compiler-errors | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 00c0b4f..75f069f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,6 +3,7 @@ # with Tartan (and -Werror). TEST_EXTENSIONS = .c +AM_TESTS_ENVIRONMENT = export abs_top_builddir=$(abs_top_builddir); C_LOG_COMPILER = $(top_srcdir)/tests/wrapper-compiler-errors c_tests = \ diff --git a/tests/wrapper-compiler-errors b/tests/wrapper-compiler-errors index 8e30771..3dc2a1a 100755 --- a/tests/wrapper-compiler-errors +++ b/tests/wrapper-compiler-errors @@ -21,7 +21,7 @@ # asserts there’s no error. input_filename=$1 -temp_dir=`mktemp -d` +temp_dir=`mktemp -d`/${abs_top_builddir} tests_dir=`dirname $0` tartan=${tests_dir}/../scripts/tartan tartan_plugin=${tests_dir}/../clang-plugin/.libs/libtartan.so @@ -46,6 +46,7 @@ template_name=`head -n 1 "${input_filename}" | \ echo "Using template ${template_name}." # Split the input file up into sections, delimiting on ‘/*’ on a line by itself. +mkdir -p ${temp_dir}/${srcdir} tail -n +3 "${input_filename}" > "${temp_dir}/${input_filename}.tail" csplit --keep-files --elide-empty-files --silent \ --prefix="${temp_dir}/${input_filename}_" \ |