Merge pull request #190 from jpoimboe/test-special-sections

add tests for special sections
This commit is contained in:
Josh Poimboeuf 2014-05-15 17:29:43 -05:00
commit d349d705bf
5 changed files with 57 additions and 7 deletions

View File

@ -1,2 +1,11 @@
all:
./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
clean:
rm -f *.ko *.log

View File

@ -0,0 +1,12 @@
Index: src/fs/proc/proc_sysctl.c
===================================================================
--- src.orig/fs/proc/proc_sysctl.c
+++ src/fs/proc/proc_sysctl.c
@@ -266,6 +266,7 @@ void sysctl_head_put(struct ctl_table_he
static struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
{
+ printk("kpatch-test: testing __bug_table section changes\n");
BUG_ON(!head);
spin_lock(&sysctl_lock);
if (!use_table(head))

View File

@ -125,21 +125,26 @@ run_load_test() {
module=kpatch-$prefix.ko
testprog=$prefix-LOADED.test
[[ ! -e $testprog ]] && return
log "load test: $prefix"
[[ $prefix = *-FAIL ]] && return
if [[ ! -e $module ]]; then
error "$prefix: can't find $module"
log "can't find $module, skipping"
return
fi
if [[ -e $testprog ]]; then
log "load test: $prefix"
else
log "load test: $prefix (no test prog)"
fi
if ! $KPATCH replace $module >> $LOG 2>&1; then
error "$prefix: kpatch replace failed"
return
fi
if ! ./$testprog >> $LOG 2>&1; then
if [[ -e $testprog ]] && ! ./$testprog >> $LOG 2>&1; then
error "$prefix: $testprog failed after kpatch replace"
return
fi
@ -149,7 +154,7 @@ run_load_test() {
return
fi
if ./$testprog >> $LOG 2>&1; then
if [[ -e $testprog ]] && ./$testprog >> $LOG 2>&1; then
error "$prefix: $testprog succeeded after kpatch unload"
return
fi
@ -159,7 +164,7 @@ run_load_test() {
return
fi
if ! ./$testprog >> $LOG 2>&1; then
if [[ -e $testprog ]] && ! ./$testprog >> $LOG 2>&1; then
error "$prefix: $testprog failed after kpatch load"
return
fi

View File

@ -0,0 +1,12 @@
Index: src/fs/proc/generic.c
===================================================================
--- src.orig/fs/proc/generic.c
+++ src/fs/proc/generic.c
@@ -132,6 +132,7 @@ int proc_alloc_inum(unsigned int *inum)
unsigned int i;
int error;
+ printk("kpatch-test: testing change to .parainstructions section\n");
retry:
if (!ida_pre_get(&proc_inum_ida, GFP_KERNEL))
return -ENOMEM;

View File

@ -0,0 +1,12 @@
Index: src/drivers/tty/tty_buffer.c
===================================================================
--- src.orig/drivers/tty/tty_buffer.c
+++ src/drivers/tty/tty_buffer.c
@@ -245,6 +245,7 @@ static int __tty_buffer_request_room(str
struct tty_buffer *b, *n;
int left, change;
+ printk("kpatch-test: testing .smp_locks section changes\n");
b = buf->tail;
if (b->flags & TTYB_NORMAL)
left = 2 * b->size - b->used;