Refresh GRUB scripts, config, and integration documentation

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-04-18 00:48:58 +01:00
parent 90168fb789
commit 8ca7e02398
2449 changed files with 1155215 additions and 38 deletions
@@ -0,0 +1,58 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2013 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"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
exit 77;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
exit 77;;
# PLATFORM: no AHCI on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
exit 77;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi | loongarch64-efi)
exit 77;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
v=$(echo "nativedisk; source '(ahci0)/$outfile';" |
"${grubshell}" --qemu-opts="-drive id=disk,file=$imgfile,if=none
-device ahci,id=ahci
-device ide-hd,drive=disk,bus=ahci.0")
v=$(echo "$v" | tail -n 1)
if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
fi
rm "$imgfile"
rm "$outfile"
@@ -0,0 +1,25 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.btrfs >/dev/null 2>&1; then
echo "mkfs.btrfs not installed; cannot test btrfs."
exit 99
fi
"@builddir@/grub-fs-tester" btrfs
"@builddir@/grub-fs-tester" btrfs_zlib
"@builddir@/grub-fs-tester" btrfs_lzo
"@builddir@/grub-fs-tester" btrfs_zstd
"@builddir@/grub-fs-tester" btrfs_raid0
"@builddir@/grub-fs-tester" btrfs_raid1
"@builddir@/grub-fs-tester" btrfs_single
"@builddir@/grub-fs-tester" btrfs_raid10
@@ -0,0 +1,40 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2013 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"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different
*-emu)
exit 77;;
# PLATFORM: Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 77;;
# FIXME: currently grub-shell uses only -kernel for loongson
mipsel-loongson)
exit 77;;
# FIXME: OFW fails to open CD-ROM
i386-ieee1275)
exit 77;;
esac
v=$(echo hello | "${grubshell}" --boot=cd)
if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ -0,0 +1,226 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2012 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/>.
*/
#include <stdio.h>
#include <string.h>
#include <grub/test.h>
#include <grub/misc.h>
GRUB_MOD_LICENSE ("GPLv3+");
#define MSG "cmp test failed"
/* Functional test main method. */
static void
cmp_test (void)
{
const char *s1 = "a";
const char *s2 = "aa";
const char *s3 = "â";
grub_test_assert (grub_strlen (s1) == 1, MSG);
grub_test_assert (grub_strlen (s2) == 2, MSG);
grub_test_assert (grub_strlen (s3) == 2, MSG);
grub_test_assert (grub_strcmp (s1, s1) == 0, MSG);
grub_test_assert (grub_strcmp (s1, s2) < 0, MSG);
grub_test_assert (grub_strcmp (s1, s3) < 0, MSG);
grub_test_assert (grub_strcmp (s2, s1) > 0, MSG);
grub_test_assert (grub_strcmp (s2, s2) == 0, MSG);
grub_test_assert (grub_strcmp (s2, s3) < 0, MSG);
grub_test_assert (grub_strcmp (s3, s1) > 0, MSG);
grub_test_assert (grub_strcmp (s3, s2) > 0, MSG);
grub_test_assert (grub_strcmp (s3, s3) == 0, MSG);
grub_test_assert (grub_strcasecmp (s1, s1) == 0, MSG);
grub_test_assert (grub_strcasecmp (s1, s2) < 0, MSG);
grub_test_assert (grub_strcasecmp (s1, s3) < 0, MSG);
grub_test_assert (grub_strcasecmp (s2, s1) > 0, MSG);
grub_test_assert (grub_strcasecmp (s2, s2) == 0, MSG);
grub_test_assert (grub_strcasecmp (s2, s3) < 0, MSG);
grub_test_assert (grub_strcasecmp (s3, s1) > 0, MSG);
grub_test_assert (grub_strcasecmp (s3, s2) > 0, MSG);
grub_test_assert (grub_strcasecmp (s3, s3) == 0, MSG);
grub_test_assert (grub_memcmp (s1, s1, 2) == 0, MSG);
grub_test_assert (grub_memcmp (s1, s2, 2) < 0, MSG);
grub_test_assert (grub_memcmp (s1, s3, 2) < 0, MSG);
grub_test_assert (grub_memcmp (s2, s1, 2) > 0, MSG);
grub_test_assert (grub_memcmp (s2, s2, 2) == 0, MSG);
grub_test_assert (grub_memcmp (s2, s3, 2) < 0, MSG);
grub_test_assert (grub_memcmp (s3, s1, 2) > 0, MSG);
grub_test_assert (grub_memcmp (s3, s2, 2) > 0, MSG);
grub_test_assert (grub_memcmp (s3, s3, 2) == 0, MSG);
grub_test_assert (grub_memcmp (s1, s1, 1) == 0, MSG);
grub_test_assert (grub_memcmp (s1, s2, 1) == 0, MSG);
grub_test_assert (grub_memcmp (s1, s3, 1) < 0, MSG);
grub_test_assert (grub_memcmp (s2, s1, 1) == 0, MSG);
grub_test_assert (grub_memcmp (s2, s2, 1) == 0, MSG);
grub_test_assert (grub_memcmp (s2, s3, 1) < 0, MSG);
grub_test_assert (grub_memcmp (s3, s1, 1) > 0, MSG);
grub_test_assert (grub_memcmp (s3, s2, 1) > 0, MSG);
grub_test_assert (grub_memcmp (s3, s3, 1) == 0, MSG);
grub_test_assert (grub_strncmp (s1, s1, 2) == 0, MSG);
grub_test_assert (grub_strncmp (s1, s2, 2) < 0, MSG);
grub_test_assert (grub_strncmp (s1, s3, 2) < 0, MSG);
grub_test_assert (grub_strncmp (s2, s1, 2) > 0, MSG);
grub_test_assert (grub_strncmp (s2, s2, 2) == 0, MSG);
grub_test_assert (grub_strncmp (s2, s3, 2) < 0, MSG);
grub_test_assert (grub_strncmp (s3, s1, 2) > 0, MSG);
grub_test_assert (grub_strncmp (s3, s2, 2) > 0, MSG);
grub_test_assert (grub_strncmp (s3, s3, 2) == 0, MSG);
grub_test_assert (grub_strncmp (s1, s1, 1) == 0, MSG);
grub_test_assert (grub_strncmp (s1, s2, 1) == 0, MSG);
grub_test_assert (grub_strncmp (s1, s3, 1) < 0, MSG);
grub_test_assert (grub_strncmp (s2, s1, 1) == 0, MSG);
grub_test_assert (grub_strncmp (s2, s2, 1) == 0, MSG);
grub_test_assert (grub_strncmp (s2, s3, 1) < 0, MSG);
grub_test_assert (grub_strncmp (s3, s1, 1) > 0, MSG);
grub_test_assert (grub_strncmp (s3, s2, 1) > 0, MSG);
grub_test_assert (grub_strncmp (s3, s3, 1) == 0, MSG);
grub_test_assert (grub_strncasecmp (s1, s1, 2) == 0, MSG);
grub_test_assert (grub_strncasecmp (s1, s2, 2) < 0, MSG);
grub_test_assert (grub_strncasecmp (s1, s3, 2) < 0, MSG);
grub_test_assert (grub_strncasecmp (s2, s1, 2) > 0, MSG);
grub_test_assert (grub_strncasecmp (s2, s2, 2) == 0, MSG);
grub_test_assert (grub_strncasecmp (s2, s3, 2) < 0, MSG);
grub_test_assert (grub_strncasecmp (s3, s1, 2) > 0, MSG);
grub_test_assert (grub_strncasecmp (s3, s2, 2) > 0, MSG);
grub_test_assert (grub_strncasecmp (s3, s3, 2) == 0, MSG);
grub_test_assert (grub_strncasecmp (s1, s1, 1) == 0, MSG);
grub_test_assert (grub_strncasecmp (s1, s2, 1) == 0, MSG);
grub_test_assert (grub_strncasecmp (s1, s3, 1) < 0, MSG);
grub_test_assert (grub_strncasecmp (s2, s1, 1) == 0, MSG);
grub_test_assert (grub_strncasecmp (s2, s2, 1) == 0, MSG);
grub_test_assert (grub_strncasecmp (s2, s3, 1) < 0, MSG);
grub_test_assert (grub_strncasecmp (s3, s1, 1) > 0, MSG);
grub_test_assert (grub_strncasecmp (s3, s2, 1) > 0, MSG);
grub_test_assert (grub_strncasecmp (s3, s3, 1) == 0, MSG);
grub_test_assert (strlen (s1) == 1, MSG);
grub_test_assert (strlen (s2) == 2, MSG);
grub_test_assert (strlen (s3) == 2, MSG);
grub_test_assert (strcmp (s1, s1) == 0, MSG);
grub_test_assert (strcmp (s1, s2) < 0, MSG);
grub_test_assert (strcmp (s1, s3) < 0, MSG);
grub_test_assert (strcmp (s2, s1) > 0, MSG);
grub_test_assert (strcmp (s2, s2) == 0, MSG);
grub_test_assert (strcmp (s2, s3) < 0, MSG);
grub_test_assert (strcmp (s3, s1) > 0, MSG);
grub_test_assert (strcmp (s3, s2) > 0, MSG);
grub_test_assert (strcmp (s3, s3) == 0, MSG);
grub_test_assert (memcmp (s1, s1, 2) == 0, MSG);
grub_test_assert (memcmp (s1, s2, 2) < 0, MSG);
grub_test_assert (memcmp (s1, s3, 2) < 0, MSG);
grub_test_assert (memcmp (s2, s1, 2) > 0, MSG);
grub_test_assert (memcmp (s2, s2, 2) == 0, MSG);
grub_test_assert (memcmp (s2, s3, 2) < 0, MSG);
grub_test_assert (memcmp (s3, s1, 2) > 0, MSG);
grub_test_assert (memcmp (s3, s2, 2) > 0, MSG);
grub_test_assert (memcmp (s3, s3, 2) == 0, MSG);
grub_test_assert (memcmp (s1, s1, 1) == 0, MSG);
grub_test_assert (memcmp (s1, s2, 1) == 0, MSG);
grub_test_assert (memcmp (s1, s3, 1) < 0, MSG);
grub_test_assert (memcmp (s2, s1, 1) == 0, MSG);
grub_test_assert (memcmp (s2, s2, 1) == 0, MSG);
grub_test_assert (memcmp (s2, s3, 1) < 0, MSG);
grub_test_assert (memcmp (s3, s1, 1) > 0, MSG);
grub_test_assert (memcmp (s3, s2, 1) > 0, MSG);
grub_test_assert (memcmp (s3, s3, 1) == 0, MSG);
grub_test_assert (strncmp (s1, s1, 2) == 0, MSG);
grub_test_assert (strncmp (s1, s2, 2) < 0, MSG);
grub_test_assert (strncmp (s1, s3, 2) < 0, MSG);
grub_test_assert (strncmp (s2, s1, 2) > 0, MSG);
grub_test_assert (strncmp (s2, s2, 2) == 0, MSG);
grub_test_assert (strncmp (s2, s3, 2) < 0, MSG);
grub_test_assert (strncmp (s3, s1, 2) > 0, MSG);
grub_test_assert (strncmp (s3, s2, 2) > 0, MSG);
grub_test_assert (strncmp (s3, s3, 2) == 0, MSG);
grub_test_assert (strncmp (s1, s1, 1) == 0, MSG);
grub_test_assert (strncmp (s1, s2, 1) == 0, MSG);
grub_test_assert (strncmp (s1, s3, 1) < 0, MSG);
grub_test_assert (strncmp (s2, s1, 1) == 0, MSG);
grub_test_assert (strncmp (s2, s2, 1) == 0, MSG);
grub_test_assert (strncmp (s2, s3, 1) < 0, MSG);
grub_test_assert (strncmp (s3, s1, 1) > 0, MSG);
grub_test_assert (strncmp (s3, s2, 1) > 0, MSG);
grub_test_assert (strncmp (s3, s3, 1) == 0, MSG);
grub_test_assert (strncasecmp (s1, s1, 2) == 0, MSG);
grub_test_assert (strncasecmp (s1, s2, 2) < 0, MSG);
grub_test_assert (strncasecmp (s1, s3, 2) < 0, MSG);
grub_test_assert (strncasecmp (s2, s1, 2) > 0, MSG);
grub_test_assert (strncasecmp (s2, s2, 2) == 0, MSG);
grub_test_assert (strncasecmp (s2, s3, 2) < 0, MSG);
grub_test_assert (strncasecmp (s3, s1, 2) > 0, MSG);
grub_test_assert (strncasecmp (s3, s2, 2) > 0, MSG);
grub_test_assert (strncasecmp (s3, s3, 2) == 0, MSG);
grub_test_assert (strncasecmp (s1, s1, 1) == 0, MSG);
grub_test_assert (strncasecmp (s1, s2, 1) == 0, MSG);
grub_test_assert (strncasecmp (s1, s3, 1) < 0, MSG);
grub_test_assert (strncasecmp (s2, s1, 1) == 0, MSG);
grub_test_assert (strncasecmp (s2, s2, 1) == 0, MSG);
grub_test_assert (strncasecmp (s2, s3, 1) < 0, MSG);
grub_test_assert (strncasecmp (s3, s1, 1) > 0, MSG);
grub_test_assert (strncasecmp (s3, s2, 1) > 0, MSG);
grub_test_assert (strncasecmp (s3, s3, 1) == 0, MSG);
}
/* Register example_test method as a functional test. */
GRUB_UNIT_TEST ("cmp_test", cmp_test);
@@ -0,0 +1,38 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2013 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"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# FIXME: Only mips currently supports configurable core compression
*-emu | i386-* | x86_64-* | sparc64-* | ia64-*)
exit 77
;;
esac
v=$(echo hello | "${grubshell}" --grub-mkimage-extra=--compress=xz)
if [ "$v" != "Hello World" ]; then
exit 1
fi
v=$(echo hello | "${grubshell}" --grub-mkimage-extra=--compress=none)
if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ -0,0 +1,16 @@
#!@BUILD_SHEBANG@
set -e
if ! which cpio >/dev/null 2>&1; then
echo "cpio not installed; cannot test cpio."
exit 99
fi
"@builddir@/grub-fs-tester" cpio_bin
"@builddir@/grub-fs-tester" cpio_odc
"@builddir@/grub-fs-tester" cpio_newc
"@builddir@/grub-fs-tester" cpio_crc
"@builddir@/grub-fs-tester" cpio_ustar
"@builddir@/grub-fs-tester" cpio_hpbin
"@builddir@/grub-fs-tester" cpio_hpodc
@@ -0,0 +1,76 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2013 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/>.
*/
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <grub/misc.h>
#include <grub/datetime.h>
#include <grub/test.h>
static void
date_test (grub_int32_t v)
{
struct grub_datetime dt;
time_t t = v;
struct tm *g;
int w;
g = gmtime (&t);
grub_unixtime2datetime (v, &dt);
w = grub_get_weekday (&dt);
grub_test_assert (g->tm_sec == dt.second, "time %d bad second: %d vs %d", v,
g->tm_sec, dt.second);
grub_test_assert (g->tm_min == dt.minute, "time %d bad minute: %d vs %d", v,
g->tm_min, dt.minute);
grub_test_assert (g->tm_hour == dt.hour, "time %d bad hour: %d vs %d", v,
g->tm_hour, dt.hour);
grub_test_assert (g->tm_mday == dt.day, "time %d bad day: %d vs %d", v,
g->tm_mday, dt.day);
grub_test_assert (g->tm_mon + 1 == dt.month, "time %d bad month: %d vs %d", v,
g->tm_mon + 1, dt.month);
grub_test_assert (g->tm_year + 1900 == dt.year,
"time %d bad year: %d vs %d", v,
g->tm_year + 1900, dt.year);
grub_test_assert (g->tm_wday == w, "time %d bad week day: %d vs %d", v,
g->tm_wday, w);
}
static void
date_test_iter (void)
{
grub_int32_t tests[] = { -1, 0, +1, -2133156255, GRUB_INT32_MIN,
GRUB_INT32_MAX };
unsigned i;
for (i = 0; i < ARRAY_SIZE (tests); i++)
date_test (tests[i]);
srand (42);
for (i = 0; i < 1000000; i++)
{
grub_int32_t x = rand ();
date_test (x);
date_test (-x);
}
}
GRUB_UNIT_TEST ("date_unit_test", date_test_iter);
@@ -0,0 +1,56 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2013 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"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
exit 77;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
exit 77;;
# PLATFORM: no USB on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
exit 77;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi | loongarch64-efi)
exit 77;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
v=$(echo "nativedisk; source '(usb0)/$outfile';" |
"${grubshell}" --qemu-opts="-device ich9-usb-ehci1
-drive id=my_usb_disk,file=$imgfile,if=none
-device usb-storage,drive=my_usb_disk")
v=$(echo "$v" | tail -n 1)
if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
fi
rm "$imgfile"
rm "$outfile"
@@ -0,0 +1,3 @@
#! @builddir@/grub-shell-tester --modules=echo
echo "hello world"
@@ -0,0 +1,4 @@
#!@BUILD_SHEBANG@
set -e
true
@@ -0,0 +1,38 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 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/>.
*/
/* Unit tests are normal programs, so they can include C library. */
#include <string.h>
/* All tests need to include test.h for GRUB testing framework. */
#include <grub/test.h>
/* Unit test main method. */
static void
example_test (void)
{
/* Check if 1st argument is true and report with default error message. */
grub_test_assert (1 == 1, "1 equal 1 expected");
/* Check if 1st argument is true and report with custom error message. */
grub_test_assert (2 == 2, "2 equal 2 expected");
grub_test_assert (2 != 3, "2 matches %d", 3);
}
/* Register example_test method as a unit test. */
GRUB_UNIT_TEST ("example_unit_test", example_test);
@@ -0,0 +1,18 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.exfat >/dev/null 2>&1; then
echo "mkfs.exfat not installed; cannot test exFAT."
exit 99
fi
"@builddir@/grub-fs-tester" exfat
@@ -0,0 +1,33 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.ext2 >/dev/null 2>&1; then
echo "mkfs.ext2 not installed; cannot test ext2."
exit 99
fi
if ! which mkfs.ext3 >/dev/null 2>&1; then
echo "mkfs.ext3 not installed; cannot test ext3."
exit 99
fi
if ! which mkfs.ext4 >/dev/null 2>&1; then
echo "mkfs.ext4 not installed; cannot test ext4."
exit 99
fi
"@builddir@/grub-fs-tester" ext2_old
"@builddir@/grub-fs-tester" ext2
"@builddir@/grub-fs-tester" ext3
"@builddir@/grub-fs-tester" ext4
"@builddir@/grub-fs-tester" ext4_metabg
"@builddir@/grub-fs-tester" ext4_encrypt
@@ -0,0 +1,19 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.f2fs >/dev/null 2>&1; then
echo "mkfs.f2fs not installed; cannot test f2fs."
exit 99
fi
"@builddir@/grub-fs-tester" f2fs
@@ -0,0 +1,22 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.vfat >/dev/null 2>&1; then
echo "mkfs.vfat not installed; cannot test FAT."
exit 99
fi
"@builddir@/grub-fs-tester" vfat16a
"@builddir@/grub-fs-tester" vfat12a
"@builddir@/grub-fs-tester" vfat12
"@builddir@/grub-fs-tester" vfat16
"@builddir@/grub-fs-tester" vfat32
@@ -0,0 +1,52 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2013 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"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different
*-emu)
exit 77;;
# PLATFORM: Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 77;;
# FIXME: currently grub-shell uses only -kernel for loongson
mipsel-loongson)
exit 77;;
# FIXME: We don't support EFI floppy boot in grub-mkrescue
*-efi)
exit 77;;
# FIXME: no floppy support
i386-multiboot)
exit 77;;
# FIXME: QEMU firmware crashes when trying to boot from floppy
sparc64-ieee1275)
exit 77;;
# FIXME: QEMU doesn't emulate SCSI floppies
mipsel-arc | mips-arc)
exit 77;;
# PLATFORM: powerpc doesn't boot from floppy except OldWorld Macs which we don't support anyway
powerpc-ieee1275)
exit 77;;
esac
v=$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes= -no-pad")
if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ -0,0 +1 @@
Hello, user!
@@ -0,0 +1,6 @@
trust /keys.pub
set check_signatures=enforce
cat /file.gz
cat /file.xz
cat /file.lzop
set check_signatures=
@@ -0,0 +1,76 @@
#! @BUILD_SHEBANG@
# 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 pgp"
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
@@ -0,0 +1,20 @@
#!@BUILD_SHEBANG@
cd '@srcdir@'
tdir="$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")" || exit 99
xgettext -f po/POTFILES.in -L C -o "$tdir/"skip.pot -x po/grub.pot --keyword=grub_util_info --keyword=grub_dprintf:1,2 --keyword=grub_register_command --keyword=grub_register_extcmd --keyword=grub_efiemu_resolve_symbol --keyword=grub_efiemu_register_symbol --keyword=grub_dl_load --keyword=grub_crypto_lookup_md_by_name --keyword=grub_crypto_lookup_cipher_by_name --keyword=grub_efiemu_resolve_symbol --keyword=alias --keyword=grub_ieee1275_get_property:2 --keyword=grub_ieee1275_find_device --keyword=grub_ieee1275_get_integer_property:2 --keyword=INIT_IEEE1275_COMMON:2 --keyword=grub_boot_time --keyword=grub_env_get --keyword=grub_env_set --keyword=grub_register_variable_hook --keyword=grub_fatal --keyword=__asm__ --keyword=volatile --keyword=__volatile__ --keyword=grub_error:2 --from-code=iso-8859-1
xgettext -f po/POTFILES.in -L C -o "$tdir/"skip2.pot -x po/grub.pot --keyword=volatile:2 --keyword=__volatile__:2 --keyword=grub_dprintf:2 --from-code=iso-8859-1
xgettext -f po/POTFILES.in -L C -o "$tdir/"skip3.pot -x po/grub.pot --keyword=volatile:3 --keyword=__volatile__:3 --from-code=iso-8859-1
cat po/POTFILES.in | xargs grep -hE -o "( | ){\"[a-z0-9\-]*\",[[:space:]]*('.'|[0-9]|-[0-9])," |sed "s,[[:space:]]*{\",,g;s,\"\,[[:space:]]*\('.'\|[0-9]\|-[0-9]\)\,,,g" | awk '{ print "msgid \"" $0 "\"\nmsgstr \"\"" ; }' > "$tdir/"opts.pot
cat po/POTFILES.in | xargs grep -hE -o "[[:space:]]*\.name[[:space:]]*=[[:space:]]*\"[a-zA-Z0-9 ()]*\"" |sed "s,[[:space:]]*\.name[[:space:]]*=[[:space:]]*\",,g;s,\",,g" | awk '{ print "msgid \"" $0 "\"\nmsgstr \"\"" ; }' > "$tdir/"name.pot
out="$(cat po/POTFILES.in | grep -v '\(colors.c\|lsefisystab.c\|lsefimmap.c\|lssal.c\|hdparm.c\|sendkey.c\|lsacpi.c\|lspci.c\|usbtest.c\|legacy_parse.c\|/libgcrypt/\|hfs.c\|/efi\.c$\|gnulib\|tests/\|util/ieee1275/ofpath.c\|minilzo.c\|terminfo.c\|setpci.c\|bin2h.c\|cb_timestamps.c\|grub-pe2elf.c\|getroot_[a-z]*.c\|getroot.c\|arc/init.c\|color.c\|grub-mklayout.c\|gentrigtables.c\|lzodefs.h\|lsefi.c\|cbls.c\|/zfs\.h$\|grub-macho2img.c\|syslinux_parse.c\|lvm.c\|efidisk.c\|grub-mkfont.c\|reiserfs.c\|LzmaEnc.c\)' | xgettext -f - -L C -o - -x po/grub.pot -x "$tdir/"skip.pot -x "$tdir/"skip2.pot -x "$tdir/"skip3.pot -x "$tdir/"opts.pot -x "$tdir/"name.pot -x po/exclude.pot -a --from-code=iso-8859-1)"
rm -rf "$tdir"
if [ x"$out" != x ]; then
echo "$out"
exit 1;
fi
@@ -0,0 +1,185 @@
#! @BUILD_SHEBANG@ -e
# Run all grub cryptomount tests in a Qemu instance
# Copyright (C) 2023 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/>.
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
echo "not root; cannot test cryptomount."
exit 99
fi
if ! which cryptsetup >/dev/null 2>&1; then
echo "cryptsetup not installed; cannot test cryptomount."
exit 99
fi
if ! which mkfs.vfat >/dev/null 2>&1; then
echo "mkfs.vfat not installed; cannot test cryptomount."
exit 99
fi
COMMON_OPTS='${V:+--debug=$V} --cs-opts="--pbkdf-force-iterations 1000"'
_testcase() {
local EXPECTEDRES=$1
local LOGPREFIX=$2
local res=0
local output
shift 2
# Create a subdir in TMPDIR for each testcase
_TMPDIR=$TMPDIR
TMPDIR=$TMPDIR/`echo -n "$(date +%s).$LOGPREFIX" | sed -e 's,[ /],_,g' -e 's,:$,,g'`
mkdir -p "$TMPDIR"
output=`"$@" 2>&1` || res=$?
TMPDIR=$_TMPDIR
if [ "$res" -eq "$EXPECTEDRES" ]; then
if [ "$res" -eq 0 ]; then
echo $LOGPREFIX PASS
else
echo $LOGPREFIX XFAIL
fi
else
echo "Error[$res]: $output"
if [ "$res" -eq 0 ]; then
echo $LOGPREFIX XPASS
elif [ "$res" -eq 1 ]; then
echo $LOGPREFIX FAIL
else
# Any exit code other than 1 or 0, indicates a hard error,
# not a test error
echo $LOGPREFIX ERROR
return 99
fi
return 1
fi
}
testcase() { _testcase 0 "$@"; }
testcase_fail() { _testcase 1 "$@"; }
### LUKS1 tests
eval testcase "'LUKS1 test cryptsetup defaults:'" \
@builddir@/grub-shell-luks-tester --luks=1 $COMMON_OPTS
eval testcase "'LUKS1 test with twofish cipher:'" \
@builddir@/grub-shell-luks-tester --luks=1 $COMMON_OPTS \
"--cs-opts='--cipher twofish-xts-plain64'"
eval testcase "'LUKS1 test key file support:'" \
@builddir@/grub-shell-luks-tester --luks=1 $COMMON_OPTS \
--keyfile
eval testcase "'LUKS1 test key file with offset:'" \
@builddir@/grub-shell-luks-tester --luks=1 $COMMON_OPTS \
--keyfile --cs-opts="--keyfile-offset=237"
eval testcase "'LUKS1 test key file with offset and size:'" \
@builddir@/grub-shell-luks-tester --luks=1 $COMMON_OPTS \
--keyfile "--cs-opts='--keyfile-offset=237 --keyfile-size=1023'"
eval testcase "'LUKS1 test detached header support:'" \
@builddir@/grub-shell-luks-tester --luks=1 $COMMON_OPTS \
--detached-header
eval testcase "'LUKS1 test both detached header and key file:'" \
@builddir@/grub-shell-luks-tester --luks=1 $COMMON_OPTS \
--keyfile --detached-header
### LUKS2 tests (mirroring the LUKS1 tests above)
LUKS2_COMMON_OPTS="--luks=2 --cs-opts=--pbkdf=pbkdf2"
eval testcase "'LUKS2 test cryptsetup defaults:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS
eval testcase "'LUKS2 test with twofish cipher:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS \
"--cs-opts='--cipher twofish-xts-plain64'"
eval testcase "'LUKS2 test key file support:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS \
--keyfile
eval testcase "'LUKS2 test key file with offset:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS \
--keyfile --cs-opts="--keyfile-offset=237"
eval testcase "'LUKS2 test key file with offset and size:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS \
--keyfile "--cs-opts='--keyfile-offset=237 --keyfile-size=1023'"
eval testcase "'LUKS2 test detached header support:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS \
--detached-header
eval testcase "'LUKS2 test both detached header and key file:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS \
--keyfile --detached-header
### LUKS1 specific tests
# Tests for xts-plain and xts-plain64 modes
eval testcase "'LUKS1 test cryptsetup xts-plain:'" \
@builddir@/grub-shell-luks-tester --luks=1 $COMMON_OPTS \
"--cs-opts='--cipher aes-xts-plain'"
eval testcase "'LUKS1 test cryptsetup xts-plain64:'" \
@builddir@/grub-shell-luks-tester --luks=1 $COMMON_OPTS \
"--cs-opts='--cipher aes-xts-plain64'"
### LUKS2 specific tests
eval testcase "'LUKS2 test with 1k sector size:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS \
"--cs-opts='--sector-size 1024'"
eval testcase "'LUKS2 test with 2k sector size:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS \
"--cs-opts='--sector-size 2048'"
eval testcase "'LUKS2 test with 4k sector size:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS \
"--cs-opts='--sector-size 4096'"
eval testcase "'LUKS2 test with non-default key slot:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS \
"--cs-opts='--key-slot 5'"
eval testcase "'LUKS2 test with different metadata size:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS \
"--cs-opts='--luks2-metadata-size 512k'"
# TODO: Expect a failure with LUKS2 volumes with argon2 key derivation
eval testcase_fail "'LUKS2 test with argon2 pbkdf:'" \
@builddir@/grub-shell-luks-tester --luks=2 $COMMON_OPTS \
"--cs-opts='--pbkdf-memory 32'" "--cs-opts='--pbkdf-parallel 1'"
# Add good password to second slot and change first slot to unchecked password
csscript=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 99
cat >$csscript <<'EOF'
CSOPTS="--pbkdf-force-iterations 1000 --pbkdf=pbkdf2"
cryptsetup $CSOPTS --key-file $lukskeyfile luksAddKey $luksdiskfile $lukskeyfile
echo "newpass" | cryptsetup $CSOPTS --key-file $lukskeyfile --key-slot 0 luksChangeKey $luksdiskfile
EOF
eval testcase "'LUKS2 test with second key slot and first slot using different password:'" \
@builddir@/grub-shell-luks-tester $LUKS2_COMMON_OPTS $COMMON_OPTS \
"--cs-script='$csscript'"
exit 0
@@ -0,0 +1,30 @@
#! @BUILD_SHEBANG@
set -e
. "@builddir@/grub-core/modinfo.sh"
# FIXME: OpenBIOS on sparc64 doesn't implement RTC
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = sparc64-ieee1275 ]; then
exit 77
fi
pdt="$(date -u +%s)"
dt="$(echo date | @builddir@/grub-shell)"
dt="$(echo "$dt" | sed 's, [A-Z][a-z]*$,,')"
dtg="$(date -u -d "$dt" +%s)"
ndt="$(date -u +%s)"
if [ $pdt -gt $dtg ] || [ $dtg -gt $ndt ]; then
echo "Date not in range: $pdt <= $dtg <= $ndt"
exit 1
fi
pdt="$(date -u +%s)"
dt=`echo 'insmod datehook; echo $YEAR-$MONTH-$DAY $HOUR:$MINUTE:$SECOND' | @builddir@/grub-shell`
dtg="$(date -u -d "$dt" +%s)"
ndt="$(date -u +%s)"
if [ $pdt -gt $dtg ] || [ $dtg -gt $ndt ]; then
echo "Date not in range: $pdt <= $dtg <= $ndt"
exit 1
fi
@@ -0,0 +1,41 @@
#! @builddir@/grub-shell-tester
#
# Copyright (C) 2010 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/>.
echo
echo -n
echo foo
echo foo bar
echo -n foo
echo -e "foo\nbar"
echo -n -e "foo\nbar"
echo foo -n
echo foo -n -e
echo -------
if test -n "$grubshell"; then insmod regexp; fi
echo '*'
echo "*"
foo="*"
echo "$foo"
@@ -0,0 +1,42 @@
#! @BUILD_SHEBANG@
set -e
# Run GRUB script in a Qemu instance
# Copyright (C) 2010 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/>.
cmd='regexp -s version "vm-(.*)" vm-1.2.3; echo $version'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != 1.2.3; then echo "error: $cmd" >&2; exit 1; fi
cmd='regexp -s 1:version "vm-(.*)" vm-1.2.3; echo $version'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != 1.2.3; then echo "error: $cmd" >&2; exit 1; fi
cmd='regexp -s 0:match "vm-(.*)" vm-1.2.3; echo $match'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != vm-1.2.3; then echo "error: $cmd" >&2; exit 1; fi
cmd='regexp -s 2:match "vm-(.*)" vm-1.2.3; echo $match'
v=`echo "$cmd" | @builddir@/grub-shell`
if test -n "$v"; then echo "error: $cmd" >&2; exit 1; fi
cmd='regexp -s match "\\\((.*)\\\)" (hd0,msdos1); echo $match'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != "hd0,msdos1"; then echo "error: $cmd" >&2; exit 1; fi
cmd='regexp -s match "hd([0-9]+)" hd0; echo $match'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != "0"; then echo "error: $cmd" >&2; exit 1; fi
@@ -0,0 +1,35 @@
#! @BUILD_SHEBANG@
set -e
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# FIXME: OpenBIOS on sparc64 doesn't implement RTC
sparc64-ieee1275)
exit 77;;
# PLATFORM: ARC doesn't provide any way to set time
*-arc)
exit 77;;
# PLATFORM: EMU doesn't provide any way to set time
# Even if it did we'd need some kind of sandbox to avoid
# modifying real system time.
*-emu)
exit 77;;
esac
out=$(cat <<EOF | @builddir@/grub-shell
insmod datehook
date
if [ \$YEAR = 2004 -a \$MONTH = 4 -a \$DAY = 4 -a \$HOUR = 20 -a \$MINUTE = 47 ]; then
hello
halt
fi
date 2004-04-04 20:47:00
reboot
EOF
)
if [ "$(echo "$out" | tail -n 1)" != "Hello World" ]; then
echo "Test failed: $out"
exit 1
fi
@@ -0,0 +1,25 @@
#! @BUILD_SHEBANG@
set -e
. "@builddir@/grub-core/modinfo.sh"
# FIXME: OpenBIOS on sparc64 doesn't implement RTC
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = sparc64-ieee1275 ]; then
exit 77
fi
# Compare RTC with interval timer.
# Not 100% proper but should check that timer is running ok
dt=`echo 'date; sleep 10; date' | @builddir@/grub-shell`
dt1="$(date -u -d "$(echo "$dt" | head -n 1 | sed 's, [A-Z][a-z]*$,,')" +%s)"
dt2="$(date -u -d "$(echo "$dt" | tail -n 1 | sed 's, [A-Z][a-z]*$,,')" +%s)"
# Ignore QEMU bug
if [ "${grub_modinfo_target_cpu}" = arm ] && [ $((dt2 - dt1)) -ge 15 ] && [ $((dt2 - dt1)) -le 17 ]; then
exit 0;
fi
if [ $((dt2 - dt1)) -gt 11 ] || [ $((dt2 - dt1)) -lt 9 ]; then
echo "Interval not in range $dt2-$dt1 != 10"
exit 1
fi
@@ -0,0 +1,68 @@
#! @BUILD_SHEBANG@
set -e
# create a randome file
empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
non_empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
cat >$non_empty <<EOF
hello world!
EOF
. "@builddir@/grub-core/modinfo.sh"
if [ x"${grub_modinfo_platform}" = xemu ]; then
grub_empty="(host)$empty"
grub_non_empty="(host)$non_empty"
grub_dir="(host)${TMPDIR:-/tmp}"
else
grub_empty="/boot/empty"
grub_non_empty="/boot/non_empty"
grub_dir="/boot/grub"
fi
outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
@builddir@/grub-shell --files=$grub_empty=$empty --files=$grub_non_empty=$non_empty>$outfile <<EOF
if ! test -f $grub_empty; then
echo FAIL1
fi
if ! test -e $grub_empty; then
echo FAIL2
fi
if test -d $grub_empty; then
echo FAIL3
fi
if ! test -d $grub_dir; then
echo FAIL4
fi
if test -s $grub_empty; then
echo FAIL5
fi
if ! test -s $grub_non_empty; then
echo FAIL6
fi
if test -f $grub_empty -a foo = bar; then
echo FAIL7
fi
if test -e $grub_empty -a foo = bar; then
echo FAIL8
fi
if test -s $grub_non_empty -a foo = bar; then
echo FAIL9
fi
if test -d $grub_dir -a foo = bar; then
echo FAIL10
fi
EOF
rm -f "$empty" "$non_empty"
if grep FAIL "$outfile" > /dev/null 2>&1; then
echo "GRUB test command file tests failed."
cat "$outfile"
exit 1
else
rm -f "${outfile}"
exit 0
fi
@@ -0,0 +1,62 @@
#! @BUILD_SHEBANG@ -e
# Run GRUB script in a Qemu instance
# Copyright (C) 2010 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/>.
#
# Translating a string argument
#
cmd='tr 12345 abcde a1b2c3d4e5'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != aabbccddee; then echo "error: $cmd [$v]" >&2; exit 1; fi
cmd='tr -U abcdABCD'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != ABCDABCD; then echo "error: $cmd [$v]" >&2; exit 1; fi
cmd='tr -D ABCDabcd'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != abcdabcd; then echo "error: $cmd [$v]" >&2; exit 1; fi
#
# Translating a variable value
#
cmd='foo=12345678; tr -s foo 1234 abcd; echo $foo'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != abcd5678; then echo "error: $cmd [$v]" >&2; exit 1; fi
cmd='foo=abcdEFGH; tr -U -s foo; echo $foo'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != ABCDEFGH; then echo "error: $cmd [$v]" >&2; exit 1; fi
cmd='foo=abcdEFGH; tr -D -s foo; echo $foo'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != abcdefgh; then echo "error: $cmd [$v]" >&2; exit 1; fi
#
# Setting a variable from string argument
#
cmd='foo=12345678; tr -s foo 1234 abcd a1b2c3d4e5; echo $foo'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != aabbccdde5; then echo "error: $cmd [$v]" >&2; exit 1; fi
cmd='foo=abcdEFGH; tr -U -s foo xyz; echo $foo'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != XYZ; then echo "error: $cmd [$v]" >&2; exit 1; fi
cmd='foo=abcdEFGH; tr -D -s foo XYZ; echo $foo'
v=`echo "$cmd" | @builddir@/grub-shell`
if test "$v" != xyz; then echo "error: $cmd [$v]" >&2; exit 1; fi
@@ -0,0 +1,28 @@
#! @BUILD_SHEBANG@
set -e
. "@builddir@/grub-core/modinfo.sh"
if [ ! -e "@builddir@/"unicode.pf2 ]; then
echo "Functional test requires grub-mkfont support"
exit 99
fi
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Max RAM is 256M
mips-qemu_mips | mipsel-qemu_mips)
mem=256M;;
loongarch64-efi)
mem=3G;;
*)
mem=512M;;
esac
# Increase memory as some of tests are high-resolution and need a lot of memory.
out=`echo all_functional_test | @builddir@/grub-shell --timeout=3600 --files="/boot/grub/fonts/unicode.pf2"="@builddir@/"unicode.pf2 --qemu-opts="-m $mem"`
if [ "$(echo "$out" | tail -n 1)" != "ALL TESTS PASSED" ]; then
echo "Functional test failure: $out"
exit 1
fi
@@ -0,0 +1,15 @@
#! @BUILD_SHEBANG@
set -e
@builddir@/grub-script-check <<EOF
# comment 1
command1 arg1
command2 arg2
last command
# comment 2
EOF
@@ -0,0 +1,42 @@
#! @BUILD_SHEBANG@
set -e
# Run GRUB script in a Qemu instance
# Copyright (C) 2010 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/>.
error_if_not () {
if test "$1" != "$2"; then
echo "[$1]" != "[$2]"
exit 1
fi
}
cmd='test_blockarg { true }'
v=`echo "$cmd" | @builddir@/grub-shell`
error_if_not "$v" '{ true }'
tmp=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 99
cmd='test_blockarg { test_blockarg { true } }'
echo "$cmd" | @builddir@/grub-shell >$tmp
error_if_not "`head -n1 $tmp|tail -n1`" '{ test_blockarg { true } }'
error_if_not "`head -n2 $tmp|tail -n1`" '{ true }'
cmd='test_blockarg { test_blockarg { test_blockarg { true } }; test_blockarg { true } }'
echo "$cmd" | @builddir@/grub-shell >$tmp
error_if_not "`head -n1 $tmp|tail -n1`" '{ test_blockarg { test_blockarg { true } }; test_blockarg { true } }'
error_if_not "`head -n2 $tmp|tail -n1`" '{ test_blockarg { true } }'
error_if_not "`head -n3 $tmp|tail -n1`" '{ true }'
error_if_not "`head -n4 $tmp|tail -n1`" '{ true }'
@@ -0,0 +1,86 @@
#! @builddir@/grub-shell-tester
#
# Copyright (C) 2010 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/>.
# break without any arguments
for i in 1 2 3 4 5 6 7 8 9 10
do
echo $i
if test "$i" = 5
then
break
fi
done
# break with one
for i in 1 2 3 4 5 6 7 8 9 10
do
echo $i
if test "$i" = 5
then
break 1
fi
done
# break with loop count
for i in 1 2 3 4 5
do
for j in a b c d e f
do
echo "$i $j"
if test "$i" = 3
then
if test "$j" = d
then
break 2
fi
fi
done
done
# break into middle loop
for i in 1 2 3 4 5
do
for j in a b c d e f
do
echo "$i $j"
if test "$i" = 3
then
if test "$j" = d
then
break 1
fi
fi
done
done
# while and until loops
a=
while test "$a" != "aaaaaaa"
do
a="a$a"
for i in 1 2 3 4
do
b=
until test "$b" = "bbbbb"
do
b="b$b"
echo "$a $i $b"
if test "$i" = 3; then echo "break 2"; break 2; fi
done
done
done
@@ -0,0 +1,28 @@
#! @builddir@/grub-shell-tester
#
# Copyright (C) 2010 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/>.
echo a###b
echo a# #b
echo #
echo \#
echo '#'
echo "#"
echo '\#'
echo "\#"
@@ -0,0 +1,86 @@
#! @builddir@/grub-shell-tester
#
# Copyright (C) 2010 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/>.
# continue without any arguments
for i in 1 2 3 4 5 6 7 8 9 10
do
if test "$i" = 5
then
continue
fi
echo $i
done
# continue with one
for i in 1 2 3 4 5 6 7 8 9 10
do
if test "$i" = 5
then
continue 1
fi
echo $i
done
# continue with loop count
for i in 1 2 3 4 5
do
for j in a b c d e f
do
if test "$i" = 3
then
if test "$j" = d
then
continue 2
fi
echo "$i $j"
fi
done
done
# continue into middle loop
for i in 1 2 3 4 5
do
for j in a b c d e f
do
if test "$i" = 3
then
if test "$j" = d
then
continue 1
fi
echo "$i $j"
fi
done
done
# while and until loops
a=
while test "$a" != "aaaaaaa"
do
a="a$a"
for i in 1 2 3 4
do
b=
until test "$b" = "bbbbb"
do
b="b$b"
if test "$i" = 3; then echo "continue 2"; continue 2; fi
echo "$a $i $b"
done
done
done
@@ -0,0 +1,6 @@
#! @BUILD_SHEBANG@
set -e
@builddir@/grub-script-check << EOF
echo "\\\$"
EOF
@@ -0,0 +1,183 @@
#! @builddir@/grub-shell-tester
# Run GRUB script in a Qemu instance
# Copyright (C) 2010 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/>.
# simple arguments
echo one two three
echo "one two three"
echo 'one two three'
echo "one two three"
echo "one two three"
echo "one two three"
# empty arguments
echo a "" b
echo a '' b
echo a $foo b
echo a ${foo} b
echo a "$foo" b
echo a "${foo}" b
# multi-part arguments
echo one"two"three
echo one${two}three
echo one"two"$three
echo one'two'three
echo one${two}three
echo one'two'$three
echo one'two'three"four"five${six}seven$eight
foo=bar
echo $foo ${foo}
echo "$foo" "${foo}"
echo '$foo' '${foo}'
echo a$foob a${foo}b
echo ab"cd"ef$foo'gh'ij${foo}kl\ mn\"op\'qr\$st\(uv\<wx\>yz\)
foo=c
bar=h
echo e"$foo"${bar}o
e"$foo"${bar}o hello world
foo=echo
$foo 1234
echo "one
"
echo "one
\""
echo "one
two"
echo one"two
"three
echo one"two
\""three
echo one"two
\"three\"
four"
echo 'one
'
echo 'one
\'
echo 'one
two'
echo one'two
'
echo one'two
\'
echo one'two
\'three
echo "one\
"
echo "one\
\""
echo "one\
two"
# echo "one\
# two"
# echo 'one\
# two'
# echo foo\
# bar
# \
# echo foo
# echo "one
#
# two"
echo "one
"
echo "one
\""
echo "one
two"
echo one"two
"three
echo one"two
\""three
echo one"two
\"three\"
four"
echo 'one
'
echo 'one
\'
echo 'one
two'
echo one'two
'
echo one'two
\'
echo one'two
\'three
echo "one\
"
echo "one\
\""
echo "one\
two"
echo one \
two
echo one x\
two
echo one x\
"x" two
echo one x\
'x' two
echo one x\
\\ two
echo one x\
\
x
echo one x\
echo one x\
;
echo one x\
$var
if test x$grubshell = xyes; then insmod regexp; fi
echo /boot/grub/i386-pc/normal.mod
echo x\\y
echo x\*y
echo x\\
echo x\\\\
echo x\\\\y
@@ -0,0 +1,3 @@
#! @builddir@/grub-shell-tester
echo if then else fi for do done
@@ -0,0 +1,18 @@
#! @builddir@/grub-shell-tester
x=1\\,1
echo $x
y='$'
echo $y
z='\'
echo $z
t='\*'
echo $t
u='$'
echo $u
v='\?'
echo $v
echo \\
@@ -0,0 +1,6 @@
#! @builddir@/grub-shell-tester
eval echo "Hello world"
valname=tst
eval $valname=hi
echo $tst
@@ -0,0 +1,44 @@
#! @BUILD_SHEBANG@
set -e
# Run GRUB script in a Qemu instance
# Copyright (C) 2010 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/>.
disks=`echo ls | @builddir@/grub-shell`
disks=`echo "$disks"| grep -av '^Network protocols:$'| grep -av '^tftp http $'`
other=`echo insmod regexp\; echo \* | @builddir@/grub-shell`
for d in $disks; do
if echo "$d" |grep ',' >/dev/null; then
if echo "$other" | grep -F -- "$d" >/dev/null; then
echo "$d should not occur in * expansion" >&2
exit 1
fi
else
if ! echo "$other" | grep -F -- "$d" >/dev/null; then
echo "$d missing from * expansion" >&2
exit 1
fi
fi
done
other=`echo insmod regexp\; echo '(*)' | @builddir@/grub-shell`
for d in $disks; do
if ! echo "$other" | grep -F -- "$d" >/dev/null; then
echo "$d missing from (*) expansion" >&2
exit 1
fi
done
@@ -0,0 +1,11 @@
#! @BUILD_SHEBANG@
set -e
@builddir@/grub-script-check <<EOF
echo one;
echo one; echo two
echo one; echo two;
echo one ; echo two ;
echo one ; echo two ; echo three
echo one; echo two ; echo three;
EOF
@@ -0,0 +1,27 @@
#! @builddir@/grub-shell-tester
for x in one two 'three 3' "four 4" five six-6; do echo $x; done
for x in one two 'three 3' "four 4" five six-6
do
echo $x
done
foo="1 2"
for x in ab${foo}cd; do echo $x; done
for x in "ab${foo}cd"; do echo $x; done
a="one two three"
y=foo
echo $y
for y in $a; do
echo $y
done
echo $y
b="one two three"
for z in $b; do
echo $z
done
echo $z
@@ -0,0 +1,147 @@
#! @builddir@/grub-shell-tester
# Run GRUB script in a Qemu instance
# Copyright (C) 2010 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/>.
echo parameter count
function fcount {
echo fcount "$#"
}
fcount
fcount a
fcount a b
echo parameter count, with nesting
function ffcount {
echo ffcount "$#"
fcount
fcount a
fcount a b
}
ffcount
ffcount 1
ffcount 1 2
echo parameters
function fparam {
echo fparam 1 $1
echo fparam 2 $2
echo fparam 3 $3
}
fparam
fparam a
fparam a b
echo parameters, with nesting
function ffparam {
echo ffparam 1 $1
echo ffparam 2 $2
echo ffparam 3 $3
fparam
fparam a
fparam a b
}
ffparam
ffparam 1
ffparam 1 2
echo parameter expansion with specials
function fstar {
for f in $*
do
echo fstar $f
done
for f in aaa$*bbb
do
echo fstar $f
done
}
fstar
fstar a
fstar a "1 2"
fstar a "1 2" b
function fdqstar {
for f in "$*"
do
echo fdqstar $f
done
for f in aaa"$*"bbb
do
echo fdqstar $f
done
for f in "aaa$*bbb"
do
echo fdqstar $f
done
}
fdqstar
fdqstar a
fdqstar a "1 2"
fdqstar a "1 2" b
function fat {
for f in $@
do
echo fat $f
done
for f in aaa$@bbb
do
echo fat $f
done
}
fat
fat a
fat a "1 2"
fat a "1 2" b
fat a "1 2" b "c d"
fat a "1 2" b "c d" e
function fdqat {
for f in "$@"
do
echo fdqat $f
done
for f in aaa"$@"bbb
do
echo fdqat $f
done
for f in "aaa$@bbb"
do
echo fdqat $f
done
}
# fdqat # this case needs special handling, lets ignore till we really need it.
fdqat a
fdqat a "1 2"
fdqat a "1 2" b
fdqat a "1 2" b "c d"
fdqat a "1 2" b "c d" e
@@ -0,0 +1,69 @@
#! @builddir@/grub-shell-tester
#
# Copyright (C) 2010,2012 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/>.
echo $"foo"
echo $"foo bar"
echo -n $"foo"
echo -e $"foo\nbar"
echo -n -e $"foo\nbar"
x=5
echo $"$x"
echo $"\x\\y\$x$x\\$xx${x}x\"$x\""
echo $"$"
echo $"$,x"
echo $"one
"
echo $"one
\""
echo $"one
two"
echo one$"two
"three
echo one$"two
\""three
echo one$"two
\"three\"
four"
echo $"one\
"
echo $"one\
\""
echo $"one\
two"
echo one$"two\
"three
echo one$"two\
\""three
echo one$"two\
\"three\"\
four"
if test -n "$grubshell"; then insmod regexp; fi
echo $"*"
foo="*"
echo $"$foo"
@@ -0,0 +1,31 @@
#! @builddir@/grub-shell-tester
#basic if, execute
if true; then echo yes; fi
#basic if, no execution
if false; then echo no; fi
#if else, execute if path
if true; then echo yes; else echo no; fi
#if else, execute else path
if false; then echo no; else echo yes; fi
#if elif, execute elif
if false; then echo no; elif true; then echo yes; fi
#if elif else, execute else
if false; then echo no; elif false; then echo no; else echo yes; fi
#if elif(1) elif(2), execute elif(2)
if false; then echo no; elif false; then echo no; elif true; then echo yes; fi
#if elif(1) elif(2) else, execute else
if false; then echo no; elif false; then echo no; elif false; then echo no; else echo yes; fi
#if {if elif else}, execute elif
if true; then if false; then echo no; elif true; then echo yes; else echo no; fi; fi
#if {if elif} else, execute elif. ofcourse no dangling-else problem due to "fi"
if true; then if false; then echo no; elif true; then echo yes; fi; else echo no; fi
@@ -0,0 +1,4 @@
#! @builddir@/grub-shell-tester
list=" 1 2 3"
echo $list
@@ -0,0 +1,21 @@
#! @BUILD_SHEBANG@
set -e
# grub-script-check refuses to pass a file with no commands; this usually
# indicates a bug in the code generating that file.
@builddir@/grub-script-check <<EOF && exit 1
EOF
@builddir@/grub-script-check <<EOF && exit 1
# comment
EOF
@builddir@/grub-script-check <<EOF && exit 1
# comment 1
# comment 2
EOF
exit 0
@@ -0,0 +1,62 @@
#! @builddir@/grub-shell-tester
#
# Copyright (C) 2010 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/>.
true
echo $?
! true
echo $?
false
echo $?
! false
echo $?
#
# Negated forms (copied from grub_script_if.in)
#
#basic if, execute
if ! true; then echo yes; fi
#basic if, no execution
if ! false; then echo no; fi
#if else, execute if path
if ! true; then echo yes; else echo no; fi
#if else, execute else path
if ! false; then echo no; else echo yes; fi
#if elif, execute elif
if ! false; then echo no; elif ! true; then echo yes; fi
#if elif else, execute else
if ! false; then echo no; elif ! false; then echo no; else echo yes; fi
#if elif(1) elif(2), execute elif(2)
if false; then echo no; elif ! false; then echo no; elif ! true; then echo yes; fi
#if elif(1) elif(2) else, execute else
if false; then echo no; elif false; then echo no; elif ! false; then echo no; else echo yes; fi
#if {if elif else}, execute elif
if true; then if false; then echo no; elif ! true; then echo yes; else echo no; fi; fi
#if {if elif} else, execute elif. ofcourse no dangling-else problem due to "fi"
if true; then if ! false; then echo no; elif true; then echo yes; fi; else echo no; fi
@@ -0,0 +1,134 @@
#! @builddir@/grub-shell-tester
# Run GRUB script in a Qemu instance
# Copyright (C) 2010 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/>.
function f1 {
return
echo one
}
f1
function f2 {
true
return
echo one
}
if f2; then echo true; else echo false; fi
function f3 {
false
return
echo one
}
if f3; then echo true; else echo false; fi
function f4 {
true
return 1;
echo one
}
if f4; then echo true; else echo false; fi
function f5 {
false
return 0;
echo one
}
if f5; then echo true; else echo false; fi
function f6 {
echo one
if true; then
echo two
return 0
else
echo three
return 1
fi
echo four
}
if f6; then echo true; else echo false; fi
function f7 {
if return 1; then
echo one
else
echo no
fi
}
if f7; then echo true; else echo false; fi
function f8 {
echo one
for v in 1 2 3 4 5; do
echo $v
if test $v = 3; then return 1; fi
done
echo two
}
if f8; then echo true; else echo false; fi
function f9 {
x=1
echo one
until test x = 11111111; do
echo $x
x="1$x"
if test $x = 1111; then return 0; fi
done
echo two
}
if f9; then echo true; else echo false; fi
function f10 {
echo one
while return 0; do
echo two
done
echo three
}
if f10; then echo true; else echo false; fi
function f11 {
f1
f2
f3
f4
f5
f6
f7
f8
f9
f10
}
if f11; then echo true; else echo false; fi
function f12 {
echo one
f11
return 1
echo two
}
if f12; then echo true; else echo false; fi
function f13 {
echo one
f12
echo two
return 0
}
if f13; then echo true; else echo false; fi
@@ -0,0 +1,59 @@
#! @builddir@/grub-shell-tester
# Run GRUB script in a Qemu instance
# Copyright (C) 2010 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/>.
if test x$grubshell = xyes; then cmd=setparams; else cmd=set; fi
function f1 {
echo $#
echo "$#"
echo $@
echo "$@"
echo $*
echo "$*"
echo $1 $2
for v in "$@"; do echo $v; done
shift
echo $1 $2
for v in "$@"; do echo $v; done
$cmd 1 2 3 4
echo $#
echo "$#"
echo $@
echo "$@"
echo $*
echo "$*"
echo $1 $2
for v in "$@"; do echo $v; done
shift
echo $1 $2
for v in "$@"; do echo $v; done
}
# f1
# f1 a
f1 a b
f1 a b c
f1 a b c d
f1 a b c d e
@@ -0,0 +1,85 @@
#! @builddir@/grub-shell-tester
# Run GRUB script in a Qemu instance
# Copyright (C) 2010 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/>.
function f1 {
echo f1 '$@' $@
echo f1 '$*' $*
echo f1 $# $1 $2 $3
shift
echo f1 '$@' $@
echo f1 '$*' $*
echo f1 $# $1 $2 $3
}
f1
f1 a
f1 a b
f1 a b c
f1 a b c d
f1 a b c d e
function f2 {
echo f1 '$@' $@
echo f1 '$*' $*
echo f2 $# $1 $2 $3
shift 1
echo f1 '$@' $@
echo f1 '$*' $*
echo f2 $# $1 $2 $3
}
f2
f2 a
f2 a b
f2 a b c
f2 a b c d
f2 a b c d e
function f3 {
echo f1 '$@' $@
echo f1 '$*' $*
echo f3 $# $1 $2 $3
shift 3
echo f1 '$@' $@
echo f1 '$*' $*
echo f3 $# $1 $2 $3
}
f3
f3 a
f3 a b
f3 a b c
f3 a b c d
f3 a b c d e
function f4 {
echo f1 '$@' $@
echo f1 '$*' $*
echo f4 $# $1 $2 $3
shift 100
echo f1 '$@' $@
echo f1 '$*' $*
echo f4 $# $1 $2 $3
}
f4
f4 a
f4 a b
f4 a b c
f4 a b c d
f4 a b c d e
@@ -0,0 +1,22 @@
#! @builddir@/grub-shell-tester
#
# Copyright (C) 2012 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/>.
LC_ALL=C
export LC_ALL
if [ "z" "<" "â" ]; then echo unsigned; else echo signed; fi
if [ "z" ">" "â" ]; then echo signed; else echo unsigned; fi
@@ -0,0 +1,15 @@
#! @builddir@/grub-shell-tester
for device in 'hd0' 'fd0'; do
# But search them if their search has been inforced
set fd0search="no"
if [ "$device" != "fd0" -a "$device" != "cd" \
-o \
"$device" = "fd0" -a "$fd0search" = "yes" ]\
; then
echo "Yes"
else
echo "No"
fi
done
@@ -0,0 +1,34 @@
#! @builddir@/grub-shell-tester
# Run GRUB script in a Qemu instance
# Copyright (C) 2010 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/>.
var=foo
echo $var
echo "$var"
echo ${var}
echo "${var}"
echo $1 $2 $?
foo=foo
echo "" $foo
echo $bar $foo
bar=""
echo $bar $foo
@@ -0,0 +1,32 @@
#! @builddir@/grub-shell-tester
echo one
foo=""
while test "$foo" != "1111"; do foo="${foo}1"; echo "$foo"; done
echo two
foo=""
while test "$foo" != "aaaa"
do
foo="${foo}a"
echo $foo
done
foo=""
until test "$foo" = "1111"; do foo="${foo}1"; echo $foo; done
foo=""
until test "$foo" = "aaaa"
do
foo="${foo}a"
echo $foo
done
# check "$?" in condition gets its value from while body commands
foo=""
false
while test "$?" != "0"
do
echo $foo
foo="${foo}1"
test "$foo" = "111111"
done
@@ -0,0 +1,30 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2013 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"
if ! which gzip >/dev/null 2>&1; then
echo "gzip not installed; cannot test gzip compression."
exit 99
fi
v=$(echo hello | "${grubshell}" --mkrescue-arg=--compress=gz)
if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ -0,0 +1,38 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2013 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"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different
*-emu)
exit 77;;
# PLATFORM: Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 77;;
# FIXME: currently grub-shell uses only -kernel for loongson
mipsel-loongson)
exit 77;;
esac
v=$(echo hello | "${grubshell}" --boot=hd)
if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ -0,0 +1,19 @@
#! @BUILD_SHEBANG@
set -e
. "@builddir@/grub-core/modinfo.sh"
template="Usage: help [PATTERN ...]
Show a help message.
-h, --help Display this help and exit.
-u, --usage Display the usage of this command and exit.
To enable less(1)-like paging, \"set pager=1\".
Hello World"
output="$(echo 'help help; hello' | @builddir@/grub-shell)"
if [ "$template" != "$output" ]; then
exit 1
fi
@@ -0,0 +1,23 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.hfs >/dev/null 2>&1; then
echo "mkfs.hfs not installed; cannot test HFS."
exit 99
fi
if ! grep -q mac_roman /proc/modules && ! modprobe mac_roman; then
echo "no mac-roman support; cannot test HFS."
exit 99
fi
"@builddir@/grub-fs-tester" hfs
@@ -0,0 +1,20 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.hfsplus >/dev/null 2>&1; then
echo "mkfs.hfsplus not installed; cannot test hfsplus."
exit 99
fi
"@builddir@/grub-fs-tester" hfsplus
"@builddir@/grub-fs-tester" hfsplus_casesens
"@builddir@/grub-fs-tester" hfsplus_wrap
@@ -0,0 +1,53 @@
#!@BUILD_SHEBANG@
set -e
if ! which xorriso >/dev/null 2>&1; then
echo "xorriso not installed; cannot test iso9660."
exit 99
fi
"@builddir@/grub-fs-tester" joliet
"@builddir@/grub-fs-tester" rockridge
"@builddir@/grub-fs-tester" rockridge_joliet
"@builddir@/grub-fs-tester" joliet_1999
"@builddir@/grub-fs-tester" rockridge_1999
"@builddir@/grub-fs-tester" rockridge_joliet_1999
echo "Testing for proper recognition of CE loops ... "
for fs in iso9660_ce_loop iso9660_ce_loop2; do
tempdir=`mktemp -d "${TMPDIR:-/tmp}/${0##*/}.$(date '+%Y%m%d%H%M%S%N').${fs}.XXX"` ||
{ echo "Failed to make temporary directory"; exit 99; }
gunzip <"$srcdir"/tests/${fs}.iso.gz >"${tempdir}/${fs}.iso" || exit 99
output=$(LC_ALL=C timeout -s KILL "60" \
"@builddir@/grub-fstest" "${tempdir}/${fs}.iso" ls / ) || ret=$?
rm -rf "$tempdir"
if [ "${ret:-0}" -ne 0 -o -n "$output" ]; then
echo "FAIL ($fs)"
exit 1
fi
done
echo "PASS"
echo "Testing for proper handling of early CE ... "
fs=iso9660_early_ce
tempdir=`mktemp -d "${TMPDIR:-/tmp}/${0##*/}.$(date '+%Y%m%d%H%M%S%N').${fs}.XXX"` ||
{ echo "Failed to make temporary directory"; exit 99; }
gunzip <"$srcdir"/tests/${fs}.iso.gz >"${tempdir}/${fs}.iso" || exit 99
ret=0
output=$(LC_ALL=C timeout -s KILL "60" \
"@builddir@/grub-fstest" "${tempdir}/${fs}.iso" ls / ) || ret=$?
rm -rf "$tempdir"
if [ "${ret:-0}" -ne 0 ]; then
echo "... grub-fstest returns $ret"
echo "FAIL ($fs)"
exit 1
fi
# Before comparing: remove trailing blank added by grub-fstest
output=$(echo -n $output)
if [ x"$output" != x"RockRidgeName:x" ]; then
echo "... found: '$output' , expected: 'RockRidgeName:x'"
echo "FAIL ($fs)"
exit 1
fi
echo "PASS"
@@ -0,0 +1,18 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.jfs >/dev/null 2>&1; then
echo "mkfs.jfs not installed; cannot test JFS."
exit 99
fi
"@builddir@/grub-fs-tester" jfs
@@ -0,0 +1,42 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 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/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <grub/list.h>
#include <grub/test.h>
int
main (int argc __attribute__ ((unused)),
char *argv[] __attribute__ ((unused)))
{
int status = 0;
grub_test_t test;
grub_unit_test_init ();
FOR_LIST_ELEMENTS (test, grub_test_list)
status = grub_test_run (test) ? : status;
grub_unit_test_fini ();
exit (status);
}
@@ -0,0 +1,23 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.ext2 >/dev/null 2>&1; then
echo "mkfs.ext2 not installed; cannot test luks."
exit 99
fi
if ! which cryptsetup >/dev/null 2>&1; then
echo "cryptsetup not installed; cannot test luks."
exit 99
fi
"@builddir@/grub-fs-tester" luks1
@@ -0,0 +1,23 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.ext2 >/dev/null 2>&1; then
echo "mkfs.ext2 not installed; cannot test luks2."
exit 99
fi
if ! which cryptsetup >/dev/null 2>&1; then
echo "cryptsetup not installed; cannot test luks2."
exit 99
fi
"@builddir@/grub-fs-tester" luks2
@@ -0,0 +1,30 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2013 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"
if ! which lzop >/dev/null 2>&1; then
echo "lzop not installed; cannot test lzo compression."
exit 99
fi
v=$(echo hello | "${grubshell}" --mkrescue-arg=--compress=lzo)
if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ -0,0 +1,30 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.minix >/dev/null 2>&1; then
echo "mkfs.minix not installed; cannot test minixfs."
exit 99
fi
if ! mkfs.minix -h | grep -- -v > /dev/null; then
echo "mkfs.minix doesn't support minix2fs; cannot test minix*fs."
exit 99
fi
if ! mkfs.minix -h | grep -- -3 > /dev/null; then
echo "mkfs.minix doesn't support minix3fs; cannot test minix*fs."
exit 99
fi
"@builddir@/grub-fs-tester" minix
"@builddir@/grub-fs-tester" minix2
"@builddir@/grub-fs-tester" minix3
@@ -0,0 +1,46 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2013 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"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different
*-emu)
exit 77;;
# PLATFORM: Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 77;;
# FIXME: currently grub-shell uses only -kernel for loongson
mipsel-loongson)
exit 77;;
# FIXME: no rtl8139 support
i386-multiboot)
exit 77;;
# FIXME: We don't fully support netboot on ARC
*-arc)
exit 77;;
# FIXME: Many QEMU firmware have no netboot capability
*-efi | i386-ieee1275 | powerpc-ieee1275 | sparc64-ieee1275)
exit 77;;
esac
v=$(echo hello | "${grubshell}" --boot=net)
if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ -0,0 +1,18 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.nilfs2 >/dev/null 2>&1; then
echo "mkfs.nilfs2 not installed; cannot test nilfs2."
exit 99
fi
"@builddir@/grub-fs-tester" nilfs2
@@ -0,0 +1,24 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.ntfs >/dev/null 2>&1; then
echo "mkfs.ntfs not installed; cannot test ntfs."
exit 99
fi
if ! which setfattr >/dev/null 2>&1; then
echo "setfattr not installed; cannot test ntfs."
exit 99
fi
"@builddir@/grub-fs-tester" ntfs
"@builddir@/grub-fs-tester" ntfscomp
@@ -0,0 +1,56 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2013 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"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
exit 77;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
exit 77;;
# PLATFORM: no USB on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
exit 77;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi | loongarch64-efi)
exit 77;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
v=$(echo "nativedisk; source '(usb0)/$outfile';" |
"${grubshell}" --qemu-opts="-device pci-ohci
-drive id=my_usb_disk,file=$imgfile,if=none
-device usb-storage,drive=my_usb_disk")
v=$(echo "$v" | tail -n 1)
if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
fi
rm "$imgfile"
rm "$outfile"
@@ -0,0 +1,491 @@
#! @BUILD_SHEBANG@
set -e
# Copyright (C) 2010 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/>.
parted=parted
grubshell=@builddir@/grub-shell
PATH="$PATH:/sbin:/usr/sbin"
. "@builddir@/grub-core/modinfo.sh"
create_disk_image () {
name="$1"
size=$2
rm -f "${name}"
dd if=/dev/zero of="${name}" bs=512 count=1 seek=$((size * 2048 - 1)) status=noxfer > /dev/null
}
create_dfly_image () {
name="$1"
rm -f ${name}
gunzip < "@srcdir@/tests/dfly-mbr-mbexample.mbr.img.gz" | dd of=${name} bs=1 seek=440 count=72 conv=notrunc > /dev/null
gunzip < "@srcdir@/tests/dfly-mbr-mbexample.dfly.img.gz" | dd of=${name} bs=512 seek=33 count=1 conv=notrunc > /dev/null
}
check_output () {
outfile=$1
shift
for dsk in $@; do
if ! grep "($dsk)" "${outfile}" >/dev/null
then
echo "($dsk): disk/partiton not found in: $(cat "${outfile}")"
exit 1
fi
done
}
list_parts () {
mod=$1;
shift;
imgfile="$1"
shift
outfile="$1"
shift
echo ls | "${grubshell}" --disk="${imgfile}" \
--modules=$mod > "${outfile}"
cat "${outfile}" | tr -d "\n\r"
echo
}
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
mips-qemu_mips | mipsel-qemu_mips | i386-qemu | i386-multiboot | i386-coreboot | mipsel-loongson)
disk=ata0
;;
powerpc-ieee1275)
disk=ieee1275//pci@80000000/mac-io@4/ata-3@20000/disk@0
# FIXME: QEMU firmware has bugs which prevent it from accessing hard disk w/o recognised label.
exit 77
;;
sparc64-ieee1275)
disk=ieee1275//pci@1fe\,0/pci-ata@5/ide0@500/disk@0
# FIXME: QEMU firmware has bugs which prevent it from accessing hard disk w/o recognised label.
exit 77
;;
i386-ieee1275)
disk=ieee1275/d
# FIXME: QEMU firmware has bugs which prevent it from accessing hard disk w/o recognised label.
exit 77
;;
mips-arc)
# FIXME: ARC firmware has bugs which prevent it from accessing hard disk w/o dvh disklabel.
exit 77 ;;
mipsel-arc)
disk=arc/scsi0/disk0/rdisk0
;;
arm*-efi)
disk=hd2
;;
*)
disk=hd0
;;
esac
if ! which ${parted} >/dev/null 2>&1; then
echo "${parted} not installed; cannot test partmap"
exit 99
fi
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
#
# MSDOS partition types
#
echo "Checking MSDOS partition types..."
# 0 primary
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel msdos
list_parts part_msdos "${imgfile}" "${outfile}"
check_output "${outfile}" $disk
# 1 primary
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel msdos mkpart primary 0 10M
list_parts part_msdos "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,msdos1
# 2 primary
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M
list_parts part_msdos "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,msdos1 $disk,msdos2
# 3 primary
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart primary 20M 30M
list_parts part_msdos "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,msdos1 $disk,msdos2 $disk,msdos3
# 4 primary
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M
list_parts part_msdos "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,msdos1 $disk,msdos2 $disk,msdos3 $disk,msdos4
# 1 primary, 1 extended
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100%
list_parts part_msdos "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,msdos1
# 1 primary, 1 extended, 1 logical
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M
list_parts part_msdos "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,msdos1 $disk,msdos5
# 1 primary, 1 extended, 2 logical
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M mkpart logical 30M 40M
list_parts part_msdos "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,msdos1 $disk,msdos5 $disk,msdos6
# 1 primary, 1 extended, 3 logical
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M mkpart logical 30M 40M mkpart logical 40M 50M
list_parts part_msdos "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,msdos1 $disk,msdos5 $disk,msdos6 $disk,msdos7
# 1 primary, 1 extended, 4 logical
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M mkpart logical 30M 40M mkpart logical 40M 50M mkpart logical 50M 60M
list_parts part_msdos "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,msdos1 $disk,msdos5 $disk,msdos6 $disk,msdos7 $disk,msdos8
#
# GPT partition types
#
echo "Checking GPT partition types..."
# 0 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel gpt
list_parts part_gpt "${imgfile}" "${outfile}"
check_output "${outfile}" $disk
# 1 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel gpt mkpart 1 0 10M
list_parts part_gpt "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,gpt1
# 2 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M
list_parts part_gpt "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,gpt1 $disk,gpt2
# 3 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 3 20M 30M
list_parts part_gpt "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,gpt1 $disk,gpt2 $disk,gpt3
# 4 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 4 20M 30M mkpart 5 30M 40M
list_parts part_gpt "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,gpt1 $disk,gpt2 $disk,gpt3 $disk,gpt4
# 5 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 3 20M 30M mkpart 4 30M 40M mkpart 5 40M 50M
list_parts part_gpt "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,gpt1 $disk,gpt2 $disk,gpt3 $disk,gpt4 $disk,gpt5
# 6 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 3 20M 30M mkpart 4 30M 40M mkpart 5 40M 50M mkpart 6 50M 60M
list_parts part_gpt "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,gpt1 $disk,gpt2 $disk,gpt3 $disk,gpt4 $disk,gpt5 $disk,gpt6
#
# SUN partition types
#
# It seems partition #3 is reserved for whole disk by parted.
#
echo "Checking SUN partition types..."
# 0 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel sun
list_parts part_sun "${imgfile}" "${outfile}"
check_output "${outfile}" $disk
# 1 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel sun mkpart 0 10M
list_parts part_sun "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,sun1
# 2 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel sun mkpart 0 10M mkpart 10M 20M
list_parts part_sun "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,sun1 $disk,sun2
# 3 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M
list_parts part_sun "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,sun1 $disk,sun2 $disk,sun4
# 4 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M
list_parts part_sun "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,sun1 $disk,sun2 $disk,sun4 $disk,sun5
# 5 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M mkpart 40M 50M
list_parts part_sun "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,sun1 $disk,sun2 $disk,sun4 $disk,sun5 $disk,sun6
# 6 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M mkpart 40M 50M mkpart 50M 60M
list_parts part_sun "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,sun1 $disk,sun2 $disk,sun4 $disk,sun5 $disk,sun6 $disk,sun7
# 7 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M mkpart 40M 50M mkpart 50M 60M mkpart 60M 70M
list_parts part_sun "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,sun1 $disk,sun2 $disk,sun4 $disk,sun5 $disk,sun6 $disk,sun7 $disk,sun8
#
# Apple partition types
#
# Partition table itself is part of some partition, so there is always
# a partition by default. Furthermore free space is also a partition,
# so there is always at least 2 partitions
#
echo "Checking APPLE partition types..."
# 0 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel mac
list_parts part_apple "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,apple1 $disk,apple2
# 1 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel mac mkpart a 1M 10M
list_parts part_apple "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,apple1 $disk,apple2 $disk,apple3
# 2 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel mac mkpart a 1M 10M mkpart b 10M 20M
list_parts part_apple "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,apple1 $disk,apple2 $disk,apple3 $disk,apple4
# 3 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M
list_parts part_apple "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,apple1 $disk,apple2 $disk,apple4 $disk,apple5
# 4 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M mkpart d 30M 40M
list_parts part_apple "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,apple1 $disk,apple2 $disk,apple4 $disk,apple5 $disk,apple6
# 5 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M mkpart d 30M 40M mkpart e 40M 50M
list_parts part_apple "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,apple1 $disk,apple2 $disk,apple4 $disk,apple5 $disk,apple6 $disk,apple7
# 6 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M mkpart d 30M 40M mkpart e 40M 50M mkpart f 50M 60M
list_parts part_apple "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,apple1 $disk,apple2 $disk,apple4 $disk,apple5 $disk,apple6 $disk,apple7 $disk,apple8
#
# DVH partition types
#
# Partition #11 is reserved for whole disk by parted.
# Parted also aliases #9 as whole disk
#
echo "Checking DVH partition types..."
# 0 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel dvh
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk
# 1 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1
# 2 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2
# 3 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3
# 4 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4
# 5 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5
# 6 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6
# 7 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7
# 8 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8
# 9 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M mkpart primary 80M 90M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8 $disk,dvh10
# 10 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M mkpart primary 80M 90M mkpart primary 90M 100M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8 $disk,dvh10 $disk,dvh12
# 11 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M mkpart primary 80M 90M mkpart primary 90M 100M mkpart primary 100M 110M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8 $disk,dvh10 $disk,dvh12 $disk,dvh13
# 12 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M mkpart primary 80M 90M mkpart primary 90M 100M mkpart primary 100M 110M mkpart primary 110M 120M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8 $disk,dvh10 $disk,dvh12 $disk,dvh13 $disk,dvh14
# 13 parts
create_disk_image "${imgfile}" 135
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M mkpart primary 80M 90M mkpart primary 90M 100M mkpart primary 100M 110M mkpart primary 110M 120M mkpart primary 120M 130M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8 $disk,dvh10 $disk,dvh12 $disk,dvh13 $disk,dvh14 $disk,dvh15
# 14 parts
create_disk_image "${imgfile}" 145
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M mkpart primary 80M 90M mkpart primary 90M 100M mkpart primary 100M 110M mkpart primary 110M 120M mkpart primary 120M 130M mkpart primary 130M 140M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8 $disk,dvh10 $disk,dvh12 $disk,dvh13 $disk,dvh14 $disk,dvh15 $disk,dvh16
echo "Checking AMIGA partition types..."
# 0 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel amiga
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk
# 1 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1
# 2 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M mkpart x 10M 20M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1 $disk,amiga2
# 3 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M mkpart x 10M 20M mkpart x 20M 30M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1 $disk,amiga2 $disk,amiga3
# 4 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M mkpart x 10M 20M mkpart x 20M 30M mkpart x 30M 40M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1 $disk,amiga2 $disk,amiga3 $disk,amiga4
# 5 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M mkpart x 10M 20M mkpart x 20M 30M mkpart x 30M 40M mkpart x 40M 50M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1 $disk,amiga2 $disk,amiga3 $disk,amiga4 $disk,amiga5
# 6 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M mkpart x 10M 20M mkpart x 20M 30M mkpart x 30M 40M mkpart x 40M 50M mkpart x 50M 60M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1 $disk,amiga2 $disk,amiga3 $disk,amiga4 $disk,amiga5 $disk,amiga6
# 7 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M mkpart x 10M 20M mkpart x 20M 30M mkpart x 30M 40M mkpart x 40M 50M mkpart x 50M 60M mkpart x 60M 70M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1 $disk,amiga2 $disk,amiga3 $disk,amiga4 $disk,amiga5 $disk,amiga6 $disk,amiga7
#
# DragonFly BSD disklabel64
#
echo "Checking DragonFly BSD disklabel64..."
create_dfly_image "${imgfile}"
list_parts part_dfly "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,msdos1 $disk,msdos1,dfly1 $disk,msdos1,dfly2 $disk,msdos1,dfly3
@@ -0,0 +1,58 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2013 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"
disk=hda
indisk=ata0
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
exit 77;;
# PLATFORM: no ATA on ARC platforms (they use SCSI)
*-arc)
exit 77;;
# QEMU: no ATA on Q35 machine type (they use AHCI)
i386-efi)
exit 77;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi | loongarch64-efi)
exit 77;;
i386-ieee1275)
disk=hdb
indisk=ata1
;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
v=$(echo "nativedisk; source '($indisk)/$outfile';" | "${grubshell}" --qemu-opts="-$disk $imgfile")
if [ "$v" != "Hello World" ]; then
rm "$outfile"
exit 1
fi
rm "$imgfile"
rm "$outfile"
@@ -0,0 +1,78 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2011 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/>.
*/
#include <stdio.h>
#include <string.h>
#include <grub/test.h>
#include <grub/misc.h>
#define MSG "printf test failed: %s, %s", real, expected
#if defined(__GNUC__) && __GNUC__ >= 7
#pragma GCC diagnostic ignored "-Wformat-truncation="
#endif
static void
printf_test (void)
{
char real[512];
char expected[512];
char *null = NULL;
grub_snprintf (real, sizeof (real), "%s", null);
snprintf (expected, sizeof (expected), "%s", null);
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%10s", null);
snprintf (expected, sizeof (expected), "%10s", null);
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%-10s", null);
snprintf (expected, sizeof (expected), "%-10s", null);
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%d%%", 10);
snprintf (expected, sizeof (expected), "%d%%", 10);
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%d %%", 10);
snprintf (expected, sizeof (expected), "%d %%", 10);
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%%");
snprintf (expected, sizeof (expected), "%%");
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%d %d %d", 1, 2, 3);
snprintf (expected, sizeof (expected), "%d %d %d", 1, 2, 3);
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%3$d %2$d %1$d", 1, 2, 3);
snprintf (expected, sizeof (expected), "%3$d %2$d %1$d", 1, 2, 3);
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%d %lld %d", 1, 2LL, 3);
snprintf (expected, sizeof (expected), "%d %lld %d", 1, 2LL, 3);
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%3$d %2$lld %1$d", 1, 2LL, 3);
snprintf (expected, sizeof (expected), "%3$d %2$lld %1$d", 1, 2LL, 3);
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%%0%dd ", 1);
snprintf (expected, sizeof (expected), "%%0%dd ", 1);
grub_test_assert (strcmp (real, expected) == 0, MSG);
}
GRUB_UNIT_TEST ("printf_unit_test", printf_test);
@@ -0,0 +1,105 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2013 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/>.
*/
#include <stdio.h>
#include <string.h>
#include <grub/test.h>
#include <grub/misc.h>
#include <grub/priority_queue.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <queue>
using namespace std;
static int
compar (const void *a_, const void *b_)
{
int a = *(int *) a_;
int b = *(int *) b_;
if (a < b)
return -1;
if (a > b)
return +1;
return 0;
}
static void
priority_queue_test (void)
{
priority_queue <int> pq;
grub_priority_queue_t pq2;
int counter;
int s = 0;
pq2 = grub_priority_queue_new (sizeof (int), compar);
if (!pq2)
{
grub_test_assert (0,
"priority queue: queue creating failed\n");
return;
}
srand (1);
for (counter = 0; counter < 1000000; counter++)
{
int op = rand () % 10;
if (s && *(int *) grub_priority_queue_top (pq2) != pq.top ())
{
printf ("Error at %d\n", counter);
grub_test_assert (0,
"priority queue: error at %d\n", counter);
return;
}
if (op < 3 && s)
{
grub_priority_queue_pop (pq2);
pq.pop ();
s--;
}
else
{
int v = rand ();
pq.push (v);
if (grub_priority_queue_push (pq2, &v) != 0)
{
grub_test_assert (0,
"priority queue: push failed");
return;
}
s++;
}
}
while (s)
{
if (*(int *) grub_priority_queue_top (pq2) != pq.top ())
{
grub_test_assert (0,
"priority queue: Error at the end. %d elements remaining.\n", s);
return;
}
grub_priority_queue_pop (pq2);
pq.pop ();
s--;
}
printf ("priority_queue: passed successfully\n");
}
GRUB_UNIT_TEST ("priority_queue_unit_test", priority_queue_test);
@@ -0,0 +1,37 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2013 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"
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" != powerpc-ieee1275 ]; then
exit 77
fi
if [ "$(echo hello | "${grubshell}" --pseries --timeout=180 --boot=cd)" != "Hello World" ]; then
exit 1
fi
if [ "$(echo hello | "${grubshell}" --pseries --timeout=180 --boot=hd)" != "Hello World" ]; then
exit 1
fi
# FIXME: workaround SLOF bugs
#if [ "$(echo hello | "${grubshell}" --pseries --timeout=180 --boot=net)" != "Hello World" ]; then
# exit 1
#fi
@@ -0,0 +1,21 @@
#!@BUILD_SHEBANG@
set -e
if [ "x$EUID" = "x" ] ; then
EUID=`id -u`
fi
if [ "$EUID" != 0 ] ; then
exit 99
fi
if ! which mkfs.reiserfs >/dev/null 2>&1; then
echo "mkfs.reiserfs not installed; cannot test reiserfs."
exit 99
fi
"@builddir@/grub-fs-tester" reiserfs
# Kernels since at least 4.15 can not mount ReiserFS filesystems of the old format.
#"@builddir@/grub-fs-tester" reiserfs_old
@@ -0,0 +1,10 @@
#!@BUILD_SHEBANG@
set -e
if ! which genromfs >/dev/null 2>&1; then
echo "genromfs not installed; cannot test romfs."
exit 99
fi
"@builddir@/grub-fs-tester" romfs
@@ -0,0 +1,55 @@
#! @BUILD_SHEBANG@
# Copyright (C) 2023 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"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different.
*-emu)
exit 77;;
# PLATFORM: Flash targets.
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 77;;
# FIXME: Currently grub-shell uses only -kernel for loongson.
mipsel-loongson)
exit 77;;
# FIXME: How do we setup serial ports in QEMU for these platforms?
*-ieee1275)
exit 77;;
esac
# Figure out the PCI device ID that the serial device will be on.
output=$(echo terminal_output | "${grubshell}" --qemu-opts="-device pci-serial")
PCIID=$(echo "$output" | grep -o "serial_pci,..:..\.." | cut -d, -f2)
if [ -z "$PCIID" ]; then
echo "Failed to find QEMU serial device." >&2
echo "${output}" >&2
exit 99
fi
# Test serial output via an emulated PCI serial card.
output=$(echo "terminal_output; hello" | \
"${grubshell}" --serial="pci,${PCIID}" \
--qemu-opts="-chardev file,path=/dev/stdout,id=ser1 -device pci-serial,chardev=ser1")
v=$(echo -e "$output" | tail -n1)
if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ -0,0 +1,12 @@
#!@BUILD_SHEBANG@
set -e
if ! which mksquashfs >/dev/null 2>&1; then
echo "mksquashfs not installed; cannot test squashfs."
exit 99
fi
"@builddir@/grub-fs-tester" squash4_gzip
"@builddir@/grub-fs-tester" squash4_xz
"@builddir@/grub-fs-tester" squash4_lzo
@@ -0,0 +1,52 @@
menu hshift 9
menu width 58
menu begin desktop
include stdmenu.cfg
menu hshift 13
menu width 49
menu label Alternative desktop environments
menu title Desktop environment menu
label mainmenu-kde
menu label ^Back..
text help
Higher level options install the GNOME desktop environment
endtext
menu exit
menu begin kde-desktop
include stdmenu.cfg
menu label ^KDE
menu title KDE desktop boot menu
text help
Select the 'K Desktop Environment' for the Desktop task
endtext
label mainmenu-kde
menu label ^Back..
menu exit
include kde/menu.cfg
menu end
menu begin lxde-desktop
include stdmenu.cfg
menu label ^LXDE
menu title LXDE desktop boot menu
text help
Select the 'Lightweight X11 Desktop Environment' for the Desktop task
endtext
label mainmenu-lxde
menu label ^Back..
menu exit
include lxde/menu.cfg
menu end
menu begin xfce-desktop
include stdmenu.cfg
menu label ^Xfce
menu title Xfce desktop boot menu
text help
Select the 'Xfce lightweight desktop environment' for the Desktop task
endtext
label mainmenu-xfce
menu label ^Back..
menu exit
include xfce/menu.cfg
menu end
menu end
@@ -0,0 +1,3 @@
label menu
kernel vesamenu.c32
config isolinux.cfg
@@ -0,0 +1,12 @@
foreground=0xFFFFFF
background=0x958490
screen-colour=0x270A1E
hidden-timeout=2
label normal=Normal
append normal=
label driverupdates=Use driver update disc
append driverupdates=debian-installer/driver-update=true
applies driverupdates=live live-install
label oem=OEM install (for manufacturers)
append oem=oem-config/enable=true
applies oem=live live-install install
@@ -0,0 +1,6 @@
# D-I config version 2.0
include menu.cfg
default vesamenu.c32
prompt 0
timeout 50
ui gfxboot bootlogo
@@ -0,0 +1,23 @@
menu hshift 13
menu width 49
menu margin 8
menu title Installer boot menu
include stdmenu.cfg
include txt.cfg
include gtk.cfg
menu begin advanced
menu title Advanced options
include stdmenu.cfg
label mainmenu
menu label ^Back..
menu exit
include adtxt.cfg
include adgtk.cfg
menu end
label help
menu label ^Help
text help
Display help screens; type 'menu' at boot prompt to return to this menu
endtext
config prompt.cfg
@@ -0,0 +1,3 @@
[po4a_langs] ar bn ca cs da de es eu fi fr gl hu id it ja ka ko ku lv nb nl pl pt pt_BR ru sk sv ta tr vi zh_CN zh_TW
[po4a_paths] po/help.pot $lang:po/$lang.po
[type:docbook] help.xml
@@ -0,0 +1,16 @@
prompt 1
display f1.txt
timeout 50
include menu.cfg
include exithelp.cfg
f1 f1.txt
f2 f2.txt
f3 f3.txt
f4 f4.txt
f5 f5.txt
f6 f6.txt
f7 f7.txt
f8 f8.txt
f9 f9.txt
f0 f10.txt
@@ -0,0 +1,4 @@
label rescue
menu label ^Rescue mode
kernel /install/vmlinuz
append vga=788 initrd=/install/initrd.gz rescue/enable=true -- quiet
@@ -0,0 +1,15 @@
menu background splash.png
menu color title * #FFFFFFFF *
menu color border * #00000000 #00000000 none
menu color sel * #ffffffff #76a1d0ff *
menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *
menu color tabmsg * #ffffffff #00000000 *
menu color help 37;40 #ffdddd00 #00000000 none
menu vshift 12
menu rows 10
menu helpmsgrow 15
# The command line must be at least one line from the bottom.
menu cmdlinerow 16
menu timeoutrow 16
menu tabmsgrow 18
menu tabmsg Press ENTER to boot or TAB to edit a menu entry

Some files were not shown because too many files have changed in this diff Show More