]> git.ozlabs.org Git - petitboot/blob - lib/pb-config/storage-test.c
test/parser: Cleanup Makefile.am
[petitboot] / lib / pb-config / storage-test.c
1
2 #include <string.h>
3 #include <stdlib.h>
4 #include <sys/types.h>
5 #include <sys/wait.h>
6
7 #include "pb-config.h"
8 #include "storage.h"
9
10 struct network_config net1 = {
11         .hwaddr = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 },
12         .method = CONFIG_METHOD_DHCP,
13 };
14
15 struct network_config net2 = {
16         .hwaddr = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x56 },
17         .method = CONFIG_METHOD_STATIC,
18         .static_config = {
19                 .address = "192.168.0.2/24",
20                 .gateway = "192.168.0.1",
21         },
22 };
23
24 struct network_config *network_configs[] = { &net1, &net2 };
25
26 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
27
28 struct config test_config = {
29         .autoboot_enabled = true,
30         .network_configs = network_configs,
31         .n_network_configs = ARRAY_SIZE(network_configs),
32 };
33
34 struct test_storage {
35         struct config_storage   storage;
36         struct param            *params;
37         int                     n_params;
38 };
39
40 static int load(struct config_storage *st __attribute__((unused)),
41                 struct config *config)
42 {
43         memcpy(config, &test_config, sizeof(test_config));
44         return 0;
45 }
46
47 static struct test_storage st = {
48         .storage = {
49                 .load  = load,
50         },
51 };
52
53 struct config_storage *create_test_storage(void *ctx __attribute__((unused)))
54 {
55         return &st.storage;
56 }