mirror of
https://github.com/dynup/kpatch
synced 2025-05-02 07:58:00 +00:00
Add create-diff-object unittest framework
Add a simple unittest framework for create-diff-object implemented in GNU Make. It will automatically scan the kpatch-unit-objs/$(uname -m) directory for specifically named files running one of 3 tests: - creating diff object with expected success - creating diff object with expected failure - creating diff object and running a shell script on it with expected success Signed-off-by: Artem Savkov <asavkov@redhat.com>
This commit is contained in:
parent
c5e4b51982
commit
a05c644c7b
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,6 +7,7 @@
|
|||||||
*.swp
|
*.swp
|
||||||
*.d
|
*.d
|
||||||
*.so
|
*.so
|
||||||
|
*.test.out
|
||||||
.tmp_versions
|
.tmp_versions
|
||||||
Module.symvers
|
Module.symvers
|
||||||
kmod/core/.cache.mk
|
kmod/core/.cache.mk
|
||||||
|
7
test/unit/Makefile
Normal file
7
test/unit/Makefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
ARCH=$(shell uname -m)
|
||||||
|
|
||||||
|
all: Makefile.include $(ARCH)/Makefile
|
||||||
|
$(MAKE) -C $(ARCH)
|
||||||
|
|
||||||
|
clean: Makefile.include $(ARCH)/Makefile
|
||||||
|
$(MAKE) -C $(ARCH) clean
|
40
test/unit/Makefile.include
Normal file
40
test/unit/Makefile.include
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
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
|
||||||
|
MUTE:=>/dev/null 2>&1
|
||||||
|
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)))
|
||||||
|
|
||||||
|
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)
|
||||||
|
$(TENV) $(CDO) $(TNAME).$(EXT_ORIG) $(TNAME).$(EXT_PATCHED) \
|
||||||
|
$(TNAME).$(EXT_ORIG) $@ /dev/null test_$(TNAME) $(MUTE)
|
||||||
|
|
||||||
|
%.$(EXT_OUTPUT): %.$(EXT_ORIG) %.$(EXT_FAIL) $(CDO)
|
||||||
|
! $(TENV) $(CDO) $(TNAME).$(EXT_ORIG) $(TNAME).$(EXT_FAIL) \
|
||||||
|
$(TNAME).$(EXT_ORIG) $@ /dev/null test_$(TNAME) $(MUTE)
|
||||||
|
# Expecting to fail, thus create output file manually so we won't rerun the
|
||||||
|
# test without clean
|
||||||
|
@touch $@
|
Loading…
Reference in New Issue
Block a user