Add support for GPG signature enforcement on booted
[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, "/etc/yaboot.conf");
38
39         test_run_parser(test, "yaboot");
40
41         ctx = test->ctx;
42
43         check_boot_option_count(ctx, 4);
44
45         for (i = 0; i < 4; i++)
46                 opt[i] = get_boot_option(ctx, i);
47
48         check_name(opt[0], "linux.1");
49         check_unresolved_resource(opt[0]->boot_image);
50         check_unresolved_resource(opt[0]->initrd);
51
52         check_name(opt[1], "linux.2");
53         check_unresolved_resource(opt[1]->boot_image);
54         check_unresolved_resource(opt[1]->initrd);
55
56         check_name(opt[2], "linux.3");
57         check_unresolved_resource(opt[2]->boot_image);
58         check_unresolved_resource(opt[2]->initrd);
59
60         check_name(opt[3], "linux.4");
61         check_unresolved_resource(opt[3]->boot_image);
62         check_unresolved_resource(opt[3]->initrd);
63
64         /* hotplug all dependent devices */
65         for (i = 0; i < 4; i++) {
66                 devname = talloc_asprintf(test, "sda%d", i + 1);
67                 dev[i] = test_create_device(test, devname);
68                 test_hotplug_device(test, dev[i]);
69         }
70
71         check_resolved_local_resource(opt[0]->boot_image, dev[0], "/vmlinux.1");
72         check_resolved_local_resource(opt[1]->boot_image, dev[1], "/vmlinux.2");
73         check_resolved_local_resource(opt[2]->boot_image, dev[2], "/vmlinux.3");
74         check_resolved_local_resource(opt[3]->boot_image, dev[3], "/vmlinux.4");
75
76         check_resolved_local_resource(opt[0]->initrd, dev[0], "/initrd.1");
77         check_resolved_local_resource(opt[1]->initrd, dev[1], "/initrd.2");
78         check_resolved_local_resource(opt[2]->initrd, dev[2], "/initrd.3");
79         check_resolved_local_resource(opt[3]->initrd, dev[2], "/initrd.4");
80 }