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 000000000..a07ffcbe0 Binary files /dev/null and b/tests/file_filter/file.gz differ diff --git a/tests/file_filter/file.gz.sig b/tests/file_filter/file.gz.sig new file mode 100644 index 000000000..602e6187e Binary files /dev/null and b/tests/file_filter/file.gz.sig differ diff --git a/tests/file_filter/file.lzop b/tests/file_filter/file.lzop new file mode 100644 index 000000000..5f5a97171 Binary files /dev/null and b/tests/file_filter/file.lzop differ diff --git a/tests/file_filter/file.lzop.sig b/tests/file_filter/file.lzop.sig new file mode 100644 index 000000000..7c68dcf93 Binary files /dev/null and b/tests/file_filter/file.lzop.sig differ diff --git a/tests/file_filter/file.xz b/tests/file_filter/file.xz new file mode 100644 index 000000000..151a98029 Binary files /dev/null and b/tests/file_filter/file.xz differ diff --git a/tests/file_filter/file.xz.sig b/tests/file_filter/file.xz.sig new file mode 100644 index 000000000..57569242e Binary files /dev/null and b/tests/file_filter/file.xz.sig differ diff --git a/tests/file_filter/keys b/tests/file_filter/keys new file mode 100644 index 000000000..1afa71382 Binary files /dev/null and b/tests/file_filter/keys differ diff --git a/tests/file_filter/keys.pub b/tests/file_filter/keys.pub new file mode 100644 index 000000000..61d4e7a7b Binary files /dev/null and b/tests/file_filter/keys.pub differ diff --git a/tests/file_filter/test.cfg b/tests/file_filter/test.cfg new file mode 100644 index 000000000..4308aaca5 --- /dev/null +++ b/tests/file_filter/test.cfg @@ -0,0 +1,6 @@ +trust /keys.pub +set check_signatures=enforce +cat /file.gz +cat /file.xz +cat /file.lzop +set check_signatures= diff --git a/tests/file_filter_test.in b/tests/file_filter_test.in new file mode 100644 index 000000000..8909e4021 --- /dev/null +++ b/tests/file_filter_test.in @@ -0,0 +1,76 @@ +#! /bin/sh +# Copyright (C) 2014 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see . + +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