summaryrefslogtreecommitdiffstats
path: root/test/parser/test-yaboot-device-override.c
blob: be9332ff0a7829c262c63211419aaaccbcc1bc00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "parser-test.h"

#include <talloc/talloc.h>

#if 0 /* PARSER_EMBEDDED_CONFIG */
default=
device=/dev/sda1

image=/vmlinux.1
	label=linux.1
	initrd=initrd.1

image=/vmlinux.2
	device=/dev/sda2
	label=linux.2
	initrd=initrd.2

image=sda3:/vmlinux.3
	device=/dev/sda2
	label=linux.3
	initrd=sda3:initrd.3

image=sda4:/vmlinux.4
	device=/dev/sda3
	label=linux.4
	initrd=initrd.4
#endif

void run_test(struct parser_test *test)
{
	struct discover_boot_option *opt[4];
	struct discover_device *dev[4];
	struct discover_context *ctx;
	char *devname;
	int i;

	test_read_conf_embedded(test, "/etc/yaboot.conf");

	test_run_parser(test, "yaboot");

	ctx = test->ctx;

	check_boot_option_count(ctx, 4);

	for (i = 0; i < 4; i++)
		opt[i] = get_boot_option(ctx, i);

	check_name(opt[0], "linux.1");
	check_unresolved_resource(opt[0]->boot_image);
	check_unresolved_resource(opt[0]->initrd);

	check_name(opt[1], "linux.2");
	check_unresolved_resource(opt[1]->boot_image);
	check_unresolved_resource(opt[1]->initrd);

	check_name(opt[2], "linux.3");
	check_unresolved_resource(opt[2]->boot_image);
	check_unresolved_resource(opt[2]->initrd);

	check_name(opt[3], "linux.4");
	check_unresolved_resource(opt[3]->boot_image);
	check_unresolved_resource(opt[3]->initrd);

	/* hotplug all dependent devices */
	for (i = 0; i < 4; i++) {
		devname = talloc_asprintf(test, "sda%d", i + 1);
		dev[i] = test_create_device(test, devname);
		test_hotplug_device(test, dev[i]);
	}

	check_resolved_local_resource(opt[0]->boot_image, dev[0], "/vmlinux.1");
	check_resolved_local_resource(opt[1]->boot_image, dev[1], "/vmlinux.2");
	check_resolved_local_resource(opt[2]->boot_image, dev[2], "/vmlinux.3");
	check_resolved_local_resource(opt[3]->boot_image, dev[3], "/vmlinux.4");

	check_resolved_local_resource(opt[0]->initrd, dev[0], "/initrd.1");
	check_resolved_local_resource(opt[1]->initrd, dev[1], "/initrd.2");
	check_resolved_local_resource(opt[2]->initrd, dev[2], "/initrd.3");
	check_resolved_local_resource(opt[3]->initrd, dev[2], "/initrd.4");
}
OpenPOWER on IntegriCloud