summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/CMakeLists.txt14
-rw-r--r--test/lua/busted.lua (renamed from test/busted.lua)0
-rw-r--r--test/lua/busted/compatibility.lua (renamed from test/busted/compatibility.lua)0
-rw-r--r--test/lua/busted/context.lua (renamed from test/busted/context.lua)0
-rw-r--r--test/lua/busted/core.lua (renamed from test/busted/core.lua)0
-rw-r--r--test/lua/busted/done.lua (renamed from test/busted/done.lua)0
-rw-r--r--test/lua/busted/environment.lua (renamed from test/busted/environment.lua)0
-rw-r--r--test/lua/busted/init.lua (renamed from test/busted/init.lua)0
-rw-r--r--test/lua/busted/languages/ar.lua (renamed from test/busted/languages/ar.lua)0
-rw-r--r--test/lua/busted/languages/de.lua (renamed from test/busted/languages/de.lua)0
-rw-r--r--test/lua/busted/languages/en.lua (renamed from test/busted/languages/en.lua)0
-rw-r--r--test/lua/busted/languages/fr.lua (renamed from test/busted/languages/fr.lua)0
-rw-r--r--test/lua/busted/languages/ja.lua (renamed from test/busted/languages/ja.lua)0
-rw-r--r--test/lua/busted/languages/nl.lua (renamed from test/busted/languages/nl.lua)0
-rw-r--r--test/lua/busted/languages/ru.lua (renamed from test/busted/languages/ru.lua)0
-rw-r--r--test/lua/busted/languages/th.lua (renamed from test/busted/languages/th.lua)0
-rw-r--r--test/lua/busted/languages/ua.lua (renamed from test/busted/languages/ua.lua)0
-rw-r--r--test/lua/busted/languages/zh.lua (renamed from test/busted/languages/zh.lua)0
-rw-r--r--test/lua/busted/modules/configuration_loader.lua (renamed from test/busted/modules/configuration_loader.lua)0
-rw-r--r--test/lua/busted/modules/files/lua.lua (renamed from test/busted/modules/files/lua.lua)0
-rw-r--r--test/lua/busted/modules/files/moonscript.lua (renamed from test/busted/modules/files/moonscript.lua)0
-rw-r--r--test/lua/busted/modules/files/terra.lua (renamed from test/busted/modules/files/terra.lua)0
-rw-r--r--test/lua/busted/modules/helper_loader.lua (renamed from test/busted/modules/helper_loader.lua)0
-rw-r--r--test/lua/busted/modules/luacov.lua (renamed from test/busted/modules/luacov.lua)0
-rw-r--r--test/lua/busted/modules/output_handler_loader.lua (renamed from test/busted/modules/output_handler_loader.lua)0
-rw-r--r--test/lua/busted/modules/test_file_loader.lua (renamed from test/busted/modules/test_file_loader.lua)0
-rw-r--r--test/lua/busted/outputHandlers/TAP.lua (renamed from test/busted/outputHandlers/TAP.lua)0
-rw-r--r--test/lua/busted/outputHandlers/base.lua (renamed from test/busted/outputHandlers/base.lua)0
-rw-r--r--test/lua/busted/outputHandlers/json.lua (renamed from test/busted/outputHandlers/json.lua)0
-rw-r--r--test/lua/busted/outputHandlers/junit.lua (renamed from test/busted/outputHandlers/junit.lua)0
-rw-r--r--test/lua/busted/outputHandlers/plainTerminal.lua (renamed from test/busted/outputHandlers/plainTerminal.lua)0
-rw-r--r--test/lua/busted/outputHandlers/sound.lua (renamed from test/busted/outputHandlers/sound.lua)0
-rw-r--r--test/lua/busted/outputHandlers/utfTerminal.lua (renamed from test/busted/outputHandlers/utfTerminal.lua)0
-rw-r--r--test/lua/busted/runner.lua (renamed from test/busted/runner.lua)0
-rw-r--r--test/lua/busted/status.lua (renamed from test/busted/status.lua)0
-rw-r--r--test/lua/busted/utils.lua (renamed from test/busted/utils.lua)0
-rw-r--r--test/lua/rsa.lua60
-rw-r--r--test/rspamd_lua_test.c10
38 files changed, 55 insertions, 29 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 9932fb87d..32d5334cb 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -23,9 +23,17 @@ TARGET_LINK_LIBRARIES(rspamd-test ${RSPAMD_REQUIRED_LIBRARIES})
TARGET_LINK_LIBRARIES(rspamd-test stemmer)
IF(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
- FILE(COPY "${CMAKE_CURRENT_SOURCE_DIR}/busted.lua"
- "${CMAKE_CURRENT_SOURCE_DIR}/busted"
- "${CMAKE_CURRENT_SOURCE_DIR}/lua"
+ FILE(COPY "${CMAKE_CURRENT_SOURCE_DIR}/lua"
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+
+ # Also add dependencies for convenience
+ FILE(GLOB LUA_TESTS "${CMAKE_CURRENT_SOURCE_DIR}/lua/*")
+ FOREACH(_LF IN LISTS "${LUA_TESTS}")
+ GET_FILENAME_COMPONENT(_NM _LF NAME)
+ ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_NM}"
+ "${CMAKE_COMMAND} -E copy_if_different ${_LF} ${CMAKE_CURRENT_BINARY_DIR}/${_NM}"
+ )
+ ADD_DEPENDENCIES(rspamd-test "${CMAKE_CURRENT_BINARY_DIR}/${_NM}")
+ ENDFOREACH()
ENDIF() \ No newline at end of file
diff --git a/test/busted.lua b/test/lua/busted.lua
index 917d21d82..917d21d82 100644
--- a/test/busted.lua
+++ b/test/lua/busted.lua
diff --git a/test/busted/compatibility.lua b/test/lua/busted/compatibility.lua
index 7837656fb..7837656fb 100644
--- a/test/busted/compatibility.lua
+++ b/test/lua/busted/compatibility.lua
diff --git a/test/busted/context.lua b/test/lua/busted/context.lua
index 4cf0f3b53..4cf0f3b53 100644
--- a/test/busted/context.lua
+++ b/test/lua/busted/context.lua
diff --git a/test/busted/core.lua b/test/lua/busted/core.lua
index 802e60c80..802e60c80 100644
--- a/test/busted/core.lua
+++ b/test/lua/busted/core.lua
diff --git a/test/busted/done.lua b/test/lua/busted/done.lua
index e6319044d..e6319044d 100644
--- a/test/busted/done.lua
+++ b/test/lua/busted/done.lua
diff --git a/test/busted/environment.lua b/test/lua/busted/environment.lua
index 686b1388f..686b1388f 100644
--- a/test/busted/environment.lua
+++ b/test/lua/busted/environment.lua
diff --git a/test/busted/init.lua b/test/lua/busted/init.lua
index da052f503..da052f503 100644
--- a/test/busted/init.lua
+++ b/test/lua/busted/init.lua
diff --git a/test/busted/languages/ar.lua b/test/lua/busted/languages/ar.lua
index d0b96e65c..d0b96e65c 100644
--- a/test/busted/languages/ar.lua
+++ b/test/lua/busted/languages/ar.lua
diff --git a/test/busted/languages/de.lua b/test/lua/busted/languages/de.lua
index e624a465e..e624a465e 100644
--- a/test/busted/languages/de.lua
+++ b/test/lua/busted/languages/de.lua
diff --git a/test/busted/languages/en.lua b/test/lua/busted/languages/en.lua
index 285d1ba14..285d1ba14 100644
--- a/test/busted/languages/en.lua
+++ b/test/lua/busted/languages/en.lua
diff --git a/test/busted/languages/fr.lua b/test/lua/busted/languages/fr.lua
index 236d87c89..236d87c89 100644
--- a/test/busted/languages/fr.lua
+++ b/test/lua/busted/languages/fr.lua
diff --git a/test/busted/languages/ja.lua b/test/lua/busted/languages/ja.lua
index d726fa8f9..d726fa8f9 100644
--- a/test/busted/languages/ja.lua
+++ b/test/lua/busted/languages/ja.lua
diff --git a/test/busted/languages/nl.lua b/test/lua/busted/languages/nl.lua
index 6173320bd..6173320bd 100644
--- a/test/busted/languages/nl.lua
+++ b/test/lua/busted/languages/nl.lua
diff --git a/test/busted/languages/ru.lua b/test/lua/busted/languages/ru.lua
index d0f403440..d0f403440 100644
--- a/test/busted/languages/ru.lua
+++ b/test/lua/busted/languages/ru.lua
diff --git a/test/busted/languages/th.lua b/test/lua/busted/languages/th.lua
index 0f8e0a13a..0f8e0a13a 100644
--- a/test/busted/languages/th.lua
+++ b/test/lua/busted/languages/th.lua
diff --git a/test/busted/languages/ua.lua b/test/lua/busted/languages/ua.lua
index 40afcfbab..40afcfbab 100644
--- a/test/busted/languages/ua.lua
+++ b/test/lua/busted/languages/ua.lua
diff --git a/test/busted/languages/zh.lua b/test/lua/busted/languages/zh.lua
index 21f97e5cb..21f97e5cb 100644
--- a/test/busted/languages/zh.lua
+++ b/test/lua/busted/languages/zh.lua
diff --git a/test/busted/modules/configuration_loader.lua b/test/lua/busted/modules/configuration_loader.lua
index f437a04cd..f437a04cd 100644
--- a/test/busted/modules/configuration_loader.lua
+++ b/test/lua/busted/modules/configuration_loader.lua
diff --git a/test/busted/modules/files/lua.lua b/test/lua/busted/modules/files/lua.lua
index a4218f6d4..a4218f6d4 100644
--- a/test/busted/modules/files/lua.lua
+++ b/test/lua/busted/modules/files/lua.lua
diff --git a/test/busted/modules/files/moonscript.lua b/test/lua/busted/modules/files/moonscript.lua
index 145b942f5..145b942f5 100644
--- a/test/busted/modules/files/moonscript.lua
+++ b/test/lua/busted/modules/files/moonscript.lua
diff --git a/test/busted/modules/files/terra.lua b/test/lua/busted/modules/files/terra.lua
index 02956f76a..02956f76a 100644
--- a/test/busted/modules/files/terra.lua
+++ b/test/lua/busted/modules/files/terra.lua
diff --git a/test/busted/modules/helper_loader.lua b/test/lua/busted/modules/helper_loader.lua
index 166f7ccd1..166f7ccd1 100644
--- a/test/busted/modules/helper_loader.lua
+++ b/test/lua/busted/modules/helper_loader.lua
diff --git a/test/busted/modules/luacov.lua b/test/lua/busted/modules/luacov.lua
index 99cfc8f56..99cfc8f56 100644
--- a/test/busted/modules/luacov.lua
+++ b/test/lua/busted/modules/luacov.lua
diff --git a/test/busted/modules/output_handler_loader.lua b/test/lua/busted/modules/output_handler_loader.lua
index d52211846..d52211846 100644
--- a/test/busted/modules/output_handler_loader.lua
+++ b/test/lua/busted/modules/output_handler_loader.lua
diff --git a/test/busted/modules/test_file_loader.lua b/test/lua/busted/modules/test_file_loader.lua
index 391cce501..391cce501 100644
--- a/test/busted/modules/test_file_loader.lua
+++ b/test/lua/busted/modules/test_file_loader.lua
diff --git a/test/busted/outputHandlers/TAP.lua b/test/lua/busted/outputHandlers/TAP.lua
index b46350ec8..b46350ec8 100644
--- a/test/busted/outputHandlers/TAP.lua
+++ b/test/lua/busted/outputHandlers/TAP.lua
diff --git a/test/busted/outputHandlers/base.lua b/test/lua/busted/outputHandlers/base.lua
index 5ea9540fc..5ea9540fc 100644
--- a/test/busted/outputHandlers/base.lua
+++ b/test/lua/busted/outputHandlers/base.lua
diff --git a/test/busted/outputHandlers/json.lua b/test/lua/busted/outputHandlers/json.lua
index f19a336aa..f19a336aa 100644
--- a/test/busted/outputHandlers/json.lua
+++ b/test/lua/busted/outputHandlers/json.lua
diff --git a/test/busted/outputHandlers/junit.lua b/test/lua/busted/outputHandlers/junit.lua
index 36e78936e..36e78936e 100644
--- a/test/busted/outputHandlers/junit.lua
+++ b/test/lua/busted/outputHandlers/junit.lua
diff --git a/test/busted/outputHandlers/plainTerminal.lua b/test/lua/busted/outputHandlers/plainTerminal.lua
index fc4b092f2..fc4b092f2 100644
--- a/test/busted/outputHandlers/plainTerminal.lua
+++ b/test/lua/busted/outputHandlers/plainTerminal.lua
diff --git a/test/busted/outputHandlers/sound.lua b/test/lua/busted/outputHandlers/sound.lua
index 8ac1a46ce..8ac1a46ce 100644
--- a/test/busted/outputHandlers/sound.lua
+++ b/test/lua/busted/outputHandlers/sound.lua
diff --git a/test/busted/outputHandlers/utfTerminal.lua b/test/lua/busted/outputHandlers/utfTerminal.lua
index f34015cc4..f34015cc4 100644
--- a/test/busted/outputHandlers/utfTerminal.lua
+++ b/test/lua/busted/outputHandlers/utfTerminal.lua
diff --git a/test/busted/runner.lua b/test/lua/busted/runner.lua
index 91ce94e50..91ce94e50 100644
--- a/test/busted/runner.lua
+++ b/test/lua/busted/runner.lua
diff --git a/test/busted/status.lua b/test/lua/busted/status.lua
index c68ce7fc7..c68ce7fc7 100644
--- a/test/busted/status.lua
+++ b/test/lua/busted/status.lua
diff --git a/test/busted/utils.lua b/test/lua/busted/utils.lua
index 4e02bc036..4e02bc036 100644
--- a/test/busted/utils.lua
+++ b/test/lua/busted/utils.lua
diff --git a/test/lua/rsa.lua b/test/lua/rsa.lua
index 83a6a9e45..073062fd1 100644
--- a/test/lua/rsa.lua
+++ b/test/lua/rsa.lua
@@ -1,39 +1,47 @@
-- Test rsa signing
-local pubkey = 'testkey.pub'
-local privkey = 'testkey'
-local data = 'test.data'
-local signature = 'test.sig'
+require "busted" ()
--- Signing test
-local rsa_key = rsa_privkey.load(string.format('%s/%s', test_dir, privkey))
+describe("rsa signarture test", function()
+ local rsa_privkey = require "rspamd_rsa_privkey"
+ local rsa_pubkey = require "rspamd_rsa_pubkey"
+ local rsa_signature = require "rspamd_rsa_signature"
+ local rsa = require "rspamd_rsa"
+ local pubkey = 'testkey.pub'
+ local privkey = 'testkey'
+ local data = 'test.data'
+ local signature = 'test.sig'
-if not rsa_key then
- return -1
-end
+ -- Signing test
+ local rsa_key = rsa_privkey.load(string.format('%s/%s', test_dir, privkey))
-local rsa_sig = rsa.sign_file(rsa_key, string.format('%s/%s', test_dir, data))
+ if not rsa_key then
+ return -1
+ end
-if not rsa_sig then
- return -1
-end
+ local rsa_sig = rsa.sign_file(rsa_key, string.format('%s/%s', test_dir, data))
-rsa_sig:save(string.format('%s/%s', test_dir, signature), true)
+ if not rsa_sig then
+ return -1
+ end
--- Verifying test
-rsa_key = rsa_pubkey.load(string.format('%s/%s', test_dir, pubkey))
+ rsa_sig:save(string.format('%s/%s', test_dir, signature), true)
-if not rsa_key then
- return -1
-end
+ -- Verifying test
+ rsa_key = rsa_pubkey.load(string.format('%s/%s', test_dir, pubkey))
-rsa_sig = rsa_signature.load(string.format('%s/%s', test_dir, signature))
+ if not rsa_key then
+ return -1
+ end
-if not rsa_sig then
- return -1
-end
+ rsa_sig = rsa_signature.load(string.format('%s/%s', test_dir, signature))
-if not rsa.verify_file(rsa_key, rsa_sig, string.format('%s/%s', test_dir, data)) then
- return -1
-end
+ if not rsa_sig then
+ return -1
+ end
+ if not rsa.verify_file(rsa_key, rsa_sig, string.format('%s/%s', test_dir, data)) then
+ return -1
+ end
+
+end)
diff --git a/test/rspamd_lua_test.c b/test/rspamd_lua_test.c
index 46303b356..da9405fa5 100644
--- a/test/rspamd_lua_test.c
+++ b/test/rspamd_lua_test.c
@@ -37,6 +37,7 @@ rspamd_lua_test_func (void)
glob_t globbuf;
gchar *pattern;
guint i, len;
+ struct stat st;
msg_info ("Starting lua tests");
@@ -54,6 +55,15 @@ rspamd_lua_test_func (void)
for (i = 0; i < globbuf.gl_pathc; i++) {
lua_file = globbuf.gl_pathv[i];
+ if (stat (lua_file, &st) == -1 || !S_ISREG (st.st_mode)) {
+ continue;
+ }
+
+ if (strstr (lua_file, "busted") != NULL) {
+ /* Skip busted code itself */
+ continue;
+ }
+
if (luaL_loadfile (L, lua_file) != 0) {
msg_err ("load test from %s failed", lua_file);
g_assert (0);