tflutre
tflutre

Reputation: 3546

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

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!

Upvotes: 5

Views: 1524

Answers (1)

Brett Hale
Brett Hale

Reputation: 22318

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.

Upvotes: 5

Related Questions