July 2010
Intermediate to advanced
360 pages
11h 12m
English
In Chapter 2 we added code to src/Makefile that executes the jupiter program and checks for the proper output string when the user makes the check target. I've duplicated the check target code in Example 5-11.
Example 5-11. The check target
...
check: all
./jupiter | grep "Hello from .*jupiter!"
@echo "*** ALL TESTS PASSED ***"
...Fortunately, Automake has solid support for unit tests. To add our simple grep test back into the new Automake-generated build system, we can add a few lines to the bottom of src/Makefile.am, as shown in Example 5-12.
Example 5-12. src/Makefile.am: Additional code required to support the check target
bin_PROGRAMS = jupiter jupiter_SOURCES = main.c ❶check_SCRIPTS = greptest.sh❷TESTS = ...