1+ SHELL = /bin/bash
12GO ?= go
23CC ?= gcc
4+ COVERAGE_PATH ?= $(shell pwd) /.coverage
35
46all : build test phaul-test
57
911build :
1012 $(GO ) build -v ./...
1113
12- TEST_BINARIES := test/test test/piggie/piggie test/phaul/phaul
14+ TEST_PAYLOAD := test/piggie/piggie
15+ TEST_BINARIES := test/test $(TEST_PAYLOAD ) test/phaul/phaul
16+ COVERAGE_BINARIES := test/test.coverage test/phaul/phaul.coverage
1317test-bin : $(TEST_BINARIES )
1418
1519test/piggie/piggie : test/piggie/piggie.c
1620 $(CC ) $^ -o $@
1721
18- test/test : test/* .go
22+ test/test : test/main .go
1923 $(GO ) build -v -o $@ $^
2024
2125test : $(TEST_BINARIES )
@@ -27,7 +31,7 @@ test: $(TEST_BINARIES)
2731 }
2832 rm -rf image
2933
30- test/phaul/phaul : test/phaul/* .go
34+ test/phaul/phaul : test/phaul/main .go
3135 $(GO ) build -v -o $@ $^
3236
3337phaul-test : $(TEST_BINARIES )
@@ -37,9 +41,39 @@ phaul-test: $(TEST_BINARIES)
3741 pkill -9 piggie; \
3842 }
3943
44+ test/test.coverage : test/* .go
45+ $(GO ) test \
46+ -covermode=count \
47+ -coverpkg=./... \
48+ -mod=vendor \
49+ -tags coverage \
50+ -buildmode=pie -c -o $@ $^
51+
52+ test/phaul/phaul.coverage : test/phaul/* .go
53+ $(GO ) test \
54+ -covermode=count \
55+ -coverpkg=./... \
56+ -mod=vendor \
57+ -tags coverage \
58+ -buildmode=pie -c -o $@ $^
59+
60+ coverage : $(COVERAGE_BINARIES ) $(TEST_PAYLOAD )
61+ mkdir -p $(COVERAGE_PATH )
62+ mkdir -p image
63+ PID=$$(test/piggie/piggie ) && { \
64+ test/test.coverage -test.coverprofile=coverprofile.integration.$$ RANDOM -test.outputdir=${COVERAGE_PATH} COVERAGE dump $$ PID image && \
65+ test/test.coverage -test.coverprofile=coverprofile.integration.$$ RANDOM -test.outputdir=${COVERAGE_PATH} COVERAGE restore image; \
66+ pkill -9 piggie; \
67+ }
68+ rm -rf image
69+ PID=$$(test/piggie/piggie ) && { \
70+ test/phaul/phaul.coverage -test.coverprofile=coverprofile.integration.$$ RANDOM -test.outputdir=${COVERAGE_PATH} COVERAGE $$ PID; \
71+ pkill -9 piggie; \
72+ }
73+
4074clean :
41- @rm -f $(TEST_BINARIES )
42- @rm -rf image
75+ @rm -f $(TEST_BINARIES ) $( COVERAGE_BINARIES ) codecov
76+ @rm -rf image $( COVERAGE_PATH )
4377
4478rpc/rpc.proto :
4579 curl -sSL https://raw.githubusercontent.com/checkpoint-restore/criu/master/images/rpc.proto -o $@
@@ -58,4 +92,9 @@ vendor:
5892 GO111MODULE=on $(GO ) mod vendor
5993 GO111MODULE=on $(GO ) mod verify
6094
61- .PHONY : build test phaul-test test-bin clean lint vendor
95+ codecov :
96+ curl -Os https://uploader.codecov.io/latest/linux/codecov
97+ chmod +x codecov
98+ ./codecov -f ' .coverage/*'
99+
100+ .PHONY : build test phaul-test test-bin clean lint vendor coverage codecov
0 commit comments