From ffc167572a9d56c52908aebefe62ba3e3e2a9cf8 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Thu, 26 Sep 2013 15:45:58 +0800 Subject: discover/grub2: Clean up error-handling for grub2 parser & lexer Rather than printf() & exit(), use the pb logging functions and abort the parse. Signed-off-by: Jeremy Kerr --- test/parser/Makefile.am | 2 ++ test/parser/test-grub2-lexer-error.c | 13 +++++++++++++ test/parser/test-grub2-parser-error.c | 13 +++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 test/parser/test-grub2-lexer-error.c create mode 100644 test/parser/test-grub2-parser-error.c (limited to 'test') diff --git a/test/parser/Makefile.am b/test/parser/Makefile.am index 8159bd6..e7146c5 100644 --- a/test/parser/Makefile.am +++ b/test/parser/Makefile.am @@ -35,6 +35,8 @@ TESTS = \ test-grub2-single-line-if \ test-grub2-f18-ppc64 \ test-grub2-ubuntu-13_04-x86 \ + test-grub2-lexer-error \ + test-grub2-parser-error \ test-kboot-single \ test-yaboot-single \ test-yaboot-partition \ diff --git a/test/parser/test-grub2-lexer-error.c b/test/parser/test-grub2-lexer-error.c new file mode 100644 index 0000000..503ec99 --- /dev/null +++ b/test/parser/test-grub2-lexer-error.c @@ -0,0 +1,13 @@ + +#include "parser-test.h" + +#if 0 /* PARSER_EMBEDDED_CONFIG */ +& +#endif + +void run_test(struct parser_test *test) +{ + test_read_conf_embedded(test); + test_run_parser(test, "grub2"); + check_boot_option_count(test->ctx, 0); +} diff --git a/test/parser/test-grub2-parser-error.c b/test/parser/test-grub2-parser-error.c new file mode 100644 index 0000000..a7a00a4 --- /dev/null +++ b/test/parser/test-grub2-parser-error.c @@ -0,0 +1,13 @@ + +#include "parser-test.h" + +#if 0 /* PARSER_EMBEDDED_CONFIG */ +{ +#endif + +void run_test(struct parser_test *test) +{ + test_read_conf_embedded(test); + test_run_parser(test, "grub2"); + check_boot_option_count(test->ctx, 0); +} -- cgit v1.2.1