2 * libfdt - Flat Device Tree manipulation
3 * Testcase for fdt_path_offset()
4 * Copyright (C) 2006 David Gibson, IBM Corporation.
5 * Copyright 2008 Kumar Gala, Freescale Semiconductor, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 static void check_alias(void *fdt, const char *full_path, const char *alias_path)
35 offset = fdt_path_offset(fdt, full_path);
36 offset_a = fdt_path_offset(fdt, alias_path);
38 if (offset != offset_a)
39 FAIL("Mismatch between %s path_offset (%d) and %s path_offset alias (%d)",
40 full_path, offset, alias_path, offset_a);
43 int main(int argc, char *argv[])
47 test_init(argc, argv);
48 fdt = load_blob_arg(argc, argv);
50 check_alias(fdt, "/subnode@1", "s1");
51 check_alias(fdt, "/subnode@1/subsubnode", "ss1");
52 check_alias(fdt, "/subnode@1/subsubnode", "s1/subsubnode");
53 check_alias(fdt, "/subnode@1/subsubnode/subsubsubnode", "sss1");
54 check_alias(fdt, "/subnode@1/subsubnode/subsubsubnode", "ss1/subsubsubnode");
55 check_alias(fdt, "/subnode@1/subsubnode/subsubsubnode", "s1/subsubnode/subsubsubnode");