]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add generic rspamc result processor
authorAndrew Lewis <nerf@judo.za.org>
Wed, 29 Jun 2016 15:14:50 +0000 (17:14 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Wed, 29 Jun 2016 16:01:15 +0000 (18:01 +0200)
test/functional/cases/general.robot
test/functional/cases/lua.robot
test/functional/cases/statistics.robot
test/functional/lib/rspamd.robot

index 4016b9a6aa0dae54a03470f7ad813a699347842d..aa146b4a9255141d6690009845aa5abd399b1f00 100644 (file)
@@ -13,13 +13,11 @@ ${RSPAMD_SCOPE}     Suite
 *** Test Cases ***
 GTUBE
   ${result} =  Scan Message With Rspamc  ${GTUBE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  GTUBE (
+  Check Rspamc  ${result}  GTUBE (
 
 GTUBE - Encrypted
   ${result} =  Run Rspamc  -p  -h  ${LOCAL_ADDR}:${PORT_NORMAL}  --key  ${KEY_PUB1}  ${GTUBE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  GTUBE (
+  Check Rspamc  ${result}  GTUBE (
 
 GTUBE - Scan File feature
   ${result} =  Scan File  ${LOCAL_ADDR}  ${PORT_NORMAL}  ${GTUBE}
index b8005cd8fd9d0111cd508a6972904aea61936656..46dd15ea0c3d70da23c45738d7a5cfee5ef8d4e2 100644 (file)
@@ -26,6 +26,5 @@ Flags
 Dependencies
   [Setup]  Lua Setup  ${TESTDIR}/lua/deps.lua
   ${result} =  Scan Message With Rspamc  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  DEP10
+  Check Rspamc  ${result}  DEP10
   [Teardown]  Generic Teardown
index d9df49813c24d3abe97b495fbe02e8641c5a48b2..6d0218b56ce06746189510a15dc2ac709bcde391 100644 (file)
@@ -21,21 +21,17 @@ Statistics Setup
 Sqlite Learn - Keyed, siphash
   [Setup]  Statistics Setup  @{ALIASES}  STATS_BACKEND=sqlite3  STATS_HASH=siphash STATS_KEY=${KEY_PVT1}
   ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  learn_spam  ${MESSAGE}
-  Should Contain  ${result.stdout}  success = true
-  Follow Rspamd Log
+  Check Rspamc  ${result}
   ${result} =  Scan Message With Rspamc  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  BAYES_SPAM
+  Check Rspamc  ${result}  BAYES_SPAM
   [Teardown]  Generic Teardown
 
 Sqlite Learn - Keyed, xxhash
   [Setup]  Statistics Setup  @{ALIASES}  STATS_BACKEND=sqlite3  STATS_HASH=xxh  STATS_KEY=${KEY_PVT1}
   ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  learn_spam  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  success = true
+  Check Rspamc  ${result}
   ${result} =  Scan Message With Rspamc  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  BAYES_SPAM
+  Check Rspamc  ${result}  BAYES_SPAM
   [Teardown]  Generic Teardown
 
 Sqlite Learn - Broken Stats Directory
@@ -49,51 +45,39 @@ Sqlite Learn - Empty part
   [Setup]  Statistics Setup  @{ALIASES}  STATS_BACKEND=sqlite3  STATS_HASH=xxh  STATS_KEY=${KEY_PVT1}
   Set Test Variable  ${MESSAGE}  ${TESTDIR}/messages/empty_part.eml
   ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  learn_spam  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  success = true
+  Check Rspamc  ${result}
   ${result} =  Scan Message With Rspamc  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  BAYES_SPAM
+  Check Rspamc  ${result}  BAYES_SPAM
   [Teardown]  Generic Teardown
 
 Sqlite Relearn
   [Setup]  Statistics Setup  @{ALIASES}  STATS_BACKEND=sqlite3  STATS_HASH=xxh  STATS_KEY=${KEY_PVT1}
   ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  learn_spam  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  success = true
+  Check Rspamc  ${result}
   ${result} =  Scan Message With Rspamc  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  BAYES_SPAM
+  Check Rspamc  ${result}  BAYES_SPAM
   ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  learn_ham  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  success = true
+  Check Rspamc  ${result}
   ${result} =  Scan Message With Rspamc  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  BAYES_HAM
+  Check Rspamc  ${result}  BAYES_HAM
   [Teardown]  Generic Teardown
 
 Mmap Learn
   [Setup]  Statistics Setup  @{ALIASES}  STATS_BACKEND=mmap  STATS_HASH=compat  STATS_KEY=${KEY_PVT1}
   ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  learn_spam  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  success = true
+  Check Rspamc  ${result}
   ${result} =  Scan Message With Rspamc  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  BAYES_SPAM
+  Check Rspamc  ${result}  BAYES_SPAM
   [Teardown]  Generic Teardown
 
 Mmap Relearn
   [Setup]  Statistics Setup  @{ALIASES}  STATS_BACKEND=mmap  STATS_HASH=compat  STATS_KEY=${KEY_PVT1}
   ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  learn_spam  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  success = true
+  Check Rspamc  ${result}
   ${result} =  Scan Message With Rspamc  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  BAYES_SPAM
+  Check Rspamc  ${result}  BAYES_SPAM
   ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  learn_ham  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  success = true
+  Check Rspamc  ${result}
   ${result} =  Scan Message With Rspamc  ${MESSAGE}
-  Follow Rspamd Log
-  Should Contain  ${result.stdout}  BAYES_HAM
+  Check Rspamc  ${result}  BAYES_HAM
   [Teardown]  Generic Teardown
index a5ddca20e85078cb2154e3dc0bb4c7a38083aabb..b6180d40d4cd2abad99fae641480ad27cd5c775f 100644 (file)
@@ -4,6 +4,15 @@ Library  OperatingSystem
 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]
+  Follow Rspamd Log
+  Should Contain  ${result.stdout}  ${expected_output}
+  Should Be Equal As Integers  ${result.rc}  ${expected_rc}
+
 Export Rspamd Vars To Suite
   [Arguments]  ${TMPDIR}  ${RSPAMD_LOGPOS}  ${RSPAMD_PID}
   Set Suite Variable  ${TMPDIR}
@@ -41,7 +50,6 @@ Log Logs
 Run Rspamc
   [Arguments]                     @{args}
   ${result} =                     Run Process  ${RSPAMC}  @{args}
-  Should Be Equal As Integers     ${result.rc}  0
   [Return]                        ${result}
 
 Run Rspamd