Currently, we have a bug when parsing zero-length files: we subtract one
from the length to exclude the trailing NUL (added by read_file), but a
zero-length file will result in a length of -1.
This change adds an explicit exit if we're attempting to parse an empty
file.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
YY_BUFFER_STATE bufstate;
int rc;
YY_BUFFER_STATE bufstate;
int rc;
parser->script->filename = filename;
bufstate = yy_scan_bytes(buf, len - 1, parser->scanner);
parser->script->filename = filename;
bufstate = yy_scan_bytes(buf, len - 1, parser->scanner);
test-null \
test-grub2-single \
test-grub2-default \
test-null \
test-grub2-single \
test-grub2-default \
test-grub2-default-index \
test-grub2-default-multiword \
test-grub2-multiple-resolve \
test-grub2-default-index \
test-grub2-default-multiword \
test-grub2-multiple-resolve \
--- /dev/null
+
+#include "parser-test.h"
+
+void run_test(struct parser_test *test)
+{
+ __test_read_conf_data(test, test->ctx->device,
+ "/grub2/grub.cfg", "", 0);
+ test_run_parser(test, "grub2");
+ check_boot_option_count(test->ctx, 0);
+}