-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathtest.mk
68 lines (54 loc) · 2.33 KB
/
test.mk
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
################################################################################
## TESTS ##
################################################################################
# test all of the drivers that have a Makefile that match the pattern
# ./drivers/storage/%/tests/Makefile. The % is extracted as the name
# of the driver
TEST_DRIVERS := $(strip $(patsubst ./drivers/storage/%/tests/Makefile,\
%,\
$(wildcard ./drivers/storage/*/tests/Makefile)))
# a list of the driver packages to test
TEST_DRIVERS_PKGS := $(foreach d,\
$(TEST_DRIVERS),\
./drivers/storage/$d/tests)
# a list of the driver packages' test binaries
TEST_DRIVERS_BINS := $(foreach d,\
$(TEST_DRIVERS),\
./drivers/storage/$d/tests/$d.test)
# only the VFS driver is used for coverage at this level. it's possible
# to visit each driver's tests package and produce coverage files
# directly from there
TEST_DRIVERS_COVR := ./drivers/storage/vfs/tests/vfs.test.out
# a list of the framework packages to test
TEST_FRAMEWORK_PKGS := ./api/context \
./api/server/auth \
./api/types \
./api/utils/filters \
./api/utils/schema \
./api/utils
# a list of the framework packages' test binaries
TEST_FRAMEWORK_BINS := $(foreach p,\
$(TEST_FRAMEWORK_PKGS),\
$p/$(notdir $p).test)
# a list of the framework packages' test coverage output
TEST_FRAMEWORK_COVR := $(addsuffix .out,$(TEST_FRAMEWORK_BINS))
# the recipe for building the test binaries
$(TEST_DRIVERS_BINS) $(TEST_FRAMEWORK_BINS):
$(MAKE) -C $(@D) build-tests
# the recipe for executing the test binaries
$(TEST_DRIVERS_COVR) $(TEST_FRAMEWORK_COVR): %.out: %
$(MAKE) -C $(@D) test
# builds all the tests
build-tests: $(TEST_FRAMEWORK_BINS) $(TEST_DRIVERS_BINS)
# executes the framework test binaries and the vfs test binary
test: $(TEST_FRAMEWORK_COVR) $(TEST_DRIVERS_COVR)
# a target for cleaning all the test binaries and coverage files
CLEAN_TESTS := $(addprefix clean-,$(TEST_FRAMEWORK_PKGS) $(TEST_DRIVERS_PKGS))
$(CLEAN_TESTS):
$(MAKE) -C $(patsubst clean-%,%,$@) clean
clean-tests: $(CLEAN_TESTS)
# add clean-tests as a dependency of clean
clean: clean-tests
# add TEST_DRIVERS_COVR and TEST_FRAMEWORK_COVR to COVERAGE_SRCS so
# the codoecov.mk file knows the source of the coverage reports
COVERAGE_SRCS := $(TEST_DRIVERS_COVR) $(TEST_FRAMEWORK_COVR)