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
-- 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)
glob_t globbuf;
gchar *pattern;
guint i, len;
+ struct stat st;
msg_info ("Starting lua tests");
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);