2018-03-20 19:39:36 +00:00
|
|
|
EXT_ORIG ?= ORIG.o
|
|
|
|
EXT_PATCHED ?= PATCHED.o
|
|
|
|
EXT_FAIL ?= PATCHED.FAIL.o
|
|
|
|
EXT_TEST ?= test
|
|
|
|
EXT_OUTPUT ?= OUTPUT.o
|
|
|
|
EXT_TEST_OUTPUT ?= test.out
|
|
|
|
TNAME = $(@:.$(EXT_OUTPUT)=)
|
|
|
|
|
|
|
|
ifndef VERBOSE
|
2018-04-17 22:45:41 +00:00
|
|
|
MUTE_PASS := >/dev/null
|
|
|
|
MUTE_FAIL := >/dev/null 2>&1
|
2018-03-20 19:39:36 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
SRC_PATH ?= $(realpath ../../../)
|
|
|
|
CDO ?= $(SRC_PATH)/kpatch-build/create-diff-object
|
|
|
|
|
|
|
|
TENV = PARA_STRUCT_SIZE=16 EX_STRUCT_SIZE=12 BUG_STRUCT_SIZE=12 ALT_STRUCT_SIZE=13
|
|
|
|
|
|
|
|
TARGETS = $(patsubst %.$(EXT_ORIG),%.$(EXT_OUTPUT),$(wildcard *.$(EXT_ORIG)))
|
|
|
|
TEST_TARGETS = $(patsubst %.$(EXT_TEST),%.$(EXT_TEST_OUTPUT),$(wildcard *.$(EXT_TEST)))
|
|
|
|
|
2018-04-13 08:55:58 +00:00
|
|
|
define check_lfs =
|
|
|
|
$(if $(shell head -1 $(1) | grep git-lfs.github.com),
|
|
|
|
$(error $(1) is not fetched. Unittests require https://git-lfs.github.com/),
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2018-04-13 08:36:57 +00:00
|
|
|
define check_stripped =
|
|
|
|
$(if $(shell readelf --debug-dump $(1)),
|
|
|
|
$(error $(1) is not properly stripped, use 'strip --strip-debug --keep-file-symbols $(1)' to fix this),
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2018-04-13 08:55:58 +00:00
|
|
|
define check_all =
|
|
|
|
$(call check_lfs,$(1))
|
|
|
|
$(call check_stripped,$(1))
|
|
|
|
endef
|
|
|
|
|
2018-03-20 19:39:36 +00:00
|
|
|
all: $(TARGETS) $(TEST_TARGETS)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(TARGETS) $(TEST_TARGETS)
|
|
|
|
|
|
|
|
%.$(EXT_TEST_OUTPUT): %.$(EXT_OUTPUT) %.$(EXT_TEST)
|
|
|
|
bash $(@:.$(EXT_TEST_OUTPUT)=.$(EXT_TEST)) $<
|
|
|
|
# Don't rely on script creating this
|
|
|
|
@touch $@
|
|
|
|
|
|
|
|
%.$(EXT_OUTPUT): %.$(EXT_ORIG) %.$(EXT_PATCHED) $(CDO)
|
2018-04-13 08:55:58 +00:00
|
|
|
$(call check_all,$(TNAME).$(EXT_ORIG))
|
|
|
|
$(call check_all,$(TNAME).$(EXT_PATCHED))
|
2018-03-20 19:39:36 +00:00
|
|
|
$(TENV) $(CDO) $(TNAME).$(EXT_ORIG) $(TNAME).$(EXT_PATCHED) \
|
2018-04-17 22:45:41 +00:00
|
|
|
$(TNAME).$(EXT_ORIG) $@ /dev/null test_$(TNAME) $(MUTE_PASS)
|
2018-03-20 19:39:36 +00:00
|
|
|
|
|
|
|
%.$(EXT_OUTPUT): %.$(EXT_ORIG) %.$(EXT_FAIL) $(CDO)
|
2018-04-13 08:55:58 +00:00
|
|
|
$(call check_all,$(TNAME).$(EXT_ORIG))
|
|
|
|
$(call check_all,$(TNAME).$(EXT_FAIL))
|
2018-03-20 19:39:36 +00:00
|
|
|
! $(TENV) $(CDO) $(TNAME).$(EXT_ORIG) $(TNAME).$(EXT_FAIL) \
|
2018-04-17 22:45:41 +00:00
|
|
|
$(TNAME).$(EXT_ORIG) $@ /dev/null test_$(TNAME) $(MUTE_FAIL)
|
2018-03-20 19:39:36 +00:00
|
|
|
# Expecting to fail, thus create output file manually so we won't rerun the
|
|
|
|
# test without clean
|
|
|
|
@touch $@
|