4 * libfdt - Flat Device Tree manipulation
6 * Copyright (C) 2006 David Gibson, IBM Corporation.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 /* Test return codes */
31 extern int verbose_test;
32 extern char *test_name;
33 void test_init(int argc, char *argv[]);
35 #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
36 #define PALIGN(p, a) ((void *)ALIGN((unsigned long)(p), (a)))
37 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
39 #define streq(s1, s2) (strcmp((s1),(s2)) == 0)
41 /* Each test case must define this function */
44 #define verbose_printf(...) \
46 printf(__VA_ARGS__); \
50 #define ERROR(fmt, args...) fprintf(stderr, ERR fmt, ## args)
60 #define PASS_INCONCLUSIVE() \
63 printf("PASS (inconclusive)\n"); \
67 #define IRRELEVANT() \
70 printf("PASS (irrelevant)\n"); \
74 /* Look out, gcc extension below... */
75 #define FAIL(fmt, ...) \
78 printf("FAIL\t" fmt "\n", ##__VA_ARGS__); \
82 #define CONFIG(fmt, ...) \
85 printf("Bad configuration: " fmt "\n", ##__VA_ARGS__); \
89 #define TEST_BUG(fmt, ...) \
92 printf("BUG in testsuite: " fmt "\n", ##__VA_ARGS__); \
96 void check_mem_rsv(void *fdt, int n, uint64_t addr, uint64_t size);
98 void check_property(void *fdt, int nodeoffset, const char *name,
99 int len, const void *val);
100 #define check_property_cell(fdt, nodeoffset, name, val) \
102 uint32_t x = cpu_to_fdt32(val); \
103 check_property(fdt, nodeoffset, name, sizeof(x), &x); \
107 const void *check_getprop(void *fdt, int nodeoffset, const char *name,
108 int len, const void *val);
109 #define check_getprop_cell(fdt, nodeoffset, name, val) \
111 uint32_t x = cpu_to_fdt32(val); \
112 check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
114 #define check_getprop_64(fdt, nodeoffset, name, val) \
116 uint64_t x = cpu_to_fdt64(val); \
117 check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
119 #define check_getprop_string(fdt, nodeoffset, name, s) \
120 check_getprop((fdt), (nodeoffset), (name), strlen(s)+1, (s))
121 int nodename_eq(const char *s1, const char *s2);
122 void *load_blob(const char *filename);
123 void *load_blob_arg(int argc, char *argv[]);
124 void save_blob(const char *filename, void *blob);
125 void *open_blob_rw(void *blob);
129 #endif /* _TESTS_H */