]> git.ozlabs.org Git - petitboot/blob - test/parser/test-grub2-test-file-ops.c
discover/grub2: Allow to separate the --id argument using a space char
[petitboot] / test / parser / test-grub2-test-file-ops.c
1
2 #include "parser-test.h"
3
4 #if 0 /* PARSER_EMBEDDED_CONFIG */
5 status=success
6
7 if [ -f /file_that_does_not_exist -a $status = success ]
8 then status=fail_f_1
9 fi
10 if [ -f /dir -a $status = success ]
11 then status=fail_f_2
12 fi
13 if [ ! -f /empty_file -a $status = success ]
14 then status=fail_f_3
15 fi
16
17 if [ -s /file_that_does_not_exist -a $status = success ]
18 then status=fail_s_1
19 fi
20 if [ ! -s /dir -a $status = success ]
21 then status=fail_s_2
22 fi
23 if [ -s /empty_file -a $status = success ]
24 then status=fail_s_3
25 fi
26 if [ ! -s /non_empty_file -a $status = success ]
27 then status=fail_s_4
28 fi
29
30 if [ -d /file_that_does_not_exist -a $status = success ]
31 then status=fail_d_1
32 fi
33 if [ ! -d /dir -a $status = success ]
34 then status=fail_d_2
35 fi
36 if [ -d /empty_file -a $status = success ]
37 then status=fail_d_3
38 fi
39
40 menuentry $status {
41   linux /vmlinux
42 }
43 #endif
44
45 void run_test(struct parser_test *test)
46 {
47         struct discover_boot_option *opt;
48         struct discover_context *ctx;
49
50         ctx = test->ctx;
51
52         test_read_conf_embedded(test, "/grub2/grub.cfg");
53         test_add_file_data(test, ctx->device, "/empty_file", "", 0);
54         test_add_file_data(test, ctx->device, "/non_empty_file", "1", 1);
55         test_add_dir(test, ctx->device, "/dir");
56
57         test_run_parser(test, "grub2");
58
59         check_boot_option_count(ctx, 1);
60         opt = get_boot_option(ctx, 0);
61
62         check_name(opt, "success");
63 }