diff options
author | Peter Wu <peter@lekensteyn.nl> | 2020-01-21 02:21:31 +0000 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2020-01-21 02:21:31 +0000 |
commit | d498196712c209fdcbd92f65c0b47ff26fc6c009 (patch) | |
tree | c29e3155fe89dc3451352abb0796149731d13ea9 /test/rspamd_lua_test.c | |
parent | 425bb31e1dd095e16cdc463a636a78193e6c86b5 (diff) | |
download | rspamd-d498196712c209fdcbd92f65c0b47ff26fc6c009.tar.gz rspamd-d498196712c209fdcbd92f65c0b47ff26fc6c009.zip |
[Minor] test: remove hard-coded build directory
* Reproducible build: avoid defining the BUILDROOT macro and avoid
embedding the build directory in the test image. Instead rely on the
test files being present next to the executable.
* I considered using g_test_build_filename, available since GLib 2.38
(available on all supported platforms, RHEL 7, Debian, Ubuntu, etc.),
but decided against it because it would require setting the
G_TEST_SRCDIR or G_TEST_BUILDDIR environment variables. Therefore this
patch simply parses argv0 directly.
Diffstat (limited to 'test/rspamd_lua_test.c')
-rw-r--r-- | test/rspamd_lua_test.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/test/rspamd_lua_test.c b/test/rspamd_lua_test.c index fc7979ee8..b014604b5 100644 --- a/test/rspamd_lua_test.c +++ b/test/rspamd_lua_test.c @@ -23,9 +23,10 @@ #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 @@ -59,7 +60,7 @@ void 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; @@ -75,11 +76,13 @@ rspamd_lua_test_func (void) 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); |