Skip to content

Commit

Permalink
Merge pull request #213 from jpoimboe/test-combined
Browse files Browse the repository at this point in the history
test: add much quicker combined test option
  • Loading branch information
jpoimboe committed May 27, 2014
2 parents 82f0951 + d7f209f commit 6aee215
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 22 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ kpatch-build/lookup
kpatch-build/create-diff-object
man/kpatch.1.gz
man/kpatch-build.1.gz
test/integration/test.log
2 changes: 2 additions & 0 deletions test/integration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test.log
COMBINED.patch
14 changes: 7 additions & 7 deletions test/integration/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
all:
all: clean
./kpatch-test

# Just reuse any already-built modules for the tests. This isn't a
# reliable way to run tests if the code has changed, but it comes in
# handy when creating new tests.
quick:
./kpatch-test -s
quick: clean
./kpatch-test --quick

cached:
./kpatch-test --cached

clean:
rm -f *.ko *.log
rm -f *.ko *.log COMBINED.patch
106 changes: 92 additions & 14 deletions test/integration/kpatch-test
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ rm -f $LOG
usage() {
echo "usage: $0 [options]" >&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"

Expand All @@ -64,9 +65,12 @@ while [[ $# -gt 0 ]]; do
usage
exit 0
;;
-s|--skipbuild)
-c|--cached)
SKIPBUILD=1
;;
-q|--quick)
QUICK=1
;;
esac
shift
done
Expand Down Expand Up @@ -97,6 +101,8 @@ build_module() {
prefix=${file%%.patch}
module=kpatch-$prefix.ko

[[ $prefix = COMBINED ]] && return

if [[ $prefix = *-FAIL ]]; then
shouldfail=1
else
Expand Down Expand Up @@ -125,6 +131,7 @@ run_load_test() {
module=kpatch-$prefix.ko
testprog=$prefix-LOADED.test

[[ $prefix = COMBINED ]] && return
[[ $prefix = *-FAIL ]] && return

if [[ ! -e $module ]]; then
Expand Down Expand Up @@ -183,23 +190,94 @@ run_custom_test() {
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"

for file in *.patch; do
build_module $file
done
if [[ $QUICK != 1 ]]; then
for file in *.patch; do
build_module $file
done
fi

build_combined_module

unload_all

for file in *.patch; do
run_load_test $file
lastmod=$file
done
if [[ $QUICK != 1 ]]; then
for file in *.patch; do
run_load_test $file
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

Expand Down

0 comments on commit 6aee215

Please sign in to comment.