File: Makefile

package info (click to toggle)
golang-github-checkpoint-restore-go-criu 7.2.0%2Bds1-4
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 1,796 kB
  • sloc: makefile: 231; ansic: 195; python: 137; sh: 110
file content (96 lines) | stat: -rw-r--r-- 3,237 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
SHELL = /bin/bash
GO ?= go
CC ?= gcc
COVERAGE_PATH ?= $(shell pwd)/.coverage
CRIU_FEATURE_MEM_TRACK = $(shell if criu check --feature mem_dirty_track > /dev/null; then echo 1; else echo 0; fi)
CRIU_FEATURE_LAZY_PAGES = $(shell if criu check --feature uffd-noncoop > /dev/null; then echo 1; else echo 0; fi)
CRIU_FEATURE_PIDFD_STORE = $(shell if criu check --feature pidfd_store > /dev/null; then echo 1; else echo 0; fi)

export CRIU_FEATURE_MEM_TRACK CRIU_FEATURE_LAZY_PAGES CRIU_FEATURE_PIDFD_STORE

TEST_PAYLOAD := piggie/piggie
TEST_BINARIES := test $(TEST_PAYLOAD) phaul/phaul
COVERAGE_BINARIES := test.coverage phaul/phaul.coverage crit/crit-test.coverage

all: $(TEST_BINARIES) phaul-test
	mkdir -p image
	PID=$$(piggie/piggie) && \
	trap 'pkill -9 piggie' INT EXIT TERM && \
	./test dump $$PID image && \
	./test restore image
	rm -rf image

piggie/piggie: piggie/piggie.c
	$(CC) $^ -o $@

test: main.go
	$(GO) build -v -o $@ $^

phaul/phaul: phaul/main.go
	$(GO) build -v -o $@ $^

phaul-test: $(TEST_BINARIES)
	rm -rf image
	PID=$$(piggie/piggie) && \
	trap 'pkill -9 piggie' INT EXIT TERM && \
	phaul/phaul $$PID

crit-test:
	$(MAKE) -C crit

test.coverage: *.go
	$(GO) build \
		-cover \
		-o $@ main.go

phaul/phaul.coverage: phaul/*.go
	$(GO) build \
		-cover \
		-o $@ phaul/main.go

crit/crit-test.coverage: crit/*.go
	# Re-build the crit binary, so that test coverage
	# works even if we run `make test` before that.
	$(MAKE) -C ../crit clean
	$(MAKE) -C ../crit bin/crit GOFLAGS="-cover"
	$(MAKE) -C crit/ test-imgs
	$(GO) build \
		-cover \
		-o $@ crit/main.go

coverage: $(COVERAGE_BINARIES) $(TEST_PAYLOAD)
	mkdir -p $(COVERAGE_PATH)
	mkdir -p image
	PID=$$(piggie/piggie) && \
	trap 'pkill -9 piggie' INT EXIT TERM && \
	GOCOVERDIR=${COVERAGE_PATH} ./test.coverage dump $$PID image && \
	GOCOVERDIR=${COVERAGE_PATH} ./test.coverage restore image
	rm -rf image
	PID=$$(piggie/piggie) && \
	trap 'pkill -9 piggie' INT EXIT TERM && \
	GOCOVERDIR=${COVERAGE_PATH} phaul/phaul.coverage $$PID
	cd crit/ && GOCOVERDIR=${COVERAGE_PATH} ./crit-test.coverage
	$(MAKE) -C ../crit/ unit-test GOFLAGS="-coverprofile=${COVERAGE_PATH}/coverprofile-crit-unit-test"
	$(MAKE) -C crit/ e2e-test GOCOVERDIR=${COVERAGE_PATH}
	$(MAKE) -C crit/ clean
	# Generate coverage for ../scripts/magic-gen
	$(MAKE) -C ../scripts/magic-gen test GOFLAGS="-coverprofile=${COVERAGE_PATH}/coverprofile-scripts-unit-test" GOCOVERDIR="${COVERAGE_PATH}"
	# Print coverage from this run
	$(GO) tool covdata percent -i=${COVERAGE_PATH}
	$(GO) tool covdata textfmt -i=${COVERAGE_PATH} -o ${COVERAGE_PATH}/coverage.out
	# The coverage from 'go test' is stored in coverprofile-*,
	# but we upload only 'coverage.out' with codecov. Here we
	# combine the coverage results to show up in GitHub.
	cat .coverage/coverprofile* | \
		grep -v mode: | sort -r | awk '{if($$1 != last) {print $$0;last=$$1}}' >> ${COVERAGE_PATH}/coverage.out
	# We do not want to upload coverage for autogenerated files (*.pb.go)
	sed -i '/\.pb\.go/d' ${COVERAGE_PATH}/coverage.out

clean:
	@rm -f $(TEST_BINARIES) $(COVERAGE_BINARIES)
	@rm -rf image $(COVERAGE_PATH)
	@make -C crit/ clean
	@make -C loop/ clean
	@make -C mmapper/ clean

.PHONY: all clean coverage crit-test phaul-test