dependencies:
pre:
- sudo apt-get update -qq
- - sudo apt-get install -qq cmake libevent-dev libglib2.0-dev libgmime-2.6-dev libluajit-5.1-dev liblua5.1-0-dev libmagic-dev libpcre3-dev libsqlite3-dev libssl-dev make ragel redis-server gcc
+ - sudo apt-get install -qq cmake gcc libevent-dev libglib2.0-dev libgmime-2.6-dev libluajit-5.1-dev liblua5.1-0-dev libmagic-dev libpcre3-dev libsqlite3-dev libssl-dev make python-psutil ragel redis-server
- sudo pip install robotframework
-# - echo $TRAVIS_OS_NAME
-# - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq ; fi
-# - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq cmake libevent-dev libglib2.0-dev libgmime-2.6-dev libluajit-5.1-dev libpcre3-dev libsqlite3-dev libhiredis-dev ; fi
-# - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update ; fi
-# - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install cmake gmime glib luajit pcre hiredis sqlite libevent ; fi
test:
override:
Redis Statistics Teardown
Generic Teardown
- Shutdown Process ${REDIS_PID}
+ Shutdown Process With Children ${REDIS_PID}
Statistics Setup
Generic Setup STATS_PATH_CACHE STATS_PATH_HAM STATS_PATH_SPAM
import grp
import os
import os.path
+import psutil
import pwd
import shutil
import signal
def encode_filename(filename):
return "".join(['%%%0X' % ord(b) for b in filename])
+def get_process_children(pid):
+ children = []
+ for p in psutil.process_iter():
+ # ppid could be int or function depending on library version
+ if callable(p.ppid):
+ ppid = p.ppid()
+ else:
+ ppid = p.ppid
+ if ppid == pid:
+ children.append(p.pid)
+ return children
+
def get_test_directory():
return os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "../..")
def make_temporary_directory():
return tempfile.mkdtemp()
-def process_should_exist(pid):
- pid = int(pid)
- os.kill(pid, 0)
-
def read_log_from_position(filename, offset):
offset = long(offset)
f = open(filename, 'rb')
return a
def shutdown_process(pid):
- pid = int(pid)
- process_should_exist(pid)
i = 0
while i < 100:
try:
os.kill(pid, signal.SIGTERM)
except OSError as e:
assert e.errno == 3
- break
+ return
i += 1
time.sleep(0.1)
+ while i < 200:
+ try:
+ os.kill(pid, signal.SIGKILL)
+ except OSError as e:
+ assert e.errno == 3
+ return
+ i += 1
+ time.sleep(0.1)
+ assert False, "Failed to shutdown process %s" % pid
+
+def shutdown_process_with_children(pid):
+ pid = int(pid)
+ children = get_process_children(pid)
+ shutdown_process(pid)
+ for child in children:
+ shutdown_process(child)
... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite'
Generic Teardown
- Shutdown Process ${RSPAMD_PID}
+ Shutdown Process With Children ${RSPAMD_PID}
Cleanup Temporary Directory ${TMPDIR}
Log Logs