2014-05-05 22:08:08 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))"
|
2015-10-29 22:21:54 +00:00
|
|
|
ROOTDIR="$(readlink -f $SCRIPTDIR/../../..)"
|
2014-05-05 22:08:08 +00:00
|
|
|
KPATCH="sudo $ROOTDIR/kpatch/kpatch"
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
|
|
|
|
die() {
|
|
|
|
echo "ERROR: $@" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
ko_to_test() {
|
|
|
|
tmp=${1%.ko}-LOADED.test
|
2018-12-10 13:50:01 +00:00
|
|
|
echo ${tmp#test-}
|
2014-05-05 22:08:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# make sure any modules added here are disjoint
|
2018-12-10 13:50:01 +00:00
|
|
|
declare -a modules=(test-data-new.ko test-shadow-newpid.ko)
|
2014-05-05 22:08:08 +00:00
|
|
|
|
|
|
|
for mod in "${modules[@]}"; do
|
|
|
|
testprog=$(ko_to_test $mod)
|
2016-12-05 15:18:43 +00:00
|
|
|
$SCRIPTDIR/$testprog && die "$SCRIPTDIR/$testprog succeeded before loading any modules"
|
2014-05-05 22:08:08 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
for mod in "${modules[@]}"; do
|
|
|
|
$KPATCH load $mod
|
|
|
|
done
|
|
|
|
|
|
|
|
for mod in "${modules[@]}"; do
|
|
|
|
testprog=$(ko_to_test $mod)
|
2016-12-05 15:18:43 +00:00
|
|
|
$SCRIPTDIR/$testprog || die "$SCRIPTDIR/$testprog failed after loading modules"
|
2014-05-05 22:08:08 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
for mod in "${modules[@]}"; do
|
|
|
|
$KPATCH unload $mod
|
|
|
|
done
|
|
|
|
|
|
|
|
for mod in "${modules[@]}"; do
|
|
|
|
testprog=$(ko_to_test $mod)
|
2016-12-05 15:18:43 +00:00
|
|
|
$SCRIPTDIR/$testprog && die "$SCRIPTDIR/$testprog succeeded after unloading modules"
|
2014-05-05 22:08:08 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|