[Crosstoolchain-logs] [device-tree-compiler] 149/198: Use a helper function to clean up path_offset testcase
Hector Oron
zumbi at moszumanska.debian.org
Thu Dec 8 17:07:03 UTC 2016
This is an automated email from the git hooks/post-receive script.
zumbi pushed a commit to branch upstream/1.4.x
in repository device-tree-compiler.
commit 5fa047f498170496c37a9d5842d3b7eaf3907cca
Author: David Gibson <david at gibson.dropbear.id.au>
Date: Tue Apr 7 14:20:33 2015 +1000
Use a helper function to clean up path_offset testcase
This introduces a check_path_offset() helper function into the path_offset
testcase to simplify it. This will also make extending the test case with
tests for path_offset_namelen() and some edge cases easier.
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
tests/path_offset.c | 55 +++++++++++++++++++----------------------------------
1 file changed, 20 insertions(+), 35 deletions(-)
diff --git a/tests/path_offset.c b/tests/path_offset.c
index 4e5b7a1..0ff710d 100644
--- a/tests/path_offset.c
+++ b/tests/path_offset.c
@@ -54,58 +54,43 @@ static int check_subnode(void *fdt, int parent, const char *name)
return offset;
}
+static void check_path_offset(void *fdt, char *path, int offset)
+{
+ int rc;
+
+ rc = fdt_path_offset(fdt, path);
+ if (rc < 0)
+ FAIL("fdt_path_offset(\"%s\") failed: %s",
+ path, fdt_strerror(rc));
+ if (rc != offset)
+ FAIL("fdt_path_offset(\"%s\") returned incorrect offset"
+ " %d instead of %d", path, rc, offset);
+}
+
int main(int argc, char *argv[])
{
void *fdt;
- int root_offset;
int subnode1_offset, subnode2_offset;
- int subnode1_offset_p, subnode2_offset_p;
int subsubnode1_offset, subsubnode2_offset, subsubnode2_offset2;
- int subsubnode1_offset_p, subsubnode2_offset_p, subsubnode2_offset2_p;
test_init(argc, argv);
fdt = load_blob_arg(argc, argv);
- root_offset = fdt_path_offset(fdt, "/");
- if (root_offset < 0)
- FAIL("fdt_path_offset(\"/\") failed: %s",
- fdt_strerror(root_offset));
- else if (root_offset != 0)
- FAIL("fdt_path_offset(\"/\") returns incorrect offset %d",
- root_offset);
+ check_path_offset(fdt, "/", 0);
+
subnode1_offset = check_subnode(fdt, 0, "subnode at 1");
subnode2_offset = check_subnode(fdt, 0, "subnode at 2");
- subnode1_offset_p = fdt_path_offset(fdt, "/subnode at 1");
- subnode2_offset_p = fdt_path_offset(fdt, "/subnode at 2");
-
- if (subnode1_offset != subnode1_offset_p)
- FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)",
- subnode1_offset, subnode1_offset_p);
-
- if (subnode2_offset != subnode2_offset_p)
- FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)",
- subnode2_offset, subnode2_offset_p);
+ check_path_offset(fdt, "/subnode at 1", subnode1_offset);
+ check_path_offset(fdt, "/subnode at 2", subnode2_offset);
subsubnode1_offset = check_subnode(fdt, subnode1_offset, "subsubnode");
subsubnode2_offset = check_subnode(fdt, subnode2_offset, "subsubnode at 0");
subsubnode2_offset2 = check_subnode(fdt, subnode2_offset, "subsubnode");
- subsubnode1_offset_p = fdt_path_offset(fdt, "/subnode at 1/subsubnode");
- subsubnode2_offset_p = fdt_path_offset(fdt, "/subnode at 2/subsubnode at 0");
- subsubnode2_offset2_p = fdt_path_offset(fdt, "/subnode at 2/subsubnode");
-
- if (subsubnode1_offset != subsubnode1_offset_p)
- FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)",
- subsubnode1_offset, subsubnode1_offset_p);
-
- if (subsubnode2_offset != subsubnode2_offset_p)
- FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)",
- subsubnode2_offset, subsubnode2_offset_p);
-
- if (subsubnode2_offset2 != subsubnode2_offset2_p)
- FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)",
- subsubnode2_offset2, subsubnode2_offset2_p);
+ check_path_offset(fdt, "/subnode at 1/subsubnode", subsubnode1_offset);
+ check_path_offset(fdt, "/subnode at 2/subsubnode at 0", subsubnode2_offset);
+ check_path_offset(fdt, "/subnode at 2/subsubnode", subsubnode2_offset2);
PASS();
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git
More information about the Crosstoolchain-logs
mailing list