[Crosstoolchain-logs] [device-tree-compiler] 151/198: Add testcases for fdt_path_offset_namelen()
Hector Oron
zumbi at moszumanska.debian.org
Thu Dec 8 17:07:04 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 9d3649bd3be245c93c9d92024ef4e618179dbad1
Author: David Gibson <david at gibson.dropbear.id.au>
Date: Tue Apr 7 14:41:42 2015 +1000
Add testcases for fdt_path_offset_namelen()
This extends the path_offset testcase to exercise the
fdt_path_offset_namelen() function.
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
tests/path_offset.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/tests/path_offset.c b/tests/path_offset.c
index af53daf..bfebe9f 100644
--- a/tests/path_offset.c
+++ b/tests/path_offset.c
@@ -69,6 +69,26 @@ static void check_path_offset(void *fdt, char *path, int offset)
" %d instead of %d", path, rc, offset);
}
+static void check_path_offset_namelen(void *fdt, char *path, int namelen,
+ int offset)
+{
+ int rc;
+
+ verbose_printf("Checking offset of \"%s\" [first %d characters]"
+ " is %d...\n", path, namelen, offset);
+
+ rc = fdt_path_offset_namelen(fdt, path, namelen);
+ if (rc == offset)
+ return;
+
+ if (rc < 0)
+ FAIL("fdt_path_offset_namelen(\"%s\", %d) failed: %s",
+ path, namelen, fdt_strerror(rc));
+ else
+ FAIL("fdt_path_offset_namelen(\"%s\", %d) returned incorrect"
+ " offset %d instead of %d", path, namelen, rc, offset);
+}
+
int main(int argc, char *argv[])
{
void *fdt;
@@ -102,5 +122,16 @@ int main(int argc, char *argv[])
check_path_offset(fdt, "//subnode at 1///", subnode1_offset);
check_path_offset(fdt, "/subnode at 2////subsubnode", subsubnode2_offset2);
+ /* Test fdt_path_offset_namelen() */
+ check_path_offset_namelen(fdt, "/subnode at 1", 1, 0);
+ check_path_offset_namelen(fdt, "/subnode at 1/subsubnode", 10, subnode1_offset);
+ check_path_offset_namelen(fdt, "/subnode at 1/subsubnode", 11, subnode1_offset);
+ check_path_offset_namelen(fdt, "/subnode at 2TRAILINGGARBAGE", 10, subnode2_offset);
+ check_path_offset_namelen(fdt, "/subnode at 2TRAILINGGARBAGE", 11, -FDT_ERR_NOTFOUND);
+ check_path_offset_namelen(fdt, "/subnode at 2/subsubnode at 0/more", 23, subsubnode2_offset2);
+ check_path_offset_namelen(fdt, "/subnode at 2/subsubnode at 0/more", 22, -FDT_ERR_NOTFOUND);
+ check_path_offset_namelen(fdt, "/subnode at 2/subsubnode at 0/more", 24, subsubnode2_offset2);
+ check_path_offset_namelen(fdt, "/subnode at 2/subsubnode at 0/more", 25, -FDT_ERR_NOTFOUND);
+
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