test: Fix up-self-test crash during out-of-tree builds

When the layout of the build tree doesn't match the expectations in
up-self-test, the test would crash failing to find UPower.conf. Pass the
path as a macro during build so we always know where it is.
This commit is contained in:
Bastien Nocera 2018-08-21 18:07:06 +02:00
parent ca2174aa3f
commit feac865366
2 changed files with 2 additions and 5 deletions

View file

@ -15,6 +15,7 @@ AM_CPPFLAGS = \
$(PIE_CFLAGS) \
-I$(top_builddir)/src -I$(top_srcdir)/src \
-I$(top_builddir)/ -I$(top_srcdir)/ \
-DUPOWER_CONF_PATH=\""$(top_srcdir)/etc/UPower.conf"\" \
-DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" \
-DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \
-DPACKAGE_DATA_DIR=\""$(datadir)"\" \

View file

@ -295,11 +295,7 @@ main (int argc, char **argv)
#endif
g_test_init (&argc, &argv, NULL);
/* make check, vs. make distcheck */
if (g_file_test ("../etc/UPower.conf", G_FILE_TEST_EXISTS))
g_setenv ("UPOWER_CONF_FILE_NAME", "../etc/UPower.conf", TRUE);
else
g_setenv ("UPOWER_CONF_FILE_NAME", "../../../etc/UPower.conf", TRUE);
g_setenv ("UPOWER_CONF_FILE_NAME", UPOWER_CONF_PATH, TRUE);
/* tests go here */
g_test_add_func ("/power/backend", up_test_backend_func);