From be4ee611c18601312dcb3d94925a073225496a29 Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Mon, 26 May 2014 16:51:53 -0500 Subject: [PATCH] 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 --- kpatch-build/create-diff-object.c | 32 ------------------------------ test/Makefile | 5 ----- test/test01.c | 16 --------------- test/test01.inventory | 12 ----------- test/test01.patch | 11 ----------- test/test02.c | 22 --------------------- test/test02.inventory | 14 ------------- test/test02.patch | 10 ---------- test/test03.c | 13 ------------ test/test03.inventory | 16 --------------- test/test03.patch | 15 -------------- test/testall.sh | 7 ------- test/testone.sh | 33 ------------------------------- 13 files changed, 206 deletions(-) delete mode 100644 test/Makefile delete mode 100644 test/test01.c delete mode 100644 test/test01.inventory delete mode 100644 test/test01.patch delete mode 100644 test/test02.c delete mode 100644 test/test02.inventory delete mode 100644 test/test02.patch delete mode 100644 test/test03.c delete mode 100644 test/test03.inventory delete mode 100644 test/test03.patch delete mode 100755 test/testall.sh delete mode 100755 test/testone.sh diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 316ec77..8506ed6 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -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); diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index f890506..0000000 --- a/test/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: - ./testall.sh -clean: - rm -f output.o output.o.inventory reference.inventory test.inventory - diff --git a/test/test01.c b/test/test01.c deleted file mode 100644 index b45be2f..0000000 --- a/test/test01.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -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. - */ diff --git a/test/test01.inventory b/test/test01.inventory deleted file mode 100644 index 96bd1cf..0000000 --- a/test/test01.inventory +++ /dev/null @@ -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 diff --git a/test/test01.patch b/test/test01.patch deleted file mode 100644 index cdec9ac..0000000 --- a/test/test01.patch +++ /dev/null @@ -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 - - void test_func() { -- printf("this is before\n"); -+ printf("this is after\n"); - } - - /* diff --git a/test/test02.c b/test/test02.c deleted file mode 100644 index e3ea0d0..0000000 --- a/test/test02.c +++ /dev/null @@ -1,22 +0,0 @@ -#include - -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. - */ diff --git a/test/test02.inventory b/test/test02.inventory deleted file mode 100644 index e0c635a..0000000 --- a/test/test02.inventory +++ /dev/null @@ -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 diff --git a/test/test02.patch b/test/test02.patch deleted file mode 100644 index b7d5e08..0000000 --- a/test/test02.patch +++ /dev/null @@ -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 */ diff --git a/test/test03.c b/test/test03.c deleted file mode 100644 index 118aee3..0000000 --- a/test/test03.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -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. - */ diff --git a/test/test03.inventory b/test/test03.inventory deleted file mode 100644 index d8838dd..0000000 --- a/test/test03.inventory +++ /dev/null @@ -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 diff --git a/test/test03.patch b/test/test03.patch deleted file mode 100644 index 90359f1..0000000 --- a/test/test03.patch +++ /dev/null @@ -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 - -+static void test_func2() { -+ printf("this is after\n"); -+} -+ - void test_func() { - printf("this is before\n"); -+ test_func2(); - } - - /* diff --git a/test/testall.sh b/test/testall.sh deleted file mode 100755 index 0059cf0..0000000 --- a/test/testall.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -for i in *.c -do - TESTCASE=${i%.*} - ./testone.sh $TESTCASE -done diff --git a/test/testone.sh b/test/testone.sh deleted file mode 100755 index 8f9387f..0000000 --- a/test/testone.sh +++ /dev/null @@ -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