diff --git a/test/integration/centos-7/Makefile b/test/integration/Makefile similarity index 81% rename from test/integration/centos-7/Makefile rename to test/integration/Makefile index 3e566d3..7f0b2d2 100644 --- a/test/integration/centos-7/Makefile +++ b/test/integration/Makefile @@ -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" diff --git a/test/integration/centos-7/multiple.test b/test/integration/centos-7/multiple.test index 1a545b9..2d5ed9f 100755 --- a/test/integration/centos-7/multiple.test +++ b/test/integration/centos-7/multiple.test @@ -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 diff --git a/test/integration/fedora-25/Makefile b/test/integration/fedora-25/Makefile deleted file mode 100644 index 3e566d3..0000000 --- a/test/integration/fedora-25/Makefile +++ /dev/null @@ -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" diff --git a/test/integration/fedora-25/multiple.test b/test/integration/fedora-25/multiple.test index 1a545b9..2d5ed9f 100755 --- a/test/integration/fedora-25/multiple.test +++ b/test/integration/fedora-25/multiple.test @@ -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 diff --git a/test/integration/kpatch-test b/test/integration/kpatch-test index d0b7be7..3cd019d 100755 --- a/test/integration/kpatch-test +++ b/test/integration/kpatch-test @@ -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