diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-07-28 13:12:36 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-07-28 13:12:36 +0100 |
commit | f42d44cc228a01d9e4f91de187a38c81fcd50a51 (patch) | |
tree | e1ce834615fe3f513ecad19ad15108d9e7e50e6d | |
parent | 1b152c5db87f6bc306e51a24b5024d0083f9b1bb (diff) | |
download | rspamd-f42d44cc228a01d9e4f91de187a38c81fcd50a51.tar.gz rspamd-f42d44cc228a01d9e4f91de187a38c81fcd50a51.zip |
[Test] Rework tests framework to run in a custom environment
-rw-r--r-- | test/functional/cases/__init__.robot | 9 | ||||
-rw-r--r-- | test/functional/lib/rspamd.py | 31 |
2 files changed, 33 insertions, 7 deletions
diff --git a/test/functional/cases/__init__.robot b/test/functional/cases/__init__.robot index 4b95b9217..3707f507b 100644 --- a/test/functional/cases/__init__.robot +++ b/test/functional/cases/__init__.robot @@ -6,7 +6,10 @@ Variables ../lib/vars.py *** Keywords *** Export Global Variables ${TESTDIR} = Get Test Directory - Set Global Variable ${RSPAMADM} ${TESTDIR}/../../src/rspamadm/rspamadm - Set Global Variable ${RSPAMC} ${TESTDIR}/../../src/client/rspamc - Set Global Variable ${RSPAMD} ${TESTDIR}/../../src/rspamd + ${RSPAMADM} = Get Rspamadm + ${RSPAMC} = Get Rspamc + ${RSPAMD} = Get Rspamd + Set Global Variable ${RSPAMADM} + Set Global Variable ${RSPAMC} + Set Global Variable ${RSPAMD} Set Global Variable ${TESTDIR} diff --git a/test/functional/lib/rspamd.py b/test/functional/lib/rspamd.py index a90b924bf..48716f6cf 100644 --- a/test/functional/lib/rspamd.py +++ b/test/functional/lib/rspamd.py @@ -37,7 +37,29 @@ def get_process_children(pid): return children def get_test_directory(): - return os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "../..") + return os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "../../") + +def get_top_dir(): + if os.environ.get('RSPAMD_TOPDIR'): + return os.environ['RSPAMD_TOPDIR'] + + return get_test_directory() + "../../" + +def get_rspamd(): + if os.environ.get('RSPAMD'): + return os.environ['RSPAMD'] + dname = get_top_dir() + return dname + "src/rspamd" +def get_rspamc(): + if os.environ.get('RSPAMC'): + return os.environ['RSPAMC'] + dname = get_top_dir() + return dname + "src/client/rspamc" +def get_rspamadm(): + if os.environ.get('RSPAMADM'): + return environ['RSPAMADM'] + dname = get_top_dir() + return dname + "src/rspamadm/rspamadm" def make_temporary_directory(): return tempfile.mkdtemp() @@ -71,9 +93,10 @@ def Send_SIGUSR1(pid): os.kill(pid, signal.SIGUSR1) def set_directory_ownership(path, username, groupname): - uid=pwd.getpwnam(username).pw_uid - gid=grp.getgrnam(groupname).gr_gid - os.chown(path, uid, gid) + if os.getuid() == 0: + uid=pwd.getpwnam(username).pw_uid + gid=grp.getgrnam(groupname).gr_gid + os.chown(path, uid, gid) def spamc(addr, port, filename): goo = open(filename, 'rb').read() |