Unit Tests: Supporting make check
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 = ...
Get Autotools now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.