Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use "make check" to launch bash script for tests which use the program binary

Tags:

autotools

I am using Autotools for my C++ package. My package has a single binary, called "myprog" for instance. I wrote a bash script, "test.bash", which contains a functional test. This script has 4 steps: (1) create input files, (2) generate expected output files, (3) launch "myprog" on the input files, (4) compare the outputs of "prog" with the expected outputs.

In step 3, "test.bash" needs to know the path to "myprog". If I launch "test.bash" on standalone myself, I can give the path to "myprog" as an option on the command-line. But what can I do when using make check or make distcheck?

I'm reading the manual of Autotools/Automake. I guess there is a way by using variables set by configure, but I don't see how to use them, so any solution is much welcomed!

like image 785
tflutre Avatar asked Jan 08 '13 20:01

tflutre


1 Answers

You can use the TESTS variable in Makefile.am and setup the AM_TESTS_ENVIRONMENT variable to pass options or set an environment variable for the bash scripts. It's described on this page, in the usual haphazard style of the autotools manuals.

Since myprog may be built outside the source tree, you could set a variable to $(top_builddir)/relative/path for use in the script, or use the pwd command for the directory in which the script is being executed.

like image 91
Brett Hale Avatar answered Oct 21 '22 16:10

Brett Hale