summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Mark W. Eichin <eichin@thok.org>2009-04-16 04:43:50 +0000
committerGravatar Mark W. Eichin <eichin@thok.org>2009-04-16 04:43:50 +0000
commit0aea3fbd83491c5a57e98d18ebe682505b0978f4 (patch)
treec103a05197e43c799761c59fc11e15fc42e129e7 /lib
parent94661ad2d0b4a042d55c6e0e2cc4284ec216f0d9 (diff)
wrap ZMakeAscii
clone it too test the wrapper against the clone fix typo in description add todos add future-coverage list
Diffstat (limited to 'lib')
-rwxr-xr-xlib/zephyr_tests.py22
-rw-r--r--lib/zephyr_tests.txt33
2 files changed, 53 insertions, 2 deletions
diff --git a/lib/zephyr_tests.py b/lib/zephyr_tests.py
index 041c2de..12864e0 100755
--- a/lib/zephyr_tests.py
+++ b/lib/zephyr_tests.py
@@ -325,6 +325,7 @@ class libZephyr(object):
"ZExpandRealm",
"ZOpenPort",
"ZClosePort",
+ "ZMakeAscii",
]
def __init__(self, library_path=None):
"""connect to the library and build the wrappers"""
@@ -405,9 +406,30 @@ class libZephyr(object):
POINTER(c_ushort), # port
]
+ # Code_t
+ # ZMakeAscii(register char *ptr,
+ # int len,
+ # unsigned char *field,
+ # int num)
+ self.ZMakeAscii.argtypes = [
+ c_char_p, # ptr
+ c_int, # len
+ c_char_p, # field; c_uchar_p?
+ c_int, # num
+ ]
+
+
# library-specific setup...
self.ZInitialize()
+def py_make_ascii(input):
+ """reference ZMakeAscii expressed as python..."""
+ hexes = ["%02X" % ord(ch) for ch in input]
+ output = []
+ for i in range(0, len(hexes), 4):
+ output.append("0x" + "".join(hexes[i:i+4]))
+ return " ".join(output)
+
diff --git a/lib/zephyr_tests.txt b/lib/zephyr_tests.txt
index c817aa1..a6e7998 100644
--- a/lib/zephyr_tests.txt
+++ b/lib/zephyr_tests.txt
@@ -84,7 +84,7 @@ Trivial test of ZExpandRealm, using terribly well known hostnames:
>>> if not Zauthtype: assert _z.ZExpandRealm("localhost") == "LOCALHOST"
>>> if not Zauthtype: assert _z.ZExpandRealm("bitsy.mit.edu") == "BITSY.MIT.EDU"
-Trivial test of ZopenPort and ZClosePort:
+Trivial test of ZOpenPort and ZClosePort:
>>> from ctypes import c_ushort
>>> port = c_ushort(0)
@@ -98,6 +98,21 @@ TODO: consider checking that ZGetFD is returning a socket on that port.
>>> assert _z.ZClosePort() == 0
>>> assert _z.ZGetFD() == -1
+TODO: check that ZGetDestAddr points somewhere, too.
+
+ZMakeAscii takes a target buffer and length and an input buffer and
+length, and generates the "special" Zephyr encoding.
+
+ >>> sample = "test\0message"
+ >>> ref = zephyr_tests.py_make_ascii(sample)
+ >>> from ctypes import create_string_buffer
+ >>> outlen = len(sample) * 6
+ >>> outbuf = create_string_buffer(outlen)
+ >>> st = _z.ZMakeAscii(outbuf, outlen, sample, len(sample))
+ >>> assert st == 0
+ >>> assert outbuf.value == ref, "%r != %r" % (outbuf.value, ref)
+
+
Coverage:
Files complete:
@@ -135,4 +150,18 @@ ZGetLocations (ZGetLocs.c)
ZGetSubscriptions (ZGetSubs.c)
ZGetWGPort (ZGetWGPort.c)
ZIfNotice (ZIfNotice.c)
-(...continue with ZInit.c...)
+ZGetRealm (ZInit.c)
+ZQLength (ZInit.c)
+ZGetDestAddr (ZInit.c)
+ZLocateUser (ZLocateU.c)
+ZInitLocationInfo (ZLocations.c)
+ZSetLocation (ZLocations.c)
+ZUnsetLocation (ZLocations.c)
+ZFlushMyLocations (ZLocations.c)
+ZParseExposureLevel (ZLocations.c)
+Z_SendLocation (ZLocations.c)
+ZMakeAscii32 (ZMakeAscii.c)
+ZMakeAscii16 (ZMakeAscii.c)
+ZMakeZcode32 (ZMakeZcode.c)
+ZMakeZcode (ZMakeZcode.c)
+(...continue with ZMkAuth.c...)