From 272e0466da16d0f8ce782895de4189c1585de9f3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 5 Dec 2014 20:19:58 +0300 Subject: [PATCH] add file filters tests Tests file access with all filters enabled. It does it both for local and network access, due to regression in signature checking over network. This includes all files in distribution to not depend on existence of compression tools and gpg. Test preloads all required modules to avoid having to provide signatures for them. Still not implemented is file offset filter (is not available in grub script, needs extra module) --- ChangeLog | 12 +++++ Makefile.util.def | 6 +++ conf/Makefile.extra-dist | 11 +++++ tests/file_filter/file.gz | Bin 0 -> 33 bytes tests/file_filter/file.gz.sig | Bin 0 -> 96 bytes tests/file_filter/file.lzop | Bin 0 -> 67 bytes tests/file_filter/file.lzop.sig | Bin 0 -> 96 bytes tests/file_filter/file.xz | Bin 0 -> 72 bytes tests/file_filter/file.xz.sig | Bin 0 -> 96 bytes tests/file_filter/keys | Bin 0 -> 994 bytes tests/file_filter/keys.pub | Bin 0 -> 990 bytes tests/file_filter/test.cfg | 6 +++ tests/file_filter_test.in | 76 ++++++++++++++++++++++++++++++++ 13 files changed, 111 insertions(+) create mode 100644 tests/file_filter/file.gz create mode 100644 tests/file_filter/file.gz.sig create mode 100644 tests/file_filter/file.lzop create mode 100644 tests/file_filter/file.lzop.sig create mode 100644 tests/file_filter/file.xz create mode 100644 tests/file_filter/file.xz.sig create mode 100644 tests/file_filter/keys create mode 100644 tests/file_filter/keys.pub create mode 100644 tests/file_filter/test.cfg create mode 100644 tests/file_filter_test.in diff --git a/ChangeLog b/ChangeLog index c163cd5c0..91ea81fb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,18 @@ 2014-12-05 Andrei Borzenkov * tests/util/grub-shell.in: Support --files also for netboot. + * tests/file_filter_test.in: New file with file filters tests. + * Makefile.util.def: Add file_filter_test. + * conf/Makefile.extra-dist: ... and here. + * tests/file_filter/file.gz: Test file for file_filter_test. + * tests/file_filter/file.gz.sig: Likewise. + * tests/file_filter/file.lzop: Likewise. + * tests/file_filter/file.lzop.sig: Likewise. + * tests/file_filter/file.xz: Likewise. + * tests/file_filter/file.xz.sig: Likewise. + * tests/file_filter/keys: Likewise. + * tests/file_filter/keys.pub: Likewise. + * tests/file_filter/test.cfg: Likewise. 2014-12-01 Andrei Borzenkov diff --git a/Makefile.util.def b/Makefile.util.def index a286a89cd..fed96d864 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -1150,6 +1150,12 @@ script = { common = tests/grub_cmd_tr.in; }; +script = { + testcase; + name = file_filter_test; + common = tests/file_filter_test.in; +}; + program = { testcase; name = example_unit_test; diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index 51f08c1f9..1b95ccd3f 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -110,3 +110,14 @@ EXTRA_DIST += tests/dfly-mbr-mbexample.mbr.img.gz EXTRA_DIST += tests/dfly-mbr-mbexample.dfly.img.gz EXTRA_DIST += coreboot.cfg + +EXTRA_DIST += tests/file_filter/file +EXTRA_DIST += tests/file_filter/file.gz +EXTRA_DIST += tests/file_filter/file.gz.sig +EXTRA_DIST += tests/file_filter/file.lzop +EXTRA_DIST += tests/file_filter/file.lzop.sig +EXTRA_DIST += tests/file_filter/file.xz +EXTRA_DIST += tests/file_filter/file.xz.sig +EXTRA_DIST += tests/file_filter/keys +EXTRA_DIST += tests/file_filter/keys.pub +EXTRA_DIST += tests/file_filter/test.cfg diff --git a/tests/file_filter/file.gz b/tests/file_filter/file.gz new file mode 100644 index 0000000000000000000000000000000000000000..a07ffcbe0cbad415ea51ec72bbe7b54094284d3d GIT binary patch literal 33 pcmb2|=3qFtrZI$p`LoB_lP9kSYUuju20dY7FxvO)Cocm70|4R_48H&X literal 0 HcmV?d00001 diff --git a/tests/file_filter/file.gz.sig b/tests/file_filter/file.gz.sig new file mode 100644 index 0000000000000000000000000000000000000000..602e6187e22d7fc288a52ac572f38cc1066083cb GIT binary patch literal 96 zcmV-m0H6PeUIYLU2ml5J0#t#n2LK8Q5M~MT@8nv<3h9^t|7f?gmaE1LNh!Sm;mO#P zdLo*tTpkl+s!TB^f%Fh1{Q&^Tlz2`!Q4Giq Ct|zAe literal 0 HcmV?d00001 diff --git a/tests/file_filter/file.lzop b/tests/file_filter/file.lzop new file mode 100644 index 0000000000000000000000000000000000000000..5f5a97171821de55168fcbdc9b1b335316d295b9 GIT binary patch literal 67 zcmeD5iSlRQ<&xqOFi>dVbYNsjC(Bu@f@NKNp%ec7JvFb-Lz3O)* CVl0pV literal 0 HcmV?d00001 diff --git a/tests/file_filter/file.xz b/tests/file_filter/file.xz new file mode 100644 index 0000000000000000000000000000000000000000..151a98029033dd0947d54f8ddad670da85a45185 GIT binary patch literal 72 zcmexsUKJ6=z`*kC+7>q^21Q0O1_p)_{ill=8F)NWb8_-^6iSOzixjzl!VG^@7(cF= Z)UCz9sLER?d1RaXw$HVUAPJVpC;$*f6z~85 literal 0 HcmV?d00001 diff --git a/tests/file_filter/file.xz.sig b/tests/file_filter/file.xz.sig new file mode 100644 index 0000000000000000000000000000000000000000..57569242e4742cdfb929307ec19440cf91f49e9a GIT binary patch literal 96 zcmV-m0H6PeUIYLU2ml5J0#t#n3jhiU5M~MT@8nv<3OS$v{x;4Uj6+!wt^-rP*&N$| z+5zKQ7vOO`?M~+y=au4FasdGNRgV;Q;4TNc&v05)-JLjLl54~a(Q}0wbmOZ2ne0%w Ci77V# literal 0 HcmV?d00001 diff --git a/tests/file_filter/keys b/tests/file_filter/keys new file mode 100644 index 0000000000000000000000000000000000000000..1afa71382364060d08bb0c28e36a1ff98d585fe8 GIT binary patch literal 994 zcmV<810DRC11@ew%2nM8awI88}g~WvBj*BJPpr^(@>)pd~ex-<$MMPxbNPGZV|BH zWj8IQR4B@uXKc3uaPJ1=^^Zq^DT zGR)3)y_E}*oM=>(9mHp}SKbH+oTA=g$}Y_>Yo72Jn4N$d^(*k!0WN3*`c`xB4p;&y zxUni$jurte*DGtmax;-CBK;ReR-(#??6SOFAtnGFD6+^8CX~5LD{yPt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ZtP zFGWnyh(8GDLvyN?Wb=5U*>gB4;O4Q~QA&IhlL~dxCca=f>yhv4IlbS9*wP37G*l-7 z68Nu9XH0V?#8Mlr_|4bivnV+Xw zydOTU@TyjupFl11F8p`)R&210tm6Y4QE*AG%aIRbg##g$XGEjNV}o~RH4hXtsdF}8 zgc#a=4BiAs$WhG?LV$*t4U}ex(o2%HHKsbzt@0q@tiFkDvxZ4j5EO=^&d${9btru+ zAB}{L36Q;49P;3xdCKCi1x(1w?GNPIz7@+G3MU121``j|n!I&1(;|JmS_t_VuMTgP z(dkfWGS. + +set -e +grubshell=@builddir@/grub-shell + +. "@builddir@/grub-core/modinfo.sh" + +filters="gzio xzio lzopio verify" +modules="cat mpi" + +for mod in $(cut -d ' ' -f 2 "@builddir@/grub-core/crypto.lst" | sort -u); do + modules="$modules $mod" +done + +for file in file.gz file.xz file.lzop file.gz.sig file.xz.sig file.lzop.sig keys.pub; do + files="$files /$file=@srcdir@/tests/file_filter/$file" +done + +# GRUB cat command adds extra newline after file +result="Hello, user! + +Hello, user! + +Hello, user!" + +out="$("${grubshell}" --modules="$modules $filters" --files="$files" "@srcdir@/tests/file_filter/test.cfg")" +if [ "$out" != "$result" ]; then + echo LOCAL FAIL + echo "$out" + exit 1 +fi + +# Taken from netboot_test +case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in + # PLATFORM: emu is different + *-emu) + exit 0;; + # PLATFORM: Flash targets + i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips) + exit 0;; + # FIXME: currently grub-shell uses only -kernel for loongson + mipsel-loongson) + exit 0;; + # FIXME: no rtl8139 support + i386-multiboot) + exit 0;; + # FIXME: We don't fully support netboot on ARC + *-arc) + exit 0;; + # FIXME: Many QEMU firmware have no netboot capability + *-efi | i386-ieee1275 | powerpc-ieee1275 | sparc64-ieee1275) + exit 0;; +esac + +out="$("${grubshell}" --boot=net --modules="$modules $filters" --files="$files" "@srcdir@/tests/file_filter/test.cfg")" +if [ "$out" != "$result" ]; then + echo NET FAIL + echo "$out" + exit 1 +fi + +exit 0