|
| 1 | +#!/usr/bin/env python |
| 2 | +from doctest import testfile, ELLIPSIS, testmod |
| 3 | +from sys import exit, path as sys_path |
| 4 | +from os.path import dirname |
| 5 | +import importlib |
| 6 | + |
| 7 | + |
| 8 | +def testDoc(filename, name=None): |
| 9 | + print("--- %s: Run tests" % filename) |
| 10 | + failure, nb_test = testfile( |
| 11 | + filename, optionflags=ELLIPSIS, name=name) |
| 12 | + if failure: |
| 13 | + exit(1) |
| 14 | + print("--- %s: End of tests" % filename) |
| 15 | + |
| 16 | + |
| 17 | +def testModule(name): |
| 18 | + print("--- Test module %s" % name) |
| 19 | + module = importlib.import_module(name) |
| 20 | + failure, nb_test = testmod(module) |
| 21 | + if failure: |
| 22 | + exit(1) |
| 23 | + print("--- End of test") |
| 24 | + |
| 25 | + |
| 26 | +def main(): |
| 27 | + ptrace_dir = dirname(__file__) |
| 28 | + sys_path.append(ptrace_dir) |
| 29 | + |
| 30 | + # Test documentation in doc/*.rst files |
| 31 | + # testDoc('doc/c_tools.rst') |
| 32 | + |
| 33 | + # Test documentation of some functions/classes |
| 34 | + testModule("ptrace.ctypes_tools") |
| 35 | + testModule("ptrace.debugger.parse_expr") |
| 36 | + testModule("ptrace.logging_tools") |
| 37 | + testModule("ptrace.signames") |
| 38 | + testModule("ptrace.syscall.socketcall") |
| 39 | + testModule("ptrace.tools") |
| 40 | + |
| 41 | + |
| 42 | +if __name__ == "__main__": |
| 43 | + main() |
0 commit comments