Make 'make check' work on emu.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-04-27 02:00:16 +02:00
parent db99fbe83f
commit a6393224c4
16 changed files with 82 additions and 49 deletions

View file

@ -1,3 +1,7 @@
2013-04-26 Vladimir Serbinenko <phcoder@gmail.com>
Make 'make check' work on emu.
2013-04-26 Vladimir Serbinenko <phcoder@gmail.com>
Replace libcurses with our own vt100 handling for the ease of testing

View file

@ -179,7 +179,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
}
/* Load modules. */
if (! grub_no_autoload)
if (! grub_no_modules)
{
const char *prefix;
prefix = grub_env_get ("prefix");

View file

@ -59,7 +59,7 @@ EOF
| grep -v '^#' \
| sed -n \
-e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/ {"\1", \1, 1},/;p;}' \
-e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/ {"\1", \&\1, 0},/;p;}' \
-e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/ {"\1", (void *) \&\1, 0},/;p;}' \
| sort -u
cat <<EOF

View file

@ -718,6 +718,9 @@ grub_dl_load (const char *name)
if (mod)
return mod;
if (grub_no_modules)
return 0;
if (! grub_dl_dir) {
grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
return 0;

View file

@ -24,6 +24,8 @@
#include <grub/emu/misc.h>
#include <grub/disk.h>
const int grub_no_modules = 1;
void
grub_register_exported_symbols (void)
{
@ -44,12 +46,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
return GRUB_ERR_BAD_MODULE;
}
void
grub_emu_init (void)
{
grub_no_autoload = 1;
}
#if defined (__ia64__) || defined (__powerpc__)
void grub_arch_dl_get_tramp_got_size (const void *ehdr __attribute__ ((unused)),
grub_size_t *tramp, grub_size_t *got)
@ -66,7 +62,3 @@ grub_arch_dl_init_linker (void)
}
#endif
void
grub_emu_post_init (void)
{
}

View file

@ -21,6 +21,8 @@
#error "No target cpu type is defined"
#endif
const int grub_no_modules = 0;
/* grub-emu-lite supports dynamic module loading, so it won't have any
embedded modules. */
void
@ -34,14 +36,3 @@ grub_fini_all (void)
{
return;
}
void
grub_emu_init (void)
{
return;
}
void
grub_emu_post_init (void)
{
}

View file

@ -55,8 +55,6 @@ static jmp_buf main_env;
/* Store the prefix specified by an argument. */
static char *root_dev = NULL, *dir = NULL;
int grub_no_autoload;
grub_addr_t grub_modbase = 0;
void
@ -171,7 +169,6 @@ void grub_hostfs_init (void);
void grub_hostfs_fini (void);
void grub_host_init (void);
void grub_host_fini (void);
void grub_emu_init (void);
int
main (int argc, char *argv[])
@ -208,7 +205,6 @@ main (int argc, char *argv[])
}
signal (SIGINT, SIG_IGN);
grub_emu_init ();
grub_console_init ();
grub_host_init ();
@ -219,8 +215,6 @@ main (int argc, char *argv[])
grub_hostfs_init ();
grub_emu_post_init ();
/* Make sure that there is a root device. */
if (! root_dev)
root_dev = grub_strdup ("host");

View file

@ -263,7 +263,7 @@ grub_normal_init_page (struct grub_term_output *term)
static void
read_lists (const char *val)
{
if (! grub_no_autoload)
if (! grub_no_modules)
{
read_command_list (val);
read_fs_list (val);

View file

@ -44,10 +44,8 @@
extern int verbosity;
extern const char *program_name;
void grub_emu_init (void);
void grub_init_all (void);
void grub_fini_all (void);
void grub_emu_post_init (void);
void grub_find_zpool_from_dir (const char *dir,
char **poolname, char **poolfs);

View file

@ -437,10 +437,10 @@ void grub_halt (void) __attribute__ ((noreturn));
#endif
#ifdef GRUB_MACHINE_EMU
/* Flag to control module autoloading in normal mode. */
extern int EXPORT_VAR(grub_no_autoload);
/* Flag to check if module loading is available. */
extern const int EXPORT_VAR(grub_no_modules);
#else
#define grub_no_autoload 0
#define grub_no_modules 0
#endif
static inline void

View file

@ -20,6 +20,8 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
*-emu)
exit 0;;
# Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 0;;

View file

@ -20,6 +20,8 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
*-emu)
exit 0;;
# Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 0;;

View file

@ -20,6 +20,8 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
*-emu)
exit 0;;
# Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 0;;

View file

@ -20,6 +20,8 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
*-emu)
exit 0;;
# Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 0;;

View file

@ -49,7 +49,7 @@ list_parts () {
outfile="$1"
shift
echo ls | "${grubshell}" --qemu-opts="-$qemudisk ${imgfile}" \
echo ls | "${grubshell}" --disk="${imgfile}" \
--modules=$mod | tr -d "\n\r" > "${outfile}"
cat "${outfile}"
echo
@ -58,23 +58,19 @@ list_parts () {
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
qemudisk=hda
;;
powerpc-ieee1275)
disk=ieee1275//pci@80000000/mac-io@4/ata-3@20000/disk@0
qemudisk=hda
# FIXME: QEMU firmware has bugs which prevent it from accessing hard disk w/o recognised label.
exit 0
;;
sparc64-ieee1275)
disk=ieee1275//pci@1fe\,0/pci-ata@5/ide0@500/disk@0
qemudisk=hda
# FIXME: QEMU firmware has bugs which prevent it from accessing hard disk w/o recognised label.
exit 0
;;
i386-ieee1275)
disk=ieee1275/d
qemudisk=hdb
# FIXME: QEMU firmware has bugs which prevent it from accessing hard disk w/o recognised label.
exit 0
;;
@ -83,11 +79,9 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
exit 0 ;;
mipsel-arc)
disk=arc/scsi0/disk0/rdisk0
qemudisk=hda
;;
*)
disk=hd0
qemudisk=hda
;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1

View file

@ -44,6 +44,7 @@ Run GRUB script in a Qemu instance.
--boot=[fd|hd|cd|net] boot method for Qemu instance
--modules=MODULES pre-load specified modules MODULES
--qemu=FILE Name of qemu binary
--disk=FILE Attach FILE as a disk
--qemu-opts=OPTIONS extra options to pass to Qemu instance
--files=FILES add files to the image
--mkrescue-arg=ARGS additional arguments to grub-mkrescue
@ -63,7 +64,16 @@ serial_port=com0
serial_null=
halt_cmd=halt
pseries=n
disk=hda
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
*-emu)
device_map=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
boot=emu
console=console
disk=0
# To skip "Welcome to GRUB" and color setttings
trim=1
;;
powerpc-ieee1275)
boot=cd
qemu=qemu-system-ppc
@ -134,6 +144,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
qemu=qemu-system-i386
console=console
trim=1
disk=hdb
;;
i386-qemu)
boot=qemu
@ -200,6 +211,28 @@ for option in "$@"; do
--qemu-opts=*)
qs=`echo "$option" | sed -e 's/--qemu-opts=//'`
qemuopts="$qemuopts $qs" ;;
--disk=*)
dsk=`echo "$option" | sed -e 's/--disk=//'`
if [ ${grub_modinfo_platform} = emu ]; then
echo "(hd$disk) $dsk" >> "$device_map"
disk="$((disk+1))"
else
if [ $disk = error ]; then
echo "Too many disks" 1>&2
exit 1;
fi
qemuopts="$qemuopts -$disk $dsk"
if [ "$disk" = hda ]; then
disk=hdb;
elif [ "$disk" = hdb ]; then
# CDROM is hdc
disk=hdd
elif [ "$disk" = hdd ]; then
# CDROM is hdc
disk=error
fi
fi
;;
--timeout=*)
timeout=`echo "$option" | sed -e 's/--timeout=//'`
;;
@ -244,16 +277,27 @@ fi
cfgfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
cat <<EOF >${cfgfile}
grubshell=yes
insmod serial
EOF
if [ "${grub_modinfo_platform}" != emu ]; then
echo insmod serial >>${cfgfile}
fi
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = powerpc-ieee1275 ]; then
echo insmod escc >>${cfgfile}
fi
if [ "${grub_modinfo_platform}" != emu ]; then
echo "serial ${serial_port}" >>${cfgfile}
term="serial_${serial_port}"
else
term=console
fi
cat <<EOF >>${cfgfile}
serial ${serial_port}
terminfo -g 255x255 serial_${serial_port} dumb
terminal_input serial_${serial_port}
terminal_output serial_${serial_port}
terminfo -g 255x255 ${term} dumb
terminal_input ${term}
terminal_output ${term}
EOF
trim_head=664cbea8-132f-4770-8aa4-1696d59ac35c
@ -270,7 +314,7 @@ do
done
cat <<EOF >>${cfgfile}
source /boot/grub/testcase.cfg
source \$prefix/testcase.cfg
# Stop serial output to suppress "ACPI shutdown failed" error.
EOF
if [ x$console != x ]; then
@ -279,7 +323,7 @@ fi
echo "${halt_cmd}" >>${cfgfile}
isofile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
if [ x$boot != xnet ]; then
if [ x$boot != xnet ] && [ x$boot != xemu ]; then
pkgdatadir="@builddir@" sh "@builddir@/grub-mkrescue" "--grub-mkimage=${builddir}/grub-mkimage" "--grub-render-label=${builddir}/grub-render-label" "--output=${isofile}" "--override-directory=${builddir}/grub-core" \
--rom-directory="${rom_directory}" ${mkrescue_args} \
"/boot/grub/grub.cfg=${cfgfile}" "/boot/grub/testcase.cfg=${source}" \
@ -354,6 +398,11 @@ if [ x$boot = xnet ]; then
cp "${cfgfile}" "$netdir/boot/grub/grub.cfg"
cp "${source}" "$netdir/boot/grub/testcase.cfg"
timeout -s KILL $timeout "${qemu}" ${qemuopts} -nographic ${serial_null} -serial file:/dev/stdout -monitor file:/dev/null -boot n -net "user,tftp=$netdir,bootfile=/boot/grub/${grub_modinfo_target_cpu}-${grub_modinfo_platform}/core.$netbootext" -net nic | cat | tr -d "\r" | do_trim
elif [ x$boot = xemu ]; then
grubdir="$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")"
cp "${cfgfile}" "$grubdir/grub.cfg"
cp "${source}" "$grubdir/testcase.cfg"
@builddir@/grub-core/grub-emu -m "$device_map" -d "$grubdir" | tr -d "\r" | do_trim
else
timeout -s KILL $timeout "${qemu}" ${qemuopts} -nographic ${serial_null} -serial file:/dev/stdout -monitor file:/dev/null -${device} ${isofile} ${bootdev} | cat | tr -d "\r" | do_trim
fi