test/parser: Allow checks for NULL boot_args
[petitboot] / test / parser / test-yaboot-device-override.c
1 #include "parser-test.h"
2
3 #include <talloc/talloc.h>
4
5 #if 0 /* PARSER_EMBEDDED_CONFIG */
6 default=
7 device=/dev/sda1
8
9 image=/vmlinux.1
10         label=linux.1
11         initrd=initrd.1
12
13 image=/vmlinux.2
14         device=/dev/sda2
15         label=linux.2
16         initrd=initrd.2
17
18 image=sda3:/vmlinux.3
19         device=/dev/sda2
20         label=linux.3
21         initrd=sda3:initrd.3
22
23 image=sda4:/vmlinux.4
24         device=/dev/sda3
25         label=linux.4
26         initrd=initrd.4
27 #endif
28
29 void run_test(struct parser_test *test)
30 {
31         struct discover_boot_option *opt[4];
32         struct discover_device *dev[4];
33         struct discover_context *ctx;
34         char *devname;
35         int i;
36
37         test_read_conf_embedded(test);
38         test_run_parser(test, "yaboot");
39
40         ctx = test->ctx;
41
42         check_boot_option_count(ctx, 4);
43
44         for (i = 0; i < 4; i++)
45                 opt[i] = get_boot_option(ctx, i);
46
47         check_name(opt[0], "linux.1");
48         check_unresolved_resource(opt[0]->boot_image);
49         check_unresolved_resource(opt[0]->initrd);
50
51         check_name(opt[1], "linux.2");
52         check_unresolved_resource(opt[1]->boot_image);
53         check_unresolved_resource(opt[1]->initrd);
54
55         check_name(opt[2], "linux.3");
56         check_unresolved_resource(opt[2]->boot_image);
57         check_unresolved_resource(opt[2]->initrd);
58
59         check_name(opt[3], "linux.4");
60         check_unresolved_resource(opt[3]->boot_image);
61         check_unresolved_resource(opt[3]->initrd);
62
63         /* hotplug all dependent devices */
64         for (i = 0; i < 4; i++) {
65                 devname = talloc_asprintf(test, "sda%d", i + 1);
66                 dev[i] = test_create_device(test, devname);
67                 test_hotplug_device(test, dev[i]);
68         }
69
70         check_resolved_local_resource(opt[0]->boot_image, dev[0], "/vmlinux.1");
71         check_resolved_local_resource(opt[1]->boot_image, dev[1], "/vmlinux.2");
72         check_resolved_local_resource(opt[2]->boot_image, dev[2], "/vmlinux.3");
73         check_resolved_local_resource(opt[3]->boot_image, dev[3], "/vmlinux.4");
74
75         check_resolved_local_resource(opt[0]->initrd, dev[0], "/initrd.1");
76         check_resolved_local_resource(opt[1]->initrd, dev[1], "/initrd.2");
77         check_resolved_local_resource(opt[2]->initrd, dev[2], "/initrd.3");
78         check_resolved_local_resource(opt[3]->initrd, dev[2], "/initrd.4");
79 }