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
|
/*
* libfdt - Flat Device Tree manipulation
* Testcase for DT overlays()
* Copyright (C) 2016 Free Electrons
* Copyright (C) 2016 NextThing Co.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <libfdt.h>
#include "tests.h"
#define CHECK(code, expected) \
{ \
err = (code); \
if (err != expected) \
FAIL(#code ": %s", fdt_strerror(err)); \
}
/* 4k ought to be enough for anybody */
#define FDT_COPY_SIZE (4 * 1024)
static void *open_dt(char *path)
{
void *dt, *copy;
int err;
dt = load_blob(path);
copy = xmalloc(FDT_COPY_SIZE);
/*
* Resize our DTs to 4k so that we have room to operate on
*/
CHECK(fdt_open_into(dt, copy, FDT_COPY_SIZE), 0);
return copy;
}
int main(int argc, char *argv[])
{
void *fdt_base, *fdt_overlay;
int err;
test_init(argc, argv);
if (argc != 3)
CONFIG("Usage: %s <base dtb> <overlay dtb>", argv[0]);
fdt_base = open_dt(argv[1]);
fdt_overlay = open_dt(argv[2]);
/* Apply the overlay */
CHECK(fdt_overlay_apply(fdt_base, fdt_overlay), -FDT_ERR_BADOVERLAY);
PASS();
}
|