[email protected] | 011eef3 | 2011-09-23 11:12:19 | [diff] [blame^] | 1 | # |
| 2 | # Makefile for the LCOV example program. |
| 3 | # |
| 4 | # Make targets: |
| 5 | # - example: compile the example program |
| 6 | # - output: run test cases on example program and create HTML output |
| 7 | # - clean: clean up directory |
| 8 | # |
| 9 | |
| 10 | CC := gcc |
| 11 | CFLAGS := -Wall -I. -fprofile-arcs -ftest-coverage |
| 12 | |
| 13 | LCOV := ../bin/lcov |
| 14 | GENHTML := ../bin/genhtml |
| 15 | GENDESC := ../bin/gendesc |
| 16 | GENPNG := ../bin/genpng |
| 17 | |
| 18 | # Depending on the presence of the GD.pm perl module, we can use the |
| 19 | # special option '--frames' for genhtml |
| 20 | USE_GENPNG := $(shell $(GENPNG) --help >/dev/null 2>/dev/null; echo $$?) |
| 21 | |
| 22 | ifeq ($(USE_GENPNG),0) |
| 23 | FRAMES := --frames |
| 24 | else |
| 25 | FRAMES := |
| 26 | endif |
| 27 | |
| 28 | .PHONY: clean output test_noargs test_2_to_2000 test_overflow |
| 29 | |
| 30 | all: output |
| 31 | |
| 32 | example: example.o iterate.o gauss.o |
| 33 | $(CC) example.o iterate.o gauss.o -o example -lgcov |
| 34 | |
| 35 | example.o: example.c iterate.h gauss.h |
| 36 | $(CC) $(CFLAGS) -c example.c -o example.o |
| 37 | |
| 38 | iterate.o: methods/iterate.c iterate.h |
| 39 | $(CC) $(CFLAGS) -c methods/iterate.c -o iterate.o |
| 40 | |
| 41 | gauss.o: methods/gauss.c gauss.h |
| 42 | $(CC) $(CFLAGS) -c methods/gauss.c -o gauss.o |
| 43 | |
| 44 | output: example descriptions test_noargs test_2_to_2000 test_overflow |
| 45 | @echo |
| 46 | @echo '*' |
| 47 | @echo '* Generating HTML output' |
| 48 | @echo '*' |
| 49 | @echo |
| 50 | $(GENHTML) trace_noargs.info trace_args.info trace_overflow.info \ |
| 51 | --output-directory output --title "Basic example" \ |
| 52 | --show-details --description-file descriptions $(FRAMES) \ |
| 53 | --legend |
| 54 | @echo |
| 55 | @echo '*' |
| 56 | @echo '* See '`pwd`/output/index.html |
| 57 | @echo '*' |
| 58 | @echo |
| 59 | |
| 60 | descriptions: descriptions.txt |
| 61 | $(GENDESC) descriptions.txt -o descriptions |
| 62 | |
| 63 | all_tests: example test_noargs test_2_to_2000 test_overflow |
| 64 | |
| 65 | test_noargs: |
| 66 | @echo |
| 67 | @echo '*' |
| 68 | @echo '* Test case 1: running ./example without parameters' |
| 69 | @echo '*' |
| 70 | @echo |
| 71 | $(LCOV) --zerocounters --directory . |
| 72 | ./example |
| 73 | $(LCOV) --capture --directory . --output-file trace_noargs.info --test-name test_noargs |
| 74 | |
| 75 | test_2_to_2000: |
| 76 | @echo |
| 77 | @echo '*' |
| 78 | @echo '* Test case 2: running ./example 2 2000' |
| 79 | @echo '*' |
| 80 | @echo |
| 81 | $(LCOV) --zerocounters --directory . |
| 82 | ./example 2 2000 |
| 83 | $(LCOV) --capture --directory . --output-file trace_args.info --test-name test_2_to_2000 |
| 84 | |
| 85 | test_overflow: |
| 86 | @echo |
| 87 | @echo '*' |
| 88 | @echo '* Test case 3: running ./example 0 100000 (causes an overflow)' |
| 89 | @echo '*' |
| 90 | @echo |
| 91 | $(LCOV) --zerocounters --directory . |
| 92 | ./example 0 100000 || true |
| 93 | $(LCOV) --capture --directory . --output-file trace_overflow.info --test-name "test_overflow" |
| 94 | |
| 95 | clean: |
| 96 | rm -rf *.o *.bb *.bbg *.da *.gcno *.gcda *.info output example \ |
| 97 | descriptions |
| 98 | |