mirror of https://github.com/dynup/kpatch
testing: use common Makefile
Move the integration tests Makefile up a directory level so that it can be shared. Update the kpatch-test script to accept a patch-directory argument and the multiple.test cases to handle this new arrangement.
This commit is contained in:
parent
b6692c14d7
commit
5db4e232ee
|
@ -1,3 +1,7 @@
|
|||
include /etc/os-release
|
||||
|
||||
PATCH_DIR?=${ID}-${VERSION_ID}
|
||||
|
||||
all:
|
||||
$(error please specify local or remote)
|
||||
|
||||
|
@ -6,13 +10,13 @@ local: slow
|
|||
remote: remote_slow
|
||||
|
||||
slow: clean
|
||||
../kpatch-test
|
||||
./kpatch-test -d $(PATCH_DIR)
|
||||
|
||||
quick: clean
|
||||
../kpatch-test --quick
|
||||
./kpatch-test -d $(PATCH_DIR) --quick
|
||||
|
||||
cached:
|
||||
../kpatch-test --cached
|
||||
./kpatch-test -d $(PATCH_DIR) --cached
|
||||
|
||||
clean:
|
||||
rm -f *.ko *.log COMBINED.patch
|
||||
|
@ -36,4 +40,4 @@ remote_sync: remote_setup
|
|||
ssh $(SSH_USER)@$(SSH_HOST) "cd kpatch-test/kpatch && make"
|
||||
|
||||
remote_slow: remote_sync
|
||||
ssh $(SSH_USER)@$(SSH_HOST) "cd kpatch-test/kpatch/test/integration/f22 && make slow"
|
||||
ssh $(SSH_USER)@$(SSH_HOST) "cd kpatch-test/kpatch/test/integration && make slow"
|
|
@ -21,7 +21,7 @@ declare -a modules=(kpatch-cmdline-string.ko kpatch-meminfo-string.ko)
|
|||
|
||||
for mod in "${modules[@]}"; do
|
||||
testprog=$(ko_to_test $mod)
|
||||
./$testprog && die "./$testprog succeeded before loading any modules"
|
||||
$SCRIPTDIR/$testprog && die "$SCRIPTDIR/$testprog succeeded before loading any modules"
|
||||
done
|
||||
|
||||
for mod in "${modules[@]}"; do
|
||||
|
@ -30,7 +30,7 @@ done
|
|||
|
||||
for mod in "${modules[@]}"; do
|
||||
testprog=$(ko_to_test $mod)
|
||||
./$testprog || die "./$testprog failed after loading modules"
|
||||
$SCRIPTDIR/$testprog || die "$SCRIPTDIR/$testprog failed after loading modules"
|
||||
done
|
||||
|
||||
for mod in "${modules[@]}"; do
|
||||
|
@ -39,7 +39,7 @@ done
|
|||
|
||||
for mod in "${modules[@]}"; do
|
||||
testprog=$(ko_to_test $mod)
|
||||
./$testprog && die "./$testprog succeeded after unloading modules"
|
||||
$SCRIPTDIR/$testprog && die "$SCRIPTDIR/$testprog succeeded after unloading modules"
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
all:
|
||||
$(error please specify local or remote)
|
||||
|
||||
local: slow
|
||||
|
||||
remote: remote_slow
|
||||
|
||||
slow: clean
|
||||
../kpatch-test
|
||||
|
||||
quick: clean
|
||||
../kpatch-test --quick
|
||||
|
||||
cached:
|
||||
../kpatch-test --cached
|
||||
|
||||
clean:
|
||||
rm -f *.ko *.log COMBINED.patch
|
||||
|
||||
check_host:
|
||||
ifndef SSH_HOST
|
||||
$(error SSH_HOST is undefined)
|
||||
endif
|
||||
|
||||
SSH_USER ?= root
|
||||
|
||||
remote_setup: check_host
|
||||
ssh $(SSH_USER)@$(SSH_HOST) exit
|
||||
ssh $(SSH_USER)@$(SSH_HOST) "ls kpatch-setup &> /dev/null" || \
|
||||
(scp remote-setup $(SSH_USER)@$(SSH_HOST):kpatch-setup && \
|
||||
ssh $(SSH_USER)@$(SSH_HOST) "./kpatch-setup")
|
||||
|
||||
remote_sync: remote_setup
|
||||
ssh $(SSH_USER)@$(SSH_HOST) "rm -rf kpatch-test"
|
||||
rsync -Cavz --include=core $(shell readlink -f ../../..) $(SSH_USER)@$(SSH_HOST):kpatch-test
|
||||
ssh $(SSH_USER)@$(SSH_HOST) "cd kpatch-test/kpatch && make"
|
||||
|
||||
remote_slow: remote_sync
|
||||
ssh $(SSH_USER)@$(SSH_HOST) "cd kpatch-test/kpatch/test/integration/f22 && make slow"
|
|
@ -21,7 +21,7 @@ declare -a modules=(kpatch-cmdline-string.ko kpatch-meminfo-string.ko)
|
|||
|
||||
for mod in "${modules[@]}"; do
|
||||
testprog=$(ko_to_test $mod)
|
||||
./$testprog && die "./$testprog succeeded before loading any modules"
|
||||
$SCRIPTDIR/$testprog && die "$SCRIPTDIR/$testprog succeeded before loading any modules"
|
||||
done
|
||||
|
||||
for mod in "${modules[@]}"; do
|
||||
|
@ -30,7 +30,7 @@ done
|
|||
|
||||
for mod in "${modules[@]}"; do
|
||||
testprog=$(ko_to_test $mod)
|
||||
./$testprog || die "./$testprog failed after loading modules"
|
||||
$SCRIPTDIR/$testprog || die "$SCRIPTDIR/$testprog failed after loading modules"
|
||||
done
|
||||
|
||||
for mod in "${modules[@]}"; do
|
||||
|
@ -39,7 +39,7 @@ done
|
|||
|
||||
for mod in "${modules[@]}"; do
|
||||
testprog=$(ko_to_test $mod)
|
||||
./$testprog && die "./$testprog succeeded after unloading modules"
|
||||
$SCRIPTDIR/$testprog && die "$SCRIPTDIR/$testprog succeeded after unloading modules"
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))"
|
||||
ROOTDIR="$(readlink -f $SCRIPTDIR/../..)"
|
||||
PATCHDIR=$PWD
|
||||
# TODO: option to use system-installed binaries instead
|
||||
KPATCH="sudo $ROOTDIR/kpatch/kpatch"
|
||||
RMMOD="sudo rmmod"
|
||||
|
@ -55,10 +56,11 @@ usage() {
|
|||
echo "usage: $0 [options]" >&2
|
||||
echo " -h, --help Show this help message" >&2
|
||||
echo " -c, --cached Don't rebuild patch modules" >&2
|
||||
echo " -d, --directory Patch directory" >&2
|
||||
echo " -q, --quick Just combine all patches into one module for testing" >&2
|
||||
}
|
||||
|
||||
options=$(getopt -o hcq -l "help,cached,quick" -- "$@") || exit 1
|
||||
options=$(getopt -o hcd:q -l "help,cached,directory,quick" -- "$@") || exit 1
|
||||
|
||||
eval set -- "$options"
|
||||
|
||||
|
@ -71,6 +73,10 @@ while [[ $# -gt 0 ]]; do
|
|||
-c|--cached)
|
||||
SKIPBUILD=1
|
||||
;;
|
||||
-d|--directory)
|
||||
PATCHDIR="$2"
|
||||
shift
|
||||
;;
|
||||
-q|--quick)
|
||||
QUICK=1
|
||||
;;
|
||||
|
@ -101,7 +107,7 @@ unload_all() {
|
|||
|
||||
build_module() {
|
||||
file=$1
|
||||
prefix=${file%%.patch}
|
||||
prefix=$(basename ${file%%.patch})
|
||||
module=kpatch-$prefix.ko
|
||||
|
||||
[[ $prefix = COMBINED ]] && return
|
||||
|
@ -130,9 +136,9 @@ build_module() {
|
|||
|
||||
run_load_test() {
|
||||
file=$1
|
||||
prefix=${file%%.patch}
|
||||
prefix=$(basename ${file%%.patch})
|
||||
module=kpatch-$prefix.ko
|
||||
testprog=$prefix-LOADED.test
|
||||
testprog="$(dirname $1)/$prefix-LOADED.test"
|
||||
|
||||
[[ $prefix = COMBINED ]] && return
|
||||
[[ $prefix =~ -FAIL ]] && return
|
||||
|
@ -149,7 +155,7 @@ run_load_test() {
|
|||
fi
|
||||
|
||||
|
||||
if [[ -e $testprog ]] && ./$testprog >> $LOG 2>&1; then
|
||||
if [[ -e $testprog ]] && $testprog >> $LOG 2>&1; then
|
||||
error "$prefix: $testprog succeeded before kpatch load"
|
||||
return
|
||||
fi
|
||||
|
@ -159,7 +165,7 @@ run_load_test() {
|
|||
return
|
||||
fi
|
||||
|
||||
if [[ -e $testprog ]] && ! ./$testprog >> $LOG 2>&1; then
|
||||
if [[ -e $testprog ]] && ! $testprog >> $LOG 2>&1; then
|
||||
error "$prefix: $testprog failed after kpatch load"
|
||||
fi
|
||||
|
||||
|
@ -168,7 +174,7 @@ run_load_test() {
|
|||
return
|
||||
fi
|
||||
|
||||
if [[ -e $testprog ]] && ./$testprog >> $LOG 2>&1; then
|
||||
if [[ -e $testprog ]] && $testprog >> $LOG 2>&1; then
|
||||
error "$prefix: $testprog succeeded after kpatch unload"
|
||||
return
|
||||
fi
|
||||
|
@ -176,13 +182,13 @@ run_load_test() {
|
|||
|
||||
run_custom_test() {
|
||||
testprog=$1
|
||||
prefix=${file%%.test}
|
||||
prefix=$(basename ${file%%.test}})
|
||||
|
||||
[[ $testprog = *-LOADED.test ]] && return
|
||||
|
||||
log "custom test: $prefix"
|
||||
|
||||
if ! ./$testprog >> $LOG 2>&1; then
|
||||
if ! $testprog >> $LOG 2>&1; then
|
||||
error "$prefix: test failed"
|
||||
fi
|
||||
}
|
||||
|
@ -202,7 +208,7 @@ build_combined_module() {
|
|||
|
||||
rm -f COMBINED.patch TMP.patch
|
||||
first=1
|
||||
for file in *.patch; do
|
||||
for file in $PATCHDIR/*.patch; do
|
||||
prefix=${file%%.patch}
|
||||
|
||||
[[ $prefix =~ -FAIL ]] && continue
|
||||
|
@ -237,9 +243,9 @@ run_combined_test() {
|
|||
|
||||
unload_all
|
||||
|
||||
for testprog in *.test; do
|
||||
for testprog in $PATCHDIR/*.test; do
|
||||
[[ $testprog != *-LOADED.test ]] && continue
|
||||
if ./$testprog >> $LOG 2>&1; then
|
||||
if $testprog >> $LOG 2>&1; then
|
||||
error "combined: $testprog succeeded before kpatch load"
|
||||
return
|
||||
fi
|
||||
|
@ -250,9 +256,9 @@ run_combined_test() {
|
|||
return
|
||||
fi
|
||||
|
||||
for testprog in *.test; do
|
||||
for testprog in $PATCHDIR/*.test; do
|
||||
[[ $testprog != *-LOADED.test ]] && continue
|
||||
if ! ./$testprog >> $LOG 2>&1; then
|
||||
if ! $testprog >> $LOG 2>&1; then
|
||||
error "combined: $testprog failed after kpatch load"
|
||||
fi
|
||||
done
|
||||
|
@ -262,9 +268,9 @@ run_combined_test() {
|
|||
return
|
||||
fi
|
||||
|
||||
for testprog in *.test; do
|
||||
for testprog in $PATCHDIR/*.test; do
|
||||
[[ $testprog != *-LOADED.test ]] && continue
|
||||
if ./$testprog >> $LOG 2>&1; then
|
||||
if $testprog >> $LOG 2>&1; then
|
||||
error "combined: $testprog succeeded after kpatch unload"
|
||||
return
|
||||
fi
|
||||
|
@ -276,7 +282,7 @@ echo "clearing printk buffer"
|
|||
sudo dmesg -C
|
||||
|
||||
if [[ $QUICK != 1 ]]; then
|
||||
for file in *.patch; do
|
||||
for file in $PATCHDIR/*.patch; do
|
||||
build_module $file
|
||||
done
|
||||
fi
|
||||
|
@ -286,7 +292,7 @@ build_combined_module
|
|||
unload_all
|
||||
|
||||
if [[ $QUICK != 1 ]]; then
|
||||
for file in *.patch; do
|
||||
for file in $PATCHDIR/*.patch; do
|
||||
run_load_test $file
|
||||
done
|
||||
fi
|
||||
|
@ -294,7 +300,7 @@ fi
|
|||
run_combined_test
|
||||
|
||||
if [[ $QUICK != 1 ]]; then
|
||||
for file in *.test; do
|
||||
for file in $PATCHDIR/*.test; do
|
||||
unload_all
|
||||
run_custom_test $file
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue