* [PATCH v4] pylibfdt: add FdtRo.get_path()
@ 2022-04-19 19:45 Luca Weiss
[not found] ` <20220419194537.63170-1-luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Luca Weiss @ 2022-04-19 19:45 UTC (permalink / raw)
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA; +Cc: Luca Weiss
Add a new Python method wrapping fdt_get_path() from the C API.
Also add a test for the new method.
Signed-off-by: Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org>
---
Changes since v3:
* add quiet parameter
* return integer error when error is quieted
Changes since v2:
* Remove arbitrary size limit
* Change size calculation to increase exponentially
* Add test to verify we still get exceptions with bad parameters
pylibfdt/libfdt.i | 28 ++++++++++++++++++++++++++++
tests/pylibfdt_tests.py | 13 +++++++++++++
2 files changed, 41 insertions(+)
diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
index ac70762..f9f7e7e 100644
--- a/pylibfdt/libfdt.i
+++ b/pylibfdt/libfdt.i
@@ -443,6 +443,29 @@ class FdtRo(object):
"""
return fdt_get_alias(self._fdt, name)
+ def get_path(self, nodeoffset, quiet=()):
+ """Get the full path of a node
+
+ Args:
+ nodeoffset: Node offset to check
+
+ Returns:
+ Full path to the node
+
+ Raises:
+ FdtException if an error occurs
+ """
+ size = 1024
+ while True:
+ ret, path = fdt_get_path(self._fdt, nodeoffset, size)
+ if ret == -NOSPACE:
+ size = size * 2
+ continue
+ err = check_err(ret, quiet)
+ if err:
+ return err
+ return path
+
def parent_offset(self, nodeoffset, quiet=()):
"""Get the offset of a node's parent
@@ -1115,6 +1138,11 @@ typedef uint32_t fdt32_t;
}
}
+%include "cstring.i"
+
+%cstring_output_maxsize(char *buf, int buflen);
+int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);
+
/* We have both struct fdt_property and a function fdt_property() */
%warnfilter(302) fdt_property;
diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
index 5479363..68d6aaa 100644
--- a/tests/pylibfdt_tests.py
+++ b/tests/pylibfdt_tests.py
@@ -348,6 +348,19 @@ class PyLibfdtBasicTests(unittest.TestCase):
self.assertEqual("/subnode@1/subsubnode", self.fdt3.get_alias('ss1'))
self.assertEqual("/subnode@1/subsubnode/subsubsubnode", self.fdt3.get_alias('sss1'))
+ def testGetPath(self):
+ """Test for the get_path() method"""
+ node = self.fdt.path_offset('/subnode@1')
+ node2 = self.fdt.path_offset('/subnode@1/subsubnode')
+ self.assertEqual("/subnode@1", self.fdt.get_path(node))
+ self.assertEqual("/subnode@1/subsubnode", self.fdt.get_path(node2))
+
+ with self.assertRaises(FdtException) as e:
+ self.fdt.get_path(-1)
+ self.assertEqual(e.exception.err, -libfdt.BADOFFSET)
+
+ self.assertEqual(-libfdt.BADOFFSET, self.fdt.get_path(-1, quiet=(libfdt.BADOFFSET,)))
+
def testParentOffset(self):
"""Test for the parent_offset() method"""
self.assertEqual(-libfdt.NOTFOUND,
--
2.35.3
^ permalink raw reply related [flat|nested] 7+ messages in thread[parent not found: <20220419194537.63170-1-luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org>]
* Re: [PATCH v4] pylibfdt: add FdtRo.get_path() [not found] ` <20220419194537.63170-1-luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> @ 2022-04-19 21:54 ` Simon Glass [not found] ` <CAPnjgZ2izMUDXJ43jSOzXW7DKbuoN5j26MyKZaLn5Wt2gd28wQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Simon Glass @ 2022-04-19 21:54 UTC (permalink / raw) To: Luca Weiss; +Cc: Devicetree Compiler Hi Luca, On Tue, 19 Apr 2022 at 13:49, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > Add a new Python method wrapping fdt_get_path() from the C API. > > Also add a test for the new method. > > Signed-off-by: Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> > --- > Changes since v3: > * add quiet parameter > * return integer error when error is quieted > > Changes since v2: > * Remove arbitrary size limit > * Change size calculation to increase exponentially > * Add test to verify we still get exceptions with bad parameters > > pylibfdt/libfdt.i | 28 ++++++++++++++++++++++++++++ > tests/pylibfdt_tests.py | 13 +++++++++++++ > 2 files changed, 41 insertions(+) Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> You don't check for when it is output of space, but I think that is OK. > > diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i > index ac70762..f9f7e7e 100644 > --- a/pylibfdt/libfdt.i > +++ b/pylibfdt/libfdt.i > @@ -443,6 +443,29 @@ class FdtRo(object): > """ > return fdt_get_alias(self._fdt, name) > > + def get_path(self, nodeoffset, quiet=()): > + """Get the full path of a node > + > + Args: > + nodeoffset: Node offset to check > + > + Returns: > + Full path to the node > + > + Raises: > + FdtException if an error occurs > + """ > + size = 1024 > + while True: > + ret, path = fdt_get_path(self._fdt, nodeoffset, size) > + if ret == -NOSPACE: > + size = size * 2 > + continue > + err = check_err(ret, quiet) > + if err: > + return err > + return path > + > def parent_offset(self, nodeoffset, quiet=()): > """Get the offset of a node's parent > > @@ -1115,6 +1138,11 @@ typedef uint32_t fdt32_t; > } > } > > +%include "cstring.i" > + > +%cstring_output_maxsize(char *buf, int buflen); > +int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen); > + > /* We have both struct fdt_property and a function fdt_property() */ > %warnfilter(302) fdt_property; > > diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py > index 5479363..68d6aaa 100644 > --- a/tests/pylibfdt_tests.py > +++ b/tests/pylibfdt_tests.py > @@ -348,6 +348,19 @@ class PyLibfdtBasicTests(unittest.TestCase): > self.assertEqual("/subnode@1/subsubnode", self.fdt3.get_alias('ss1')) > self.assertEqual("/subnode@1/subsubnode/subsubsubnode", self.fdt3.get_alias('sss1')) > > + def testGetPath(self): > + """Test for the get_path() method""" > + node = self.fdt.path_offset('/subnode@1') > + node2 = self.fdt.path_offset('/subnode@1/subsubnode') > + self.assertEqual("/subnode@1", self.fdt.get_path(node)) > + self.assertEqual("/subnode@1/subsubnode", self.fdt.get_path(node2)) > + > + with self.assertRaises(FdtException) as e: > + self.fdt.get_path(-1) > + self.assertEqual(e.exception.err, -libfdt.BADOFFSET) > + > + self.assertEqual(-libfdt.BADOFFSET, self.fdt.get_path(-1, quiet=(libfdt.BADOFFSET,))) > + > def testParentOffset(self): > """Test for the parent_offset() method""" > self.assertEqual(-libfdt.NOTFOUND, > -- > 2.35.3 > Regards, Simon ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <CAPnjgZ2izMUDXJ43jSOzXW7DKbuoN5j26MyKZaLn5Wt2gd28wQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH v4] pylibfdt: add FdtRo.get_path() [not found] ` <CAPnjgZ2izMUDXJ43jSOzXW7DKbuoN5j26MyKZaLn5Wt2gd28wQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2022-04-20 2:56 ` David Gibson 2022-04-20 18:19 ` Luca Weiss 0 siblings, 1 reply; 7+ messages in thread From: David Gibson @ 2022-04-20 2:56 UTC (permalink / raw) To: Simon Glass; +Cc: Luca Weiss, Devicetree Compiler [-- Attachment #1: Type: text/plain, Size: 4015 bytes --] On Tue, Apr 19, 2022 at 03:54:07PM -0600, Simon Glass wrote: > Hi Luca, > > On Tue, 19 Apr 2022 at 13:49, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > > > Add a new Python method wrapping fdt_get_path() from the C API. > > > > Also add a test for the new method. > > > > Signed-off-by: Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> > > --- > > Changes since v3: > > * add quiet parameter > > * return integer error when error is quieted > > > > Changes since v2: > > * Remove arbitrary size limit > > * Change size calculation to increase exponentially > > * Add test to verify we still get exceptions with bad parameters > > > > pylibfdt/libfdt.i | 28 ++++++++++++++++++++++++++++ > > tests/pylibfdt_tests.py | 13 +++++++++++++ > > 2 files changed, 41 insertions(+) > > Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > > You don't check for when it is output of space, but I think that is > OK. Right, a testcase for that would be good, but it can be a follow up. Applied. > > > > > diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i > > index ac70762..f9f7e7e 100644 > > --- a/pylibfdt/libfdt.i > > +++ b/pylibfdt/libfdt.i > > @@ -443,6 +443,29 @@ class FdtRo(object): > > """ > > return fdt_get_alias(self._fdt, name) > > > > + def get_path(self, nodeoffset, quiet=()): > > + """Get the full path of a node > > + > > + Args: > > + nodeoffset: Node offset to check > > + > > + Returns: > > + Full path to the node > > + > > + Raises: > > + FdtException if an error occurs > > + """ > > + size = 1024 > > + while True: > > + ret, path = fdt_get_path(self._fdt, nodeoffset, size) > > + if ret == -NOSPACE: > > + size = size * 2 > > + continue > > + err = check_err(ret, quiet) > > + if err: > > + return err > > + return path > > + > > def parent_offset(self, nodeoffset, quiet=()): > > """Get the offset of a node's parent > > > > @@ -1115,6 +1138,11 @@ typedef uint32_t fdt32_t; > > } > > } > > > > +%include "cstring.i" > > + > > +%cstring_output_maxsize(char *buf, int buflen); > > +int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen); > > + > > /* We have both struct fdt_property and a function fdt_property() */ > > %warnfilter(302) fdt_property; > > > > diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py > > index 5479363..68d6aaa 100644 > > --- a/tests/pylibfdt_tests.py > > +++ b/tests/pylibfdt_tests.py > > @@ -348,6 +348,19 @@ class PyLibfdtBasicTests(unittest.TestCase): > > self.assertEqual("/subnode@1/subsubnode", self.fdt3.get_alias('ss1')) > > self.assertEqual("/subnode@1/subsubnode/subsubsubnode", self.fdt3.get_alias('sss1')) > > > > + def testGetPath(self): > > + """Test for the get_path() method""" > > + node = self.fdt.path_offset('/subnode@1') > > + node2 = self.fdt.path_offset('/subnode@1/subsubnode') > > + self.assertEqual("/subnode@1", self.fdt.get_path(node)) > > + self.assertEqual("/subnode@1/subsubnode", self.fdt.get_path(node2)) > > + > > + with self.assertRaises(FdtException) as e: > > + self.fdt.get_path(-1) > > + self.assertEqual(e.exception.err, -libfdt.BADOFFSET) > > + > > + self.assertEqual(-libfdt.BADOFFSET, self.fdt.get_path(-1, quiet=(libfdt.BADOFFSET,))) > > + > > def testParentOffset(self): > > """Test for the parent_offset() method""" > > self.assertEqual(-libfdt.NOTFOUND, > > > > Regards, > Simon > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] pylibfdt: add FdtRo.get_path() 2022-04-20 2:56 ` David Gibson @ 2022-04-20 18:19 ` Luca Weiss 2022-04-20 21:29 ` Simon Glass 2022-04-26 6:28 ` David Gibson 0 siblings, 2 replies; 7+ messages in thread From: Luca Weiss @ 2022-04-20 18:19 UTC (permalink / raw) To: Simon Glass, David Gibson; +Cc: Devicetree Compiler Hi Simon and David, On Mittwoch, 20. April 2022 04:56:15 CEST David Gibson wrote: > On Tue, Apr 19, 2022 at 03:54:07PM -0600, Simon Glass wrote: > > Hi Luca, > > > > On Tue, 19 Apr 2022 at 13:49, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > > Add a new Python method wrapping fdt_get_path() from the C API. > > > > > > Also add a test for the new method. > > > > > > Signed-off-by: Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> > > > --- > > > Changes since v3: > > > * add quiet parameter > > > * return integer error when error is quieted > > > > > > Changes since v2: > > > * Remove arbitrary size limit > > > * Change size calculation to increase exponentially > > > * Add test to verify we still get exceptions with bad parameters > > > > > > pylibfdt/libfdt.i | 28 ++++++++++++++++++++++++++++ > > > tests/pylibfdt_tests.py | 13 +++++++++++++ > > > 2 files changed, 41 insertions(+) > > > > Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > > > > You don't check for when it is output of space, but I think that is > > OK. > > Right, a testcase for that would be good, but it can be a follow up. I don't quite understand what you mean "is output of space". Maybe you mean a test for when the string is longer than 1024 characters ("size = 1024") so the size increase gets triggered? If yes, then I did test that manually before by setting the value absurdly low. Not sure how to properly check that in the tests though. Add a node with a super long name into the test dtb? > > Applied. Thanks! Regards Luca > > > > diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i > > > index ac70762..f9f7e7e 100644 > > > --- a/pylibfdt/libfdt.i > > > +++ b/pylibfdt/libfdt.i > > > > > > @@ -443,6 +443,29 @@ class FdtRo(object): > > > """ > > > return fdt_get_alias(self._fdt, name) > > > > > > + def get_path(self, nodeoffset, quiet=()): > > > + """Get the full path of a node > > > + > > > + Args: > > > + nodeoffset: Node offset to check > > > + > > > + Returns: > > > + Full path to the node > > > + > > > + Raises: > > > + FdtException if an error occurs > > > + """ > > > + size = 1024 > > > + while True: > > > + ret, path = fdt_get_path(self._fdt, nodeoffset, size) > > > + if ret == -NOSPACE: > > > + size = size * 2 > > > + continue > > > + err = check_err(ret, quiet) > > > + if err: > > > + return err > > > + return path > > > + > > > > > > def parent_offset(self, nodeoffset, quiet=()): > > > """Get the offset of a node's parent > > > > > > @@ -1115,6 +1138,11 @@ typedef uint32_t fdt32_t; > > > > > > } > > > > > > } > > > > > > +%include "cstring.i" > > > + > > > +%cstring_output_maxsize(char *buf, int buflen); > > > +int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int > > > buflen); > > > + > > > > > > /* We have both struct fdt_property and a function fdt_property() */ > > > %warnfilter(302) fdt_property; > > > > > > diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py > > > index 5479363..68d6aaa 100644 > > > --- a/tests/pylibfdt_tests.py > > > +++ b/tests/pylibfdt_tests.py > > > > > > @@ -348,6 +348,19 @@ class PyLibfdtBasicTests(unittest.TestCase): > > > self.assertEqual("/subnode@1/subsubnode", > > > self.fdt3.get_alias('ss1')) > > > self.assertEqual("/subnode@1/subsubnode/subsubsubnode", > > > self.fdt3.get_alias('sss1'))> > > > > + def testGetPath(self): > > > + """Test for the get_path() method""" > > > + node = self.fdt.path_offset('/subnode@1') > > > + node2 = self.fdt.path_offset('/subnode@1/subsubnode') > > > + self.assertEqual("/subnode@1", self.fdt.get_path(node)) > > > + self.assertEqual("/subnode@1/subsubnode", > > > self.fdt.get_path(node2)) + > > > + with self.assertRaises(FdtException) as e: > > > + self.fdt.get_path(-1) > > > + self.assertEqual(e.exception.err, -libfdt.BADOFFSET) > > > + > > > + self.assertEqual(-libfdt.BADOFFSET, self.fdt.get_path(-1, > > > quiet=(libfdt.BADOFFSET,))) + > > > > > > def testParentOffset(self): > > > """Test for the parent_offset() method""" > > > self.assertEqual(-libfdt.NOTFOUND, > > > > Regards, > > Simon ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] pylibfdt: add FdtRo.get_path() 2022-04-20 18:19 ` Luca Weiss @ 2022-04-20 21:29 ` Simon Glass [not found] ` <CAPnjgZ2CjKLrCXEcBH0vTN77d7zk29dxnmRta4tTR_Th2arBzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2022-04-26 6:28 ` David Gibson 1 sibling, 1 reply; 7+ messages in thread From: Simon Glass @ 2022-04-20 21:29 UTC (permalink / raw) To: Luca Weiss; +Cc: David Gibson, Devicetree Compiler Hi Luca, On Wed, 20 Apr 2022 at 12:20, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > Hi Simon and David, > > On Mittwoch, 20. April 2022 04:56:15 CEST David Gibson wrote: > > On Tue, Apr 19, 2022 at 03:54:07PM -0600, Simon Glass wrote: > > > Hi Luca, > > > > > > On Tue, 19 Apr 2022 at 13:49, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > > > Add a new Python method wrapping fdt_get_path() from the C API. > > > > > > > > Also add a test for the new method. > > > > > > > > Signed-off-by: Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> > > > > --- > > > > Changes since v3: > > > > * add quiet parameter > > > > * return integer error when error is quieted > > > > > > > > Changes since v2: > > > > * Remove arbitrary size limit > > > > * Change size calculation to increase exponentially > > > > * Add test to verify we still get exceptions with bad parameters > > > > > > > > pylibfdt/libfdt.i | 28 ++++++++++++++++++++++++++++ > > > > tests/pylibfdt_tests.py | 13 +++++++++++++ > > > > 2 files changed, 41 insertions(+) > > > > > > Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > > > > > > You don't check for when it is output of space, but I think that is > > > OK. > > > > Right, a testcase for that would be good, but it can be a follow up. > > I don't quite understand what you mean "is output of space". is out of space (sorry) > > Maybe you mean a test for when the string is longer than 1024 characters > ("size = 1024") so the size increase gets triggered? > > If yes, then I did test that manually before by setting the value absurdly > low. Not sure how to properly check that in the tests though. Add a node with > a super long name into the test dtb? Another option is to add a parameter for the max size, just for testing, but I doubt David would like that! You could have a SIZE_INCREMENT = 1024 at the top of the file, then change it in a try/finally clause in your test. > > > > > Applied. > > Thanks! > > Regards > Luca Regards, Simon ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <CAPnjgZ2CjKLrCXEcBH0vTN77d7zk29dxnmRta4tTR_Th2arBzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH v4] pylibfdt: add FdtRo.get_path() [not found] ` <CAPnjgZ2CjKLrCXEcBH0vTN77d7zk29dxnmRta4tTR_Th2arBzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2022-04-26 6:29 ` David Gibson 0 siblings, 0 replies; 7+ messages in thread From: David Gibson @ 2022-04-26 6:29 UTC (permalink / raw) To: Simon Glass; +Cc: Luca Weiss, Devicetree Compiler [-- Attachment #1: Type: text/plain, Size: 2630 bytes --] On Wed, Apr 20, 2022 at 03:29:49PM -0600, Simon Glass wrote: > Hi Luca, > > On Wed, 20 Apr 2022 at 12:20, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > > > Hi Simon and David, > > > > On Mittwoch, 20. April 2022 04:56:15 CEST David Gibson wrote: > > > On Tue, Apr 19, 2022 at 03:54:07PM -0600, Simon Glass wrote: > > > > Hi Luca, > > > > > > > > On Tue, 19 Apr 2022 at 13:49, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > > > > Add a new Python method wrapping fdt_get_path() from the C API. > > > > > > > > > > Also add a test for the new method. > > > > > > > > > > Signed-off-by: Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> > > > > > --- > > > > > Changes since v3: > > > > > * add quiet parameter > > > > > * return integer error when error is quieted > > > > > > > > > > Changes since v2: > > > > > * Remove arbitrary size limit > > > > > * Change size calculation to increase exponentially > > > > > * Add test to verify we still get exceptions with bad parameters > > > > > > > > > > pylibfdt/libfdt.i | 28 ++++++++++++++++++++++++++++ > > > > > tests/pylibfdt_tests.py | 13 +++++++++++++ > > > > > 2 files changed, 41 insertions(+) > > > > > > > > Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > > > > > > > > You don't check for when it is output of space, but I think that is > > > > OK. > > > > > > Right, a testcase for that would be good, but it can be a follow up. > > > > I don't quite understand what you mean "is output of space". > > is out of space (sorry) > > > > > Maybe you mean a test for when the string is longer than 1024 characters > > ("size = 1024") so the size increase gets triggered? > > > > If yes, then I did test that manually before by setting the value absurdly > > low. Not sure how to properly check that in the tests though. Add a node with > > a super long name into the test dtb? > > Another option is to add a parameter for the max size, just for > testing, but I doubt David would like that! Actually I'm fine with adding a "hint" size as a parameter - as long as it's optional with a a sensible default. > You could have a SIZE_INCREMENT = 1024 at the top of the file, then > change it in a try/finally clause in your test. > > > > > > > > > Applied. > > > > Thanks! > > > > Regards > > Luca > > Regards, > Simon > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] pylibfdt: add FdtRo.get_path() 2022-04-20 18:19 ` Luca Weiss 2022-04-20 21:29 ` Simon Glass @ 2022-04-26 6:28 ` David Gibson 1 sibling, 0 replies; 7+ messages in thread From: David Gibson @ 2022-04-26 6:28 UTC (permalink / raw) To: Luca Weiss; +Cc: Simon Glass, Devicetree Compiler [-- Attachment #1: Type: text/plain, Size: 2370 bytes --] On Wed, Apr 20, 2022 at 08:19:43PM +0200, Luca Weiss wrote: > Hi Simon and David, > > On Mittwoch, 20. April 2022 04:56:15 CEST David Gibson wrote: > > On Tue, Apr 19, 2022 at 03:54:07PM -0600, Simon Glass wrote: > > > Hi Luca, > > > > > > On Tue, 19 Apr 2022 at 13:49, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > > > Add a new Python method wrapping fdt_get_path() from the C API. > > > > > > > > Also add a test for the new method. > > > > > > > > Signed-off-by: Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> > > > > --- > > > > Changes since v3: > > > > * add quiet parameter > > > > * return integer error when error is quieted > > > > > > > > Changes since v2: > > > > * Remove arbitrary size limit > > > > * Change size calculation to increase exponentially > > > > * Add test to verify we still get exceptions with bad parameters > > > > > > > > pylibfdt/libfdt.i | 28 ++++++++++++++++++++++++++++ > > > > tests/pylibfdt_tests.py | 13 +++++++++++++ > > > > 2 files changed, 41 insertions(+) > > > > > > Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > > > > > > You don't check for when it is output of space, but I think that is > > > OK. > > > > Right, a testcase for that would be good, but it can be a follow up. > > I don't quite understand what you mean "is output of space". > > Maybe you mean a test for when the string is longer than 1024 characters > ("size = 1024") so the size increase gets triggered? That's what I was thinking, yes. > If yes, then I did test that manually before by setting the value absurdly > low. Not sure how to properly check that in the tests though. Add a node with > a super long name into the test dtb? Not to the main "test_tree1" dtb, but you could use a different dtb with a large property. You could make one, or use an existing one with a long property - look for references to 'lorem.txt` in run_tests.sh for one example already creating and using a long property. Alternatively you could add an extra parameter to the Python wrapper giving a "hint" size for the initial buffer. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-04-26 6:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-19 19:45 [PATCH v4] pylibfdt: add FdtRo.get_path() Luca Weiss
[not found] ` <20220419194537.63170-1-luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org>
2022-04-19 21:54 ` Simon Glass
[not found] ` <CAPnjgZ2izMUDXJ43jSOzXW7DKbuoN5j26MyKZaLn5Wt2gd28wQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-04-20 2:56 ` David Gibson
2022-04-20 18:19 ` Luca Weiss
2022-04-20 21:29 ` Simon Glass
[not found] ` <CAPnjgZ2CjKLrCXEcBH0vTN77d7zk29dxnmRta4tTR_Th2arBzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-04-26 6:29 ` David Gibson
2022-04-26 6:28 ` David Gibson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).