aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional/lib/rspamd.robot
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2016-07-10 13:39:33 +0200
committerAndrew Lewis <nerf@judo.za.org>2016-07-10 13:39:33 +0200
commitf0349d47ad137f8d965377e2e037bff25e009f8b (patch)
treea99478f62bac7c0e5ffe6a9a847b47b7edc8d359 /test/functional/lib/rspamd.robot
parent14803e9faeefeee69e97902573f3e367ceaf9744 (diff)
downloadrspamd-f0349d47ad137f8d965377e2e037bff25e009f8b.tar.gz
rspamd-f0349d47ad137f8d965377e2e037bff25e009f8b.zip
[Test] Some basic functional tests for mime_types module & archives
- Also some new features for Check Rspamc function - Run rspamd/rspamc with LD_LIBRARY_PATH
Diffstat (limited to 'test/functional/lib/rspamd.robot')
-rw-r--r--test/functional/lib/rspamd.robot40
1 files changed, 32 insertions, 8 deletions
diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot
index ded537e03..eb70d4c43 100644
--- a/test/functional/lib/rspamd.robot
+++ b/test/functional/lib/rspamd.robot
@@ -5,13 +5,36 @@ Library Process
*** Keywords ***
Check Rspamc
- [Arguments] ${result} @{args}
- ${arglen} = Get Length ${args}
- ${expected_output} = Set Variable If ${arglen} < 1 success = true @{args}[0]
- ${expected_rc} = Set Variable If ${arglen} < 2 0 @{args}[1]
+ [Arguments] ${result} @{args} &{kwargs}
Follow Rspamd Log
- Should Contain ${result.stdout} ${expected_output}
- Should Be Equal As Integers ${result.rc} ${expected_rc}
+ Run Keyword If ${result.rc} != 0 Log ${result.stderr}
+ ${has_rc} = Evaluate 'rc' in $kwargs
+ ${inverse} = Evaluate 'inverse' in $kwargs
+ ${re} = Evaluate 're' in $kwargs
+ ${rc} = Set Variable If ${has_rc} == True &{kwargs}[rc] 0
+ : FOR ${i} IN @{args}
+ \ Run Keyword If ${re} == True Check Rspamc Match Regexp ${result.stdout} ${i} ${inverse}
+ \ ... ELSE Check Rspamc Match String ${result.stdout} ${i} ${inverse}
+ Run Keyword If @{args} == @{EMPTY} Check Rspamc Match Default ${result.stdout} ${inverse}
+ ${rc_nocheck} = Evaluate 'rc_nocheck' in $kwargs
+ Run Keyword If ${rc_nocheck} == True Return From Keyword
+ Run Keyword If ${inverse} == False Should Be Equal As Integers ${result.rc} ${rc}
+ ... ELSE Should Not Be Equal As Integers ${result.rc} ${rc}
+
+Check Rspamc Match Default
+ [Arguments] ${subject} ${inverse}
+ Run Keyword If ${inverse} == False Should Contain ${subject} success = true
+ ... ELSE Should Not Contain ${subject} success = true
+
+Check Rspamc Match Regexp
+ [Arguments] ${subject} ${re} ${inverse}
+ Run Keyword If ${inverse} == False Should Match Regexp ${subject} ${re}
+ ... ELSE Should Not Match Regexp ${subject} ${re}
+
+Check Rspamc Match String
+ [Arguments] ${subject} ${str} ${inverse}
+ Run Keyword If ${inverse} == False Should Contain ${subject} ${str}
+ ... ELSE Should Not Contain ${subject} ${str}
Export Rspamd Vars To Suite
[Arguments] ${TMPDIR} ${RSPAMD_LOGPOS} ${RSPAMD_PID}
@@ -60,7 +83,7 @@ Run Redis
Run Rspamc
[Arguments] @{args}
- ${result} = Run Process ${RSPAMC} @{args}
+ ${result} = Run Process ${RSPAMC} @{args} env:LD_LIBRARY_PATH=${TESTDIR}/../../contrib/aho-corasick
[Return] ${result}
Run Rspamd
@@ -78,7 +101,8 @@ Run Rspamd
Log ${config}
Create File ${TMPDIR}/rspamd.conf ${config}
${result} = Run Process ${RSPAMD} -u ${RSPAMD_USER} -g ${RSPAMD_GROUP}
- ... -c ${TMPDIR}/rspamd.conf
+ ... -c ${TMPDIR}/rspamd.conf env:LD_LIBRARY_PATH=${TESTDIR}/../../contrib/aho-corasick
+ Run Keyword If ${result.rc} != 0 Log ${result.stderr}
${rspamd_logpos} = Log Logs ${TMPDIR}/rspamd.log 0
Should Be Equal As Integers ${result.rc} 0
${rspamd_pid} = Get File ${TMPDIR}/rspamd.pid