Allow the use of custom kernel image for tests

If KERNEL_IMAGE is set when doing a make test, then the linux
image pointed by the variable is used rather than the source.
diff --git a/Makefile b/Makefile
index 1ab4f9d..bccca31 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,7 @@
 ##
 ROOT_DIR := $(CURDIR)
 OUT_DIR := $(ROOT_DIR)/out
+LINUX_OUT := $(OUT_DIR)/linux
 CCACHE_DIR := $(OUT_DIR)/.ccache
 TEST_SCRIPTS_DIR := $(ROOT_DIR)/build/aarch64-unit-tests
 
@@ -17,6 +18,15 @@
 TOOLCHAIN_CLANG := $(ROOT_DIR)/toolchains/$(UNNAME_S)-x86/clang/clang-r383902
 TOOLCHAIN_BINUTILS := $(ROOT_DIR)/toolchains/$(UNNAME_S)-x86/gcc/aarch64-linux-android
 
+CUSTOM_KERNEL_IMAGE=0
+
+# KERNEL_IMAGE can be set to use own custom kernel image.
+ifdef KERNEL_IMAGE
+CUSTOM_KERNEL_IMAGE=1
+else
+KERNEL_IMAGE := $(LINUX_OUT)/arch/arm64/boot/Image
+endif
+
 ##
 ## Common targets
 ##
@@ -116,7 +126,6 @@
 LINUX_SRC ?= $(ROOT_DIR)/linux
 
 LINUX_ARCH := arm64
-LINUX_OUT := $(OUT_DIR)/linux
 LINUX_PATH := $(TOOLCHAIN_CLANG)/bin:$(PATH)
 LINUX_MAKE := \
 	PATH=$(LINUX_PATH) \
@@ -136,8 +145,12 @@
 
 .PHONY: linux_image
 linux_image:
+# If using own kernel image (KERNEL_IMAGE is set in the environment), then skip.
+ifeq ($(CUSTOM_KERNEL_IMAGE), 0)
+	echo $(CUSTOM_KERNEL_IMAGE)
 	+ $(LINUX_MAKE) $(LINUX_DEFCONFIG)
 	+ $(LINUX_MAKE) Image.gz
+endif
 
 .PHONY: linux_clean
 linux_clean:
@@ -194,6 +207,6 @@
 			-j $(JOBS) \
 			-t $(KUT_OUT)/share/kvm-unit-tests/ \
 			-x $(KUT_EXCLUDE) \
-			-l $(LINUX_OUT)/arch/arm64/boot/Image \
+			-l $(KERNEL_IMAGE) \
 			-r $(KUT_ROOTFS_IMAGE) \
 			-e $(KUT_QEMU_BIN)