]> git.ozlabs.org Git - petitboot/blob - test/parser/test-grub2-save-env-dash-f.c
discover: Reimplement native-parser as a Bison parser
[petitboot] / test / parser / test-grub2-save-env-dash-f.c
1
2 #include <string.h>
3
4 #include <talloc/talloc.h>
5
6 #include "parser-test.h"
7
8 #if 0 /* PARSER_EMBEDDED_CONFIG */
9 hello=world
10 save_env -f env_file hello
11 #endif
12
13 static const char *envsig = "# GRUB Environment Block\n";
14
15 void run_test(struct parser_test *test)
16 {
17         const char *env_before, *env_after;
18
19         /* The environment file must be preallocated */
20
21         /* The padding at the end of the environment block is the length of
22          * "hello=world\n" */
23         env_before = talloc_asprintf(test, "%s%s", envsig,
24                                         "############");
25         test_add_file_data(test, test->ctx->device, "/boot/grub/env_file",
26                                 env_before, strlen(env_before));
27
28         env_after = talloc_asprintf(test, "%s%s", envsig,
29                                         "hello=world\n");
30
31         test_read_conf_embedded(test, "/boot/grub/grub.cfg");
32
33         test_run_parser(test, "grub2");
34
35         check_file_contents(test, test->ctx->device, "/boot/grub/env_file",
36                                 env_after, strlen(env_after));
37 }