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)
This commit is contained in:
parent
4b94e3227b
commit
272e0466da
13 changed files with 111 additions and 0 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,6 +1,18 @@
|
||||||
2014-12-05 Andrei Borzenkov <arvidjaar@gmail.com>
|
2014-12-05 Andrei Borzenkov <arvidjaar@gmail.com>
|
||||||
|
|
||||||
* tests/util/grub-shell.in: Support --files also for netboot.
|
* 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 <arvidjaar@gmail.com>
|
2014-12-01 Andrei Borzenkov <arvidjaar@gmail.com>
|
||||||
|
|
||||||
|
|
|
@ -1150,6 +1150,12 @@ script = {
|
||||||
common = tests/grub_cmd_tr.in;
|
common = tests/grub_cmd_tr.in;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = file_filter_test;
|
||||||
|
common = tests/file_filter_test.in;
|
||||||
|
};
|
||||||
|
|
||||||
program = {
|
program = {
|
||||||
testcase;
|
testcase;
|
||||||
name = example_unit_test;
|
name = example_unit_test;
|
||||||
|
|
|
@ -110,3 +110,14 @@ EXTRA_DIST += tests/dfly-mbr-mbexample.mbr.img.gz
|
||||||
EXTRA_DIST += tests/dfly-mbr-mbexample.dfly.img.gz
|
EXTRA_DIST += tests/dfly-mbr-mbexample.dfly.img.gz
|
||||||
|
|
||||||
EXTRA_DIST += coreboot.cfg
|
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
|
||||||
|
|
BIN
tests/file_filter/file.gz
Normal file
BIN
tests/file_filter/file.gz
Normal file
Binary file not shown.
BIN
tests/file_filter/file.gz.sig
Normal file
BIN
tests/file_filter/file.gz.sig
Normal file
Binary file not shown.
BIN
tests/file_filter/file.lzop
Normal file
BIN
tests/file_filter/file.lzop
Normal file
Binary file not shown.
BIN
tests/file_filter/file.lzop.sig
Normal file
BIN
tests/file_filter/file.lzop.sig
Normal file
Binary file not shown.
BIN
tests/file_filter/file.xz
Normal file
BIN
tests/file_filter/file.xz
Normal file
Binary file not shown.
BIN
tests/file_filter/file.xz.sig
Normal file
BIN
tests/file_filter/file.xz.sig
Normal file
Binary file not shown.
BIN
tests/file_filter/keys
Normal file
BIN
tests/file_filter/keys
Normal file
Binary file not shown.
BIN
tests/file_filter/keys.pub
Normal file
BIN
tests/file_filter/keys.pub
Normal file
Binary file not shown.
6
tests/file_filter/test.cfg
Normal file
6
tests/file_filter/test.cfg
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
trust /keys.pub
|
||||||
|
set check_signatures=enforce
|
||||||
|
cat /file.gz
|
||||||
|
cat /file.xz
|
||||||
|
cat /file.lzop
|
||||||
|
set check_signatures=
|
76
tests/file_filter_test.in
Normal file
76
tests/file_filter_test.in
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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
|
Loading…
Reference in a new issue