Skip to Main Content
Autotools
book

Autotools

by John Calcote
July 2010
Intermediate to advanced content levelIntermediate to advanced
360 pages
11h 12m
English
No Starch Press
Content preview from Autotools

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.shTESTS = ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

GNU Autoconf, Automake, and Libtool

GNU Autoconf, Automake, and Libtool

Gary V. Vaughan, Ben Elliston, Tom Tromey, Ian Lance Taylor
Red Hat® Linux® 7 Unleashed

Red Hat® Linux® 7 Unleashed

Bill Ball, David Pitts

Publisher Resources

ISBN: 9781593272067Errata