test: add much quicker combined test option

Combine all the patch modules into a single kpatch-COMBINED.ko for a
much quicker test which still gives 95% or so of the coverage compared
to the full test suite.  Use "make quick" for use this new option.
This commit is contained in:
Josh Poimboeuf 2014-05-27 08:34:21 -05:00
parent ae24942c9e
commit d7f209f838
4 changed files with 101 additions and 22 deletions

1
.gitignore vendored
View File

@ -11,4 +11,3 @@ kpatch-build/lookup
kpatch-build/create-diff-object kpatch-build/create-diff-object
man/kpatch.1.gz man/kpatch.1.gz
man/kpatch-build.1.gz man/kpatch-build.1.gz
test/integration/test.log

2
test/integration/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
test.log
COMBINED.patch

View File

@ -1,11 +1,11 @@
all: all: clean
./kpatch-test ./kpatch-test
# Just reuse any already-built modules for the tests. This isn't a quick: clean
# reliable way to run tests if the code has changed, but it comes in ./kpatch-test --quick
# handy when creating new tests.
quick: cached:
./kpatch-test -s ./kpatch-test --cached
clean: clean:
rm -f *.ko *.log rm -f *.ko *.log COMBINED.patch

View File

@ -51,10 +51,11 @@ rm -f $LOG
usage() { usage() {
echo "usage: $0 [options]" >&2 echo "usage: $0 [options]" >&2
echo " -h, --help Show this help message" >&2 echo " -h, --help Show this help message" >&2
echo " -s, --skipbuild Don't rebuild patch modules" >&2 echo " -c, --cached Don't rebuild patch modules" >&2
echo " -q, --quick Just combine all patches into one module for testing" >&2
} }
options=$(getopt -o hs -l "help,skipbuild" -- "$@") || exit 1 options=$(getopt -o hcq -l "help,cached,quick" -- "$@") || exit 1
eval set -- "$options" eval set -- "$options"
@ -64,9 +65,12 @@ while [[ $# -gt 0 ]]; do
usage usage
exit 0 exit 0
;; ;;
-s|--skipbuild) -c|--cached)
SKIPBUILD=1 SKIPBUILD=1
;; ;;
-q|--quick)
QUICK=1
;;
esac esac
shift shift
done done
@ -97,6 +101,8 @@ build_module() {
prefix=${file%%.patch} prefix=${file%%.patch}
module=kpatch-$prefix.ko module=kpatch-$prefix.ko
[[ $prefix = COMBINED ]] && return
if [[ $prefix = *-FAIL ]]; then if [[ $prefix = *-FAIL ]]; then
shouldfail=1 shouldfail=1
else else
@ -125,6 +131,7 @@ run_load_test() {
module=kpatch-$prefix.ko module=kpatch-$prefix.ko
testprog=$prefix-LOADED.test testprog=$prefix-LOADED.test
[[ $prefix = COMBINED ]] && return
[[ $prefix = *-FAIL ]] && return [[ $prefix = *-FAIL ]] && return
if [[ ! -e $module ]]; then if [[ ! -e $module ]]; then
@ -183,23 +190,94 @@ run_custom_test() {
fi fi
} }
build_combined_module() {
if [[ $SKIPBUILD -eq 1 ]] && [[ -e kpatch-COMBINED.ko ]]; then
log "skipping build: combined"
return
fi
if ! which combinediff > /dev/null; then
log "patchutils not installed, skipping combined module build"
error "PLEASE INSTALL PATCHUTILS"
return
fi
rm -f COMBINED.patch
first=1
for file in *.patch; do
prefix=${file%%.patch}
[[ $prefix = *-FAIL ]] && continue
[[ $prefix = meminfo-cmdline ]] && continue # HACK
log "combine: $prefix"
if [[ $first -eq 1 ]]; then
cp -f $file COMBINED.patch
first=0
continue
fi
combinediff COMBINED.patch $file > TMP.patch
mv -f TMP.patch COMBINED.patch
done
log "build: combined module"
if ! $KPATCHBUILD COMBINED.patch >> $LOG 2>&1; then
error "combined build failed"
fi
}
run_combined_test() {
if [[ ! -e kpatch-COMBINED.ko ]]; then
log "can't find kpatch-COMBINED.ko, skipping"
return
fi
log "load test: combined module"
if ! $KPATCH replace kpatch-COMBINED.ko >> $LOG 2>&1; then
error "combined: kpatch replace failed"
return
fi
for testprog in *.test; do
[[ $testprog != *-LOADED.test ]] && continue
if ! ./$testprog >> $LOG 2>&1; then
error "combined: $testprog failed"
fi
done
}
cd "$SCRIPTDIR" cd "$SCRIPTDIR"
for file in *.patch; do if [[ $QUICK != 1 ]]; then
build_module $file for file in *.patch; do
done build_module $file
done
fi
build_combined_module
unload_all unload_all
for file in *.patch; do if [[ $QUICK != 1 ]]; then
run_load_test $file for file in *.patch; do
lastmod=$file run_load_test $file
done done
fi
run_combined_test
if [[ $QUICK != 1 ]]; then
for file in *.test; do
unload_all
run_custom_test $file
done
fi
for file in *.test; do
unload_all
run_custom_test $file
done
unload_all unload_all