diff --git a/CMakeLists.txt b/CMakeLists.txt index 7515f518..cf398baf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ set( IXWEBSOCKET_SOURCES ixwebsocket/IXHttpClient.cpp ixwebsocket/IXUrlParser.cpp ixwebsocket/IXSelectInterrupt.cpp + ixwebsocket/IXSelectInterruptPipe.cpp ixwebsocket/IXSelectInterruptFactory.cpp ) @@ -59,14 +60,13 @@ set( IXWEBSOCKET_HEADERS ixwebsocket/IXHttpClient.h ixwebsocket/IXUrlParser.h ixwebsocket/IXSelectInterrupt.h + ixwebsocket/IXSelectInterruptPipe.h ixwebsocket/IXSelectInterruptFactory.h ) # Platform specific code if (APPLE) list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/apple/IXSetThreadName_apple.cpp) - list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSelectInterruptPipe.cpp) - list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSelectInterruptPipe.h) elseif (WIN32) list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/windows/IXSetThreadName_windows.cpp) else() diff --git a/ixwebsocket/IXSelectInterruptFactory.cpp b/ixwebsocket/IXSelectInterruptFactory.cpp index 1e666cbf..f0c09c14 100644 --- a/ixwebsocket/IXSelectInterruptFactory.cpp +++ b/ixwebsocket/IXSelectInterruptFactory.cpp @@ -6,9 +6,7 @@ #include "IXSelectInterruptFactory.h" -#if defined(__linux__) -# include -#elif defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) # include #else # include @@ -18,9 +16,7 @@ namespace ix { std::shared_ptr createSelectInterrupt() { -#if defined(__linux__) - return std::make_shared(); -#elif defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) return std::make_shared(); #else return std::make_shared(); diff --git a/test/run.py b/test/run.py index e75327dd..c18b5631 100644 --- a/test/run.py +++ b/test/run.py @@ -2,6 +2,39 @@ import os import platform import shutil +import subprocess +import threading + + +class Command(object): + """Run system commands with timeout + + From http://www.bo-yang.net/2016/12/01/python-run-command-with-timeout + Python3 might have a builtin way to do that. + """ + def __init__(self, cmd): + self.cmd = cmd + self.process = None + + def run_command(self, capture = False): + self.process = subprocess.Popen(self.cmd, shell=True) + self.process.communicate() + + def run(self, timeout = 5 * 60): + '''5 minutes default timeout''' + thread = threading.Thread(target=self.run_command, args=()) + thread.start() + thread.join(timeout) + + if thread.is_alive(): + print 'Command timeout, kill it: ' + self.cmd + self.process.terminate() + thread.join() + return False, 255 + else: + return True, self.process.returncode + + osName = platform.system() print('os name = {}'.format(osName)) @@ -81,5 +114,6 @@ shutil.copy(os.path.join( # lldb = "lldb --batch -o 'run' -k 'thread backtrace all' -k 'quit 1'" lldb = "" # Disabled for now testCommand = '{} {} {}'.format(lldb, testBinary, os.getenv('TEST', '')) -ret = os.system(testCommand) +command = Command(testCommand) +timedout, ret = command.run() assert ret == 0, 'Test command failed'