diff options
author | Mark W. Eichin <eichin@thok.org> | 2009-04-13 05:56:16 +0000 |
---|---|---|
committer | Mark W. Eichin <eichin@thok.org> | 2009-04-13 05:56:16 +0000 |
commit | 9be1f2ec0860bdad34774f6eed95ddfbc0ac0b41 (patch) | |
tree | 5db6c013701ed08820871c26bba4dba2a62e13ac /lib/zephyr_tests.txt | |
parent | 2de01dbd7d402298870a8698607c08cf58199fed (diff) |
draft doctest version of the existing tests, to show what they look
like; might serve as a start on a "live API guide" once it is fleshed
out more. Emphasizes the commentary which actually makes a lot of
sense (a bunch of things went into the svn commit logs which really
should have been in-line in the test cases; this approach avoids
that...)
Diffstat (limited to 'lib/zephyr_tests.txt')
-rw-r--r-- | lib/zephyr_tests.txt | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/lib/zephyr_tests.txt b/lib/zephyr_tests.txt new file mode 100644 index 0000000..ddc6598 --- /dev/null +++ b/lib/zephyr_tests.txt @@ -0,0 +1,67 @@ + + +Generic library setup that should be moved into zephyr_tests.py: + + >>> import os + >>> import zephyr_tests + >>> libzephyr_path = os.path.join("../../../build/", "lib/.libs/", "libzephyr.so.4.0.0") + >>> _z = zephyr_tests.libZephyr(libzephyr_path) + +ZInit() got run by libZephyr, internally. Make sure other things +actually got set up: + + >>> assert _z.ZGetFD() == -1 + >>> realm = _z.ZGetRealm() + >>> assert realm + >>> assert realm != "local-realm" + >>> assert _z.ZGetSender() + >>> assert "@" in _z.ZGetSender() + +ZNotice_t structure pseudo-round-trip (needs a lot more explicit +settings and assertions to be a real round-trip test...) + + >>> notice = zephyr_tests.ZNotice_t() + >>> from ctypes import sizeof + >>> assert sizeof(notice) > 150 + >>> from ctypes import c_char_p, c_int + >>> zbuf = c_char_p(0) + >>> zbuflen = c_int(0) + >>> st = _z.ZFormatNotice(notice, zbuf, zbuflen, zephyr_tests.ZNOAUTH) + >>> assert st == 0 + >>> assert zbuf.value.startswith("ZEPH") + >>> new_notice = zephyr_tests.ZNotice_t() + >>> st = _z.ZParseNotice(zbuf, zbuflen, new_notice) + >>> assert st == 0 + >>> assert new_notice.z_version.startswith("ZEPH") + +Should we check for ZEPH0.2 now, or leave that open? + +Simple test of ZCompareUID: + + >>> uid1 = zephyr_tests.ZUnique_Id_t() + >>> uid2 = zephyr_tests.ZUnique_Id_t() + >>> assert _z.ZCompareUID(uid1, uid2), "null uids don't match" + +There's no ZUnique_Id_t constructor - Z_FormatHeader and +Z_NewFormatHeader initialize notice->z_uid directly, so cheat and use +ZNotice_t as the constructor... + + >>> notice1 = zephyr_tests.ZNotice_t() + >>> zbuf = c_char_p(0) + >>> zbuflen = c_int(0) + >>> st = _z.ZFormatNotice(notice1, zbuf, zbuflen, zephyr_tests.ZNOAUTH) + >>> assert st == 0, "ZFormatNotice notice1 failed" + + >>> notice2 = zephyr_tests.ZNotice_t() + >>> zbuf = c_char_p(0) + >>> zbuflen = c_int(0) + >>> st = _z.ZFormatNotice(notice2, zbuf, zbuflen, zephyr_tests.ZNOAUTH) + >>> assert st == 0, "ZFormatNotice notice1 failed" + + >>> assert not _z.ZCompareUID(notice1.z_uid, notice2.z_uid), "distinct notices don't compare as distinct" + +Trivial test of ZExpandRealm, using terribly well known hostnames: + + >>> assert _z.ZExpandRealm("") == "" + >>> assert _z.ZExpandRealm("localhost") == "" + >>> assert _z.ZExpandRealm("bitsy.mit.edu") == "ATHENA.MIT.EDU" |