mirror of
https://github.com/dynup/kpatch
synced 2025-03-04 17:58:10 +00:00
remove inventory based testing
The inventory based testing for create-diff-object was introduced at a time when create-diff-object only needed the two object files to operate. Now, it requires vmlinux as well. This makes the inventory testing (a unit testing framework for create-diff-object) obsolete and difficult to update in it's current form. This commit removes the inventory test framework. Signed-off-by: Seth Jennings <sjenning@redhat.com>
This commit is contained in:
parent
ae24942c9e
commit
be4ee611c1
@ -956,29 +956,6 @@ void kpatch_reindex_elements(struct kpatch_elf *kelf)
|
||||
}
|
||||
}
|
||||
|
||||
void kpatch_write_inventory_file(struct kpatch_elf *kelf, char *outfile)
|
||||
{
|
||||
FILE *out;
|
||||
char outbuf[255];
|
||||
struct section *sec;
|
||||
struct symbol *sym;
|
||||
|
||||
if (snprintf(outbuf, 254, "%s.inventory", outfile) < 0)
|
||||
ERROR("snprintf");
|
||||
|
||||
out = fopen(outbuf, "w");
|
||||
if (!out)
|
||||
ERROR("fopen");
|
||||
|
||||
list_for_each_entry(sec, &kelf->sections, list)
|
||||
fprintf(out, "section %s\n", sec->name);
|
||||
|
||||
list_for_each_entry(sym, &kelf->symbols, list)
|
||||
fprintf(out, "symbol %s %d %d\n", sym->name, sym->type, sym->bind);
|
||||
|
||||
fclose(out);
|
||||
}
|
||||
|
||||
/*
|
||||
* The format of section __bug_table is a table of struct bug_entry. Each
|
||||
* bug_entry has three fields:
|
||||
@ -1770,14 +1747,12 @@ void kpatch_write_output_elf(struct kpatch_elf *kelf, Elf *elf, char *outfile)
|
||||
struct arguments {
|
||||
char *args[4];
|
||||
int debug;
|
||||
int inventory;
|
||||
};
|
||||
|
||||
static char args_doc[] = "original.o patched.o vmlinux output.o";
|
||||
|
||||
static struct argp_option options[] = {
|
||||
{"debug", 'd', 0, 0, "Show debug output" },
|
||||
{"inventory", 'i', 0, 0, "Create inventory file with list of sections and symbols" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
@ -1792,9 +1767,6 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
|
||||
case 'd':
|
||||
arguments->debug = 1;
|
||||
break;
|
||||
case 'i':
|
||||
arguments->inventory = 1;
|
||||
break;
|
||||
case ARGP_KEY_ARG:
|
||||
if (state->arg_num >= 4)
|
||||
/* Too many arguments. */
|
||||
@ -1867,7 +1839,6 @@ int main(int argc, char *argv[])
|
||||
char *hint;
|
||||
|
||||
arguments.debug = 0;
|
||||
arguments.inventory = 0;
|
||||
argp_parse (&argp, argc, argv, 0, 0, &arguments);
|
||||
if (arguments.debug)
|
||||
loglevel = DEBUG;
|
||||
@ -1970,9 +1941,6 @@ int main(int argc, char *argv[])
|
||||
kpatch_dump_kelf(kelf_out);
|
||||
kpatch_write_output_elf(kelf_out, kelf_patched->elf, outfile);
|
||||
|
||||
if (arguments.inventory)
|
||||
kpatch_write_inventory_file(kelf_out, outfile);
|
||||
|
||||
kpatch_elf_free(kelf_patched);
|
||||
kpatch_elf_teardown(kelf_out);
|
||||
kpatch_elf_free(kelf_out);
|
||||
|
@ -1,5 +0,0 @@
|
||||
all:
|
||||
./testall.sh
|
||||
clean:
|
||||
rm -f output.o output.o.inventory reference.inventory test.inventory
|
||||
|
@ -1,16 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void test_func() {
|
||||
printf("this is before\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* This test case ensures that deep inspection for rela entries
|
||||
* that reference strings is taking place. The text and rela sections
|
||||
* for test_func() are the same between the original and patched
|
||||
* versions. However, the tool should detect that the string referenced
|
||||
* by the printf has changed.
|
||||
*
|
||||
* Verification points: test_func bundle and the rodata.str1.8 section
|
||||
* are included.
|
||||
*/
|
@ -1,12 +0,0 @@
|
||||
section .rodata.str1.1
|
||||
section .text.test_func
|
||||
section .rela.text.test_func
|
||||
section .shstrtab
|
||||
section .symtab
|
||||
section .strtab
|
||||
symbol test01.c 4 0
|
||||
symbol .rodata.str1.1 3 0
|
||||
symbol .text.test_func 3 0
|
||||
symbol test_func 2 1
|
||||
symbol puts 0 1
|
||||
symbol 0 0
|
@ -1,11 +0,0 @@
|
||||
--- test01.c.orig 2014-03-10 14:34:02.547250917 -0500
|
||||
+++ test01.c 2014-03-10 14:34:02.549250971 -0500
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void test_func() {
|
||||
- printf("this is before\n");
|
||||
+ printf("this is after\n");
|
||||
}
|
||||
|
||||
/*
|
@ -1,22 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
static int a = 1;
|
||||
|
||||
void test_func() {
|
||||
printf("%d\n",a);
|
||||
}
|
||||
|
||||
/* this is to ensure that a isn't optimized out by the compiler */
|
||||
void test_func2() {
|
||||
a = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* This test case ensures that static data structures, normally referenced
|
||||
* by section in rela entries that reference them, are being converted to
|
||||
* symbol references, so they can later be linked to the location of the
|
||||
* data structure in the running kernel
|
||||
*
|
||||
* Verification points: test_func() bundle and 'a' symbol should be included.
|
||||
* 'a' should have GLOBAL bind and NOTYPE type.
|
||||
*/
|
@ -1,14 +0,0 @@
|
||||
section .rodata.str1.1
|
||||
section .text.test_func
|
||||
section .rela.text.test_func
|
||||
section .shstrtab
|
||||
section .symtab
|
||||
section .strtab
|
||||
symbol test02.c 4 0
|
||||
symbol .rodata.str1.1 3 0
|
||||
symbol .text.test_func 3 0
|
||||
symbol a 0 1
|
||||
symbol test_func 2 1
|
||||
symbol printf 0 1
|
||||
symbol puts 0 1
|
||||
symbol 0 0
|
@ -1,10 +0,0 @@
|
||||
--- test02.c.orig 2014-03-10 14:34:02.556251118 -0500
|
||||
+++ test02.c 2014-03-10 14:34:02.558251160 -0500
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
void test_func() {
|
||||
printf("%d\n",a);
|
||||
+ printf("this is after\n");
|
||||
}
|
||||
|
||||
/* this is to ensure that a isn't optimized out by the compiler */
|
@ -1,13 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void test_func() {
|
||||
printf("this is before\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* This test case introduces a new function called by an existing function
|
||||
* and ensure that the bundle for that function is included.
|
||||
*
|
||||
* Verification points: bundles for test_func() and test_func2() should be
|
||||
* included.
|
||||
*/
|
@ -1,16 +0,0 @@
|
||||
section .rodata.str1.1
|
||||
section .text.test_func2
|
||||
section .rela.text.test_func2
|
||||
section .text.test_func
|
||||
section .rela.text.test_func
|
||||
section .shstrtab
|
||||
section .symtab
|
||||
section .strtab
|
||||
symbol test03.c 4 0
|
||||
symbol .rodata.str1.1 3 0
|
||||
symbol .text.test_func2 3 0
|
||||
symbol test_func2 2 0
|
||||
symbol .text.test_func 3 0
|
||||
symbol puts 0 1
|
||||
symbol test_func 2 1
|
||||
symbol 0 0
|
@ -1,15 +0,0 @@
|
||||
--- test03.c.orig 2014-03-10 14:34:02.564251278 -0500
|
||||
+++ test03.c 2014-03-10 14:34:02.566251318 -0500
|
||||
@@ -1,7 +1,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
+static void test_func2() {
|
||||
+ printf("this is after\n");
|
||||
+}
|
||||
+
|
||||
void test_func() {
|
||||
printf("this is before\n");
|
||||
+ test_func2();
|
||||
}
|
||||
|
||||
/*
|
@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
for i in *.c
|
||||
do
|
||||
TESTCASE=${i%.*}
|
||||
./testone.sh $TESTCASE
|
||||
done
|
@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $# -ne 1 ]]
|
||||
then
|
||||
echo "test.sh testcase"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TESTCASE=$1
|
||||
FLAGS="-fno-strict-aliasing -fno-common -fno-delete-null-pointer-checks -O2 -m64 -mpreferred-stack-boundary=4 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fno-asynchronous-unwind-tables -fno-stack-protector -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-overflow -fconserve-stack -ffunction-sections -fdata-sections -fno-inline"
|
||||
CFLAGS="$FLAGS" make $TESTCASE.o > /dev/null 2>&1 || exit 1
|
||||
mv -f $TESTCASE.o $TESTCASE.o.orig
|
||||
patch $TESTCASE.c $TESTCASE.patch > /dev/null 2>&1 || exit 1
|
||||
CFLAGS="$FLAGS" make $TESTCASE.o > /dev/null 2>&1 || exit 1
|
||||
if [[ ! -e ../kpatch-build/create-diff-object ]]
|
||||
then
|
||||
make -C ../kpatch-build create-diff-object || exit 1
|
||||
fi
|
||||
../kpatch-build/create-diff-object -i $TESTCASE.o.orig $TESTCASE.o output.o > /dev/null 2>&1 || exit 1
|
||||
rm -f $TESTCASE.o $TESTCASE.o.orig > /dev/null 2>&1
|
||||
patch -R $TESTCASE.c $TESTCASE.patch > /dev/null 2>&1 || echo "warning: unable to unpatch file $TESTCASE.c"
|
||||
|
||||
sort $TESTCASE.inventory > reference.inventory
|
||||
sort output.o.inventory > test.inventory
|
||||
rm -f output.o.inventory > /dev/null 2>&1
|
||||
diff reference.inventory test.inventory
|
||||
if [[ $? -ne 0 ]]
|
||||
then
|
||||
echo "$TESTCASE failed" && exit 1
|
||||
else
|
||||
echo "$TESTCASE passed"
|
||||
fi
|
||||
rm -f reference.inventory test.inventory output.o
|
Loading…
Reference in New Issue
Block a user