Skip to content

Commit

Permalink
Merge pull request #190 from jpoimboe/test-special-sections
Browse files Browse the repository at this point in the history
add tests for special sections
  • Loading branch information
jpoimboe committed May 15, 2014
2 parents 59e9011 + ecfed91 commit d349d70
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 7 deletions.
9 changes: 9 additions & 0 deletions test/integration/Makefile
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions test/integration/bug-table-section.patch
Original file line number Diff line number Diff line change
@@ -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))
19 changes: 12 additions & 7 deletions test/integration/kpatch-test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/integration/parainstructions-section.patch
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 12 additions & 0 deletions test/integration/smp-locks-section.patch
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit d349d70

Please sign in to comment.