1 /* 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. 6 * 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. 11 * 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. 16 * 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 20 */ 21 #include <stdlib.h> 22 #include <stdio.h> 23 #include <string.h> 24 #include <stdint.h> 25 26 #include <libfdt.h> 27 28 #include "tests.h" 29 #include "testdata.h" 30 31 static void check_alias(void *fdt, const char *full_path, const char *alias_path) 32 { 33 int offset, offset_a; 34 35 offset = fdt_path_offset(fdt, full_path); 36 offset_a = fdt_path_offset(fdt, alias_path); 37 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); 41 } 42 43 int main(int argc, char *argv[]) 44 { 45 void *fdt; 46 47 test_init(argc, argv); 48 fdt = load_blob_arg(argc, argv); 49 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"); 56 57 PASS(); 58 } 59