mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
Modify Makefile to allow insertion of mock modules
When we need to mock modules in a unit test, we need a way to mock the actual modules. This CL enables mock of given source files. For example, if we need to mock watchdog for test 'foo', we can add to test/build.mk: "core-mock-foo-watchdog.o=fake_watchdog.o", and then implement its own watchdog in fake_watchdog.c. Signed-off-by: Vic Yang <victoryang@chromium.org> BUG=chrome-os-partner:10356 TEST=Set a mock fake_watchdog.c and check the test is compiled with fake_watchdog.c instead of watchdog.c. Change-Id: I4a0afb589a49dad7c4d6faf8926438085cdc46cf Reviewed-on: https://gerrit.chromium.org/gerrit/24942 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Ready: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
This commit is contained in:
17
Makefile
17
Makefile
@@ -40,16 +40,17 @@ include util/build.mk
|
||||
|
||||
includes+=$(includes-y)
|
||||
|
||||
objs_from_dir=$(foreach obj,$(2), $(out)/$(1)/$(obj))
|
||||
objs_from_dir=$(foreach obj, $($(2)-y), \
|
||||
$(out)/$(1)/$(firstword $($(2)-mock-$(PROJECT)-$(obj)) $(obj)))
|
||||
|
||||
# Get all sources to build
|
||||
all-y=$(call objs_from_dir,core/$(CORE),$(core-y))
|
||||
all-y+=$(call objs_from_dir,chip/$(CHIP),$(chip-y))
|
||||
all-y+=$(call objs_from_dir,board/$(BOARD),$(board-y))
|
||||
all-y+=$(call objs_from_dir,private,$(private-y))
|
||||
all-y+=$(call objs_from_dir,common,$(common-y))
|
||||
all-y+=$(call objs_from_dir,test,$($(PROJECT)-y))
|
||||
all-y+=$(call objs_from_dir,vboot,$(vboot-y))
|
||||
all-y=$(call objs_from_dir,core/$(CORE),core)
|
||||
all-y+=$(call objs_from_dir,chip/$(CHIP),chip)
|
||||
all-y+=$(call objs_from_dir,board/$(BOARD),board)
|
||||
all-y+=$(call objs_from_dir,private,private)
|
||||
all-y+=$(call objs_from_dir,common,common)
|
||||
all-y+=$(call objs_from_dir,test,$(PROJECT))
|
||||
all-y+=$(call objs_from_dir,vboot,vboot)
|
||||
dirs=core/$(CORE) chip/$(CHIP) board/$(BOARD) private common test util
|
||||
|
||||
include Makefile.rules
|
||||
|
||||
Reference in New Issue
Block a user