]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Reorganize lua tests.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 27 Feb 2015 15:55:46 +0000 (15:55 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 27 Feb 2015 15:55:46 +0000 (15:55 +0000)
38 files changed:
test/CMakeLists.txt
test/lua/busted.lua [moved from test/busted.lua with 100% similarity]
test/lua/busted/compatibility.lua [moved from test/busted/compatibility.lua with 100% similarity]
test/lua/busted/context.lua [moved from test/busted/context.lua with 100% similarity]
test/lua/busted/core.lua [moved from test/busted/core.lua with 100% similarity]
test/lua/busted/done.lua [moved from test/busted/done.lua with 100% similarity]
test/lua/busted/environment.lua [moved from test/busted/environment.lua with 100% similarity]
test/lua/busted/init.lua [moved from test/busted/init.lua with 100% similarity]
test/lua/busted/languages/ar.lua [moved from test/busted/languages/ar.lua with 100% similarity]
test/lua/busted/languages/de.lua [moved from test/busted/languages/de.lua with 100% similarity]
test/lua/busted/languages/en.lua [moved from test/busted/languages/en.lua with 100% similarity]
test/lua/busted/languages/fr.lua [moved from test/busted/languages/fr.lua with 100% similarity]
test/lua/busted/languages/ja.lua [moved from test/busted/languages/ja.lua with 100% similarity]
test/lua/busted/languages/nl.lua [moved from test/busted/languages/nl.lua with 100% similarity]
test/lua/busted/languages/ru.lua [moved from test/busted/languages/ru.lua with 100% similarity]
test/lua/busted/languages/th.lua [moved from test/busted/languages/th.lua with 100% similarity]
test/lua/busted/languages/ua.lua [moved from test/busted/languages/ua.lua with 100% similarity]
test/lua/busted/languages/zh.lua [moved from test/busted/languages/zh.lua with 100% similarity]
test/lua/busted/modules/configuration_loader.lua [moved from test/busted/modules/configuration_loader.lua with 100% similarity]
test/lua/busted/modules/files/lua.lua [moved from test/busted/modules/files/lua.lua with 100% similarity]
test/lua/busted/modules/files/moonscript.lua [moved from test/busted/modules/files/moonscript.lua with 100% similarity]
test/lua/busted/modules/files/terra.lua [moved from test/busted/modules/files/terra.lua with 100% similarity]
test/lua/busted/modules/helper_loader.lua [moved from test/busted/modules/helper_loader.lua with 100% similarity]
test/lua/busted/modules/luacov.lua [moved from test/busted/modules/luacov.lua with 100% similarity]
test/lua/busted/modules/output_handler_loader.lua [moved from test/busted/modules/output_handler_loader.lua with 100% similarity]
test/lua/busted/modules/test_file_loader.lua [moved from test/busted/modules/test_file_loader.lua with 100% similarity]
test/lua/busted/outputHandlers/TAP.lua [moved from test/busted/outputHandlers/TAP.lua with 100% similarity]
test/lua/busted/outputHandlers/base.lua [moved from test/busted/outputHandlers/base.lua with 100% similarity]
test/lua/busted/outputHandlers/json.lua [moved from test/busted/outputHandlers/json.lua with 100% similarity]
test/lua/busted/outputHandlers/junit.lua [moved from test/busted/outputHandlers/junit.lua with 100% similarity]
test/lua/busted/outputHandlers/plainTerminal.lua [moved from test/busted/outputHandlers/plainTerminal.lua with 100% similarity]
test/lua/busted/outputHandlers/sound.lua [moved from test/busted/outputHandlers/sound.lua with 100% similarity]
test/lua/busted/outputHandlers/utfTerminal.lua [moved from test/busted/outputHandlers/utfTerminal.lua with 100% similarity]
test/lua/busted/runner.lua [moved from test/busted/runner.lua with 100% similarity]
test/lua/busted/status.lua [moved from test/busted/status.lua with 100% similarity]
test/lua/busted/utils.lua [moved from test/busted/utils.lua with 100% similarity]
test/lua/rsa.lua
test/rspamd_lua_test.c

index 9932fb87dd728cc90851efb1fc823f5171a11d69..32d5334cbfc3ef52db108aa4e978acf07c5d24ac 100644 (file)
@@ -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
similarity index 100%
rename from test/busted.lua
rename to test/lua/busted.lua
index 83a6a9e4576ae0fb6cbafe00234ee11e27b35eec..073062fd14228a06bd8d2d95a91d0485752226de 100644 (file)
@@ -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)
index 46303b35686a66ada7bc2b721868eff42831be00..da9405fa5adce66a3d16f89e5b02e201ca174248 100644 (file)
@@ -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);