summaryrefslogtreecommitdiff
path: root/lib/zephyr_tests.py
diff options
context:
space:
mode:
authorGravatar Mark W. Eichin <eichin@thok.org>2009-04-07 07:27:44 +0000
committerGravatar Mark W. Eichin <eichin@thok.org>2009-04-07 07:27:44 +0000
commit6ba8a04b9146e29c6d6e30e579927bccf51002f5 (patch)
tree4cbe85725227f6fa891c3eda6b8339526ac49aad /lib/zephyr_tests.py
parent721679c85dadd2187f1af9296cb32867922d1c9a (diff)
allow a class to override the display of individual fields; since this
is at the class level, it can look at other fields (ie. z_num_hdr_fields) for lengths or other parameters that modify the display. implemented for z_hdr_fields, z_other_fields. probably useful for selecting z_sender_sockaddr values too.
Diffstat (limited to 'lib/zephyr_tests.py')
-rwxr-xr-xlib/zephyr_tests.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/zephyr_tests.py b/lib/zephyr_tests.py
index 8f9ca50..06817ca 100755
--- a/lib/zephyr_tests.py
+++ b/lib/zephyr_tests.py
@@ -28,7 +28,10 @@ def ctypes_pprint(cstruct, indent=""):
for field_name, field_ctype in cstruct._fields_:
field_value = getattr(cstruct, field_name)
print indent + field_name,
- if hasattr(field_value, "pprint"):
+ pprint_name = "pprint_%s" % field_name
+ if hasattr(cstruct, pprint_name):
+ print getattr(cstruct, pprint_name)(indent + " ")
+ elif hasattr(field_value, "pprint"):
print field_value.pprint()
elif hasattr(field_value, "_fields_"):
print
@@ -240,6 +243,17 @@ class ZNotice_t(Structure):
("z_hdr_fields", POINTER(c_char_p)),
# } ZNotice_t;
]
+ def pprint_z_other_fields(self, indent):
+ fields = ["%s%d: %s" % (indent, n, self.z_other_fields[n])
+ for n in range(Z_MAXOTHERFIELDS)]
+ return "\n" + "\n".join(fields)
+ def pprint_z_hdr_fields(self, indent):
+ if not self.z_hdr_fields:
+ return "NULL"
+ fields = ["%s%d: %s" % (indent, n, self.z_hdr_fields[n])
+ for n in range(self.z_num_hdr_fields)]
+ return "\n" + "\n".join(fields)
+
class libZephyr(object):