1 /* $NetBSD: truncated_property.c,v 1.1.1.3 2019/12/22 12:34:06 skrll Exp $ */
2
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 /*
5 * libfdt - Flat Device Tree manipulation
6 * Testcase for misbehaviour on a truncated property
7 * Copyright (C) 2006 David Gibson, IBM Corporation.
8 */
9
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <string.h>
13 #include <stdint.h>
14
15 #include <libfdt.h>
16
17 #include "tests.h"
18 #include "testdata.h"
19
main(int argc,char * argv[])20 int main(int argc, char *argv[])
21 {
22 void *fdt = &truncated_property;
23 const void *prop;
24 int len;
25
26 test_init(argc, argv);
27
28 vg_prepare_blob(fdt, fdt_totalsize(fdt));
29
30 prop = fdt_getprop(fdt, 0, "truncated", &len);
31 if (prop)
32 FAIL("fdt_getprop() succeeded on truncated property");
33 if (len != -FDT_ERR_BADSTRUCTURE)
34 FAIL("fdt_getprop() failed with \"%s\" instead of \"%s\"",
35 fdt_strerror(len), fdt_strerror(-FDT_ERR_BADSTRUCTURE));
36
37 PASS();
38 }
39