Mercurial > vim
view src/testdir/test_channel_unix.py @ 29340:fba9e366ced4 v9.0.0013
patch 9.0.0013: reproducing memory access errors can be difficult
Commit: https://github.com/vim/vim/commit/fa4873ccfc10e0f278dc46f39d00136fab059b19
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 30 22:13:59 2022 +0100
patch 9.0.0013: reproducing memory access errors can be difficult
Problem: Reproducing memory access errors can be difficult.
Solution: When testing, copy each line to allocated memory, so that valgrind
can detect accessing memory before and/or after it. Fix uncovered
problems.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 30 Jun 2022 23:15:03 +0200 |
parents | cdd13ed3e5cb |
children |
line wrap: on
line source
#!/usr/bin/env python # # Server that will accept connections from a Vim channel. # Used by test_channel.vim. # # This requires Python 2.6 or later. from __future__ import print_function from test_channel import ThreadedTCPServer, TestingRequestHandler, \ writePortInFile import socket import threading import os try: FileNotFoundError except NameError: # Python 2 FileNotFoundError = (IOError, OSError) if not hasattr(socket, "AF_UNIX"): raise NotImplementedError("Unix sockets are not supported on this platform") class ThreadedUnixServer(ThreadedTCPServer): address_family = socket.AF_UNIX class ThreadedUnixRequestHandler(TestingRequestHandler): pass def main(path): server = ThreadedUnixServer(path, ThreadedUnixRequestHandler) # Start a thread with the server. That thread will then start a new thread # for each connection. server_thread = threading.Thread(target=server.serve_forever) server_thread.start() # Signal the test harness we're ready, the port value has no meaning. writePortInFile(1234) print("Listening on {0}".format(server.server_address)) # Main thread terminates, but the server continues running # until server.shutdown() is called. try: while server_thread.is_alive(): server_thread.join(1) except (KeyboardInterrupt, SystemExit): server.shutdown() if __name__ == "__main__": try: os.remove("Xtestsocket") except FileNotFoundError: pass main("Xtestsocket")