From 02af1caf9df8e43ebb9555069cb014e60bb7ec6d Mon Sep 17 00:00:00 2001 From: Brett Grandbois Date: Fri, 9 Feb 2018 13:26:41 +1000 Subject: syslinux: add syslinux parser support Signed-off-by: Brett Grandbois Signed-off-by: Samuel Mendoza-Jonas --- test/parser/Makefile.am | 13 ++++++- test/parser/data/syslinux-include-nest-1.cfg | 7 ++++ test/parser/data/syslinux-include-nest-2.cfg | 6 +++ test/parser/data/syslinux-include-root.cfg | 18 +++++++++ test/parser/test-syslinux-explicit.c | 41 ++++++++++++++++++++ test/parser/test-syslinux-global-append.c | 56 ++++++++++++++++++++++++++++ test/parser/test-syslinux-nested-config.c | 41 ++++++++++++++++++++ test/parser/test-syslinux-single-yocto.c | 36 ++++++++++++++++++ 8 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 test/parser/data/syslinux-include-nest-1.cfg create mode 100644 test/parser/data/syslinux-include-nest-2.cfg create mode 100644 test/parser/data/syslinux-include-root.cfg create mode 100644 test/parser/test-syslinux-explicit.c create mode 100644 test/parser/test-syslinux-global-append.c create mode 100644 test/parser/test-syslinux-nested-config.c create mode 100644 test/parser/test-syslinux-single-yocto.c (limited to 'test') diff --git a/test/parser/Makefile.am b/test/parser/Makefile.am index 31300f0..a0795db 100644 --- a/test/parser/Makefile.am +++ b/test/parser/Makefile.am @@ -73,7 +73,12 @@ parser_TESTS = \ test/parser/test-pxe-discover-bootfile-relative-conffile \ test/parser/test-pxe-discover-bootfile-absolute-conffile \ test/parser/test-pxe-discover-bootfile-async-file \ - test/parser/test-unresolved-remove + test/parser/test-unresolved-remove \ + test/parser/test-syslinux-single-yocto \ + test/parser/test-syslinux-global-append \ + test/parser/test-syslinux-explicit \ + test/parser/test-syslinux-nested-config + TESTS += $(parser_TESTS) check_PROGRAMS += $(parser_TESTS) test/parser/libtest.ro @@ -82,7 +87,10 @@ check_DATA += \ test/parser/data/grub2-f18-ppc64.conf \ test/parser/data/grub2-f20-ppc.conf \ test/parser/data/grub2-ubuntu-13_04-x86.conf \ - test/parser/data/yaboot-rh8-ppc64.conf + test/parser/data/yaboot-rh8-ppc64.conf \ + test/parser/data/syslinux-include-root.cfg \ + test/parser/data/syslinux-include-nest-1.cfg \ + test/parser/data/syslinux-include-nest-2.cfg $(parser_TESTS): AM_CPPFLAGS += \ -I$(top_srcdir)/discover \ @@ -107,6 +115,7 @@ test_parser_libtest_ro_SOURCES = \ discover/yaboot-parser.c \ discover/kboot-parser.c \ discover/pxe-parser.c \ + discover/syslinux-parser.c \ discover/platform.c \ discover/resource.c \ discover/paths.c \ diff --git a/test/parser/data/syslinux-include-nest-1.cfg b/test/parser/data/syslinux-include-nest-1.cfg new file mode 100644 index 0000000..65e680e --- /dev/null +++ b/test/parser/data/syslinux-include-nest-1.cfg @@ -0,0 +1,7 @@ +LABEL com32 +COM32 /boot/com32.c32 + +INCLUDE syslinux-include-nest-2.cfg + +LABEL bss +KERNEL /boot/test.bss diff --git a/test/parser/data/syslinux-include-nest-2.cfg b/test/parser/data/syslinux-include-nest-2.cfg new file mode 100644 index 0000000..26d7cff --- /dev/null +++ b/test/parser/data/syslinux-include-nest-2.cfg @@ -0,0 +1,6 @@ +LABEL boot +KERNEL /bzImage-boot +INITRD /initrd-boot +APPEND root=/dev/sda + +DEFAULT boot diff --git a/test/parser/data/syslinux-include-root.cfg b/test/parser/data/syslinux-include-root.cfg new file mode 100644 index 0000000..834360c --- /dev/null +++ b/test/parser/data/syslinux-include-root.cfg @@ -0,0 +1,18 @@ +APPEND console=ttyS0 + +LABEL floppy +FDIMAGE /boot/floppy.img + +LABEL backup +KERNEL /backup/vmlinuz +APPEND root=/dev/sdb +INITRD /boot/initrd + +LABEL comboot +KERNEL /boot/comboot.com + +INCLUDE /syslinux-include-nest-1.cfg + +LABEL linux +LINUX /boot/bzImage +APPEND root=/dev/sdc diff --git a/test/parser/test-syslinux-explicit.c b/test/parser/test-syslinux-explicit.c new file mode 100644 index 0000000..5d23f50 --- /dev/null +++ b/test/parser/test-syslinux-explicit.c @@ -0,0 +1,41 @@ +/* test a standard yocto syslinux wic cfg */ + +#include "parser-test.h" + +#if 0 /* PARSER_EMBEDDED_CONFIG */ + + +DEFAULT boot + +KERNEL /vmlinuz +APPEND console=tty0 + +LABEL backup +KERNEL /backup/vmlinuz +APPEND root=/dev/sdb +INITRD /boot/initrd + +IMPLICIT 0 + +#endif + +void run_test(struct parser_test *test) +{ + struct discover_boot_option *opt; + struct discover_context *ctx; + + test_read_conf_embedded(test, "/boot/syslinux/syslinux.cfg"); + + test_run_parser(test, "syslinux"); + + ctx = test->ctx; + + check_boot_option_count(ctx, 1); + + opt = get_boot_option(ctx, 0); + + check_name(opt, "backup"); + check_resolved_local_resource(opt->boot_image, ctx->device, "/backup/vmlinuz"); + check_args(opt, " root=/dev/sdb"); + check_resolved_local_resource(opt->initrd, ctx->device, "/boot/initrd"); +} diff --git a/test/parser/test-syslinux-global-append.c b/test/parser/test-syslinux-global-append.c new file mode 100644 index 0000000..18af99a --- /dev/null +++ b/test/parser/test-syslinux-global-append.c @@ -0,0 +1,56 @@ + +#include "parser-test.h" + +#if 0 /* PARSER_EMBEDDED_CONFIG */ + +APPEND console=ttyS0 + +LABEL linux +LINUX /vmlinuz +APPEND console=tty0 + +LABEL backup +KERNEL /backup/vmlinuz +APPEND root=/dev/sdb +INITRD /boot/initrd + +LABEL hyphen +KERNEL /test/vmlinuz +APPEND - + +#endif + +void run_test(struct parser_test *test) +{ + struct discover_boot_option *opt; + struct discover_context *ctx; + + test_read_conf_embedded(test, "/syslinux/syslinux.cfg"); + + test_run_parser(test, "syslinux"); + + ctx = test->ctx; + + check_boot_option_count(ctx, 3); + opt = get_boot_option(ctx, 2); + + check_name(opt, "linux"); + check_resolved_local_resource(opt->boot_image, ctx->device, "/vmlinuz"); + check_is_default(opt); + check_args(opt, "console=ttyS0 console=tty0"); + check_not_present_resource(opt->initrd); + + opt = get_boot_option(ctx, 1); + + check_name(opt, "backup"); + check_resolved_local_resource(opt->boot_image, ctx->device, "/backup/vmlinuz"); + check_args(opt, "console=ttyS0 root=/dev/sdb"); + check_resolved_local_resource(opt->initrd, ctx->device, "/boot/initrd"); + + opt = get_boot_option(ctx, 0); + + check_name(opt, "hyphen"); + check_resolved_local_resource(opt->boot_image, ctx->device, "/test/vmlinuz"); + check_args(opt, ""); + check_not_present_resource(opt->initrd); +} diff --git a/test/parser/test-syslinux-nested-config.c b/test/parser/test-syslinux-nested-config.c new file mode 100644 index 0000000..73c4774 --- /dev/null +++ b/test/parser/test-syslinux-nested-config.c @@ -0,0 +1,41 @@ + +#include "parser-test.h" + + +void run_test(struct parser_test *test) +{ + struct discover_boot_option *opt; + struct discover_context *ctx; + + test_read_conf_file(test, "syslinux-include-root.cfg", "/boot/syslinux/syslinux.cfg"); + test_read_conf_file(test, "syslinux-include-nest-1.cfg", "/syslinux-include-nest-1.cfg"); + test_read_conf_file(test, "syslinux-include-nest-2.cfg", "/boot/syslinux/syslinux-include-nest-2.cfg"); + + test_run_parser(test, "syslinux"); + + ctx = test->ctx; + + check_boot_option_count(ctx, 3); + + opt = get_boot_option(ctx, 1); + + check_name(opt, "boot"); + check_resolved_local_resource(opt->boot_image, ctx->device, "/bzImage-boot"); + check_is_default(opt); + check_args(opt, "console=ttyS0 root=/dev/sda"); + check_resolved_local_resource(opt->initrd, ctx->device, "/initrd-boot"); + + opt = get_boot_option(ctx, 2); + + check_name(opt, "backup"); + check_resolved_local_resource(opt->boot_image, ctx->device, "/backup/vmlinuz"); + check_args(opt, "console=ttyS0 root=/dev/sdb"); + check_resolved_local_resource(opt->initrd, ctx->device, "/boot/initrd"); + + opt = get_boot_option(ctx, 0); + + check_name(opt, "linux"); + check_resolved_local_resource(opt->boot_image, ctx->device, "/boot/bzImage"); + check_args(opt, "console=ttyS0 root=/dev/sdc"); + check_not_present_resource(opt->initrd); +} diff --git a/test/parser/test-syslinux-single-yocto.c b/test/parser/test-syslinux-single-yocto.c new file mode 100644 index 0000000..e5e084d --- /dev/null +++ b/test/parser/test-syslinux-single-yocto.c @@ -0,0 +1,36 @@ +/* test a standard yocto syslinux wic cfg */ + +#include "parser-test.h" + +#if 0 /* PARSER_EMBEDDED_CONFIG */ +PROMPT 0 +TIMEOUT 0 + +ALLOWOPTIONS 1 +SERIAL 0 115200 + +DEFAULT boot +LABEL boot +KERNEL /vmlinuz +APPEND console=ttyS0,115200n8 console=tty0 +#endif + +void run_test(struct parser_test *test) +{ + struct discover_boot_option *opt; + struct discover_context *ctx; + + test_read_conf_embedded(test, "/syslinux.cfg"); + + test_run_parser(test, "syslinux"); + + ctx = test->ctx; + + check_boot_option_count(ctx, 1); + opt = get_boot_option(ctx, 0); + + check_name(opt, "boot"); + check_resolved_local_resource(opt->boot_image, ctx->device, "/vmlinuz"); + check_is_default(opt); + check_args(opt, " console=ttyS0,115200n8 console=tty0"); +} -- cgit v1.2.1