#define MODULES_NUM ${RSPAMD_MODULES_NUM}
-#define BUILDROOT "${CMAKE_BINARY_DIR}"
-
/* sys/types */
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#include "lua/lua_thread_pool.h"
#include "unix-std.h"
-static const char *lua_src = BUILDROOT "/test/lua/pcall_test.lua";
+static const char *lua_src_name = "lua/pcall_test.lua";
+extern gchar *argv0_dirname;
extern struct rspamd_main *rspamd_main;
rspamd_lua_lua_pcall_vs_resume_test_func (void)
{
lua_State *L = rspamd_main->cfg->lua_state;
+ gchar *lua_src;
gdouble t1, reference;
+ lua_src = g_build_filename (argv0_dirname, lua_src_name, NULL);
if (luaL_dofile (L, lua_src) != 0) {
msg_err ("failed to load test file: %s ", lua_tostring (L, -1));
g_assert (0);
}
+ g_free (lua_src);
gint function_call = luaL_ref (L, LUA_REGISTRYINDEX);
t1 = test_resume_get_new_thread (function_call);
msg_notice ("resume+get [new] thread stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1/(gdouble)N, t1 / reference);
-}
\ No newline at end of file
+}
#include <glob.h>
#endif
-static const char *lua_src = BUILDROOT "/test/lua/tests.lua";
+static const char *lua_src_name = "lua/tests.lua";
extern gchar *lua_test;
extern gchar *lua_test_case;
+extern gchar *argv0_dirname;
extern struct rspamd_main *rspamd_main;
static int
rspamd_lua_test_func (void)
{
lua_State *L = (lua_State *)rspamd_main->cfg->lua_state;
- gchar *rp, rp_buf[PATH_MAX], path_buf[PATH_MAX], *tmp, *dir, *pattern;
+ gchar *lua_src, *rp, rp_buf[PATH_MAX], path_buf[PATH_MAX], *tmp, *dir, *pattern;
const gchar *old_path;
glob_t globbuf;
gint i, len;
rspamd_printf ("Starting lua tests\n");
+ lua_src = g_build_filename (argv0_dirname, lua_src_name, NULL);
if ((rp = realpath (lua_src, rp_buf)) == NULL) {
msg_err ("cannot find path %s: %s",
lua_src, strerror (errno));
g_assert (0);
}
+ g_free (lua_src);
tmp = g_strdup (rp);
dir = dirname (tmp);
gchar *lua_test = NULL;
gchar *lua_test_case = NULL;
gboolean verbose = FALSE;
+gchar *argv0_dirname = NULL;
static GOptionEntry entries[] =
{
g_test_init (&argc, &argv, NULL);
+ argv0_dirname = g_path_get_dirname (argv[0]);
+
context = g_option_context_new ("- run rspamd test");
g_option_context_add_main_entries (context, entries, NULL);