diff --git a/tests/Makefile.am b/tests/Makefile.am index 1a69a4e85..281c5ffd6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,7 @@ include $(top_srcdir)/Makefile.decl +insttestdir = $(pkglibexecdir)/installed-tests + SUBDIRS=gobject refcount AM_CPPFLAGS = \ @@ -129,6 +131,29 @@ TESTS_ENVIRONMENT = srcdir=$(srcdir) \ MALLOC_CHECK_=2 \ MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) +test_data = \ + iochannel-test-infile \ + casemap.txt \ + casefold.txt \ + utf8.txt \ + $(NULL) + +if BUILDOPT_INSTALL_TESTS +insttest_PROGRAMS = $(test_programs) + +testmetadir = $(datadir)/installed-tests/$(PACKAGE) +testmeta_DATA = $(test_programs:=.test) + +insttest_DATA = $(test_data) + +%.test: % Makefile + $(AM_V_GEN) (echo '[Test]' > $@.tmp; \ + echo 'Type=session' >> $@.tmp; \ + echo 'Exec=env G_TEST_DATA=$(pkglibexecdir)/installed-tests $(pkglibexecdir)/installed-tests/$<' >> $@.tmp; \ + mv $@.tmp $@) + +endif + progs_ldadd = $(EFENCE) $(libglib) $(EFENCE) thread_ldadd = $(libgthread) $(G_THREAD_LIBS) $(progs_ldadd) module_ldadd = $(libgmodule) $(G_MODULE_LIBS) $(progs_ldadd) @@ -166,14 +191,18 @@ type_test_LDADD = $(progs_ldadd) unicode_encoding_LDADD = $(progs_ldadd) unicode_caseconv_LDADD = $(progs_ldadd) +if BUILDOPT_INSTALL_TESTS +insttest_LTLIBRARIES = libmoduletestplugin_a.la libmoduletestplugin_b.la +else noinst_LTLIBRARIES = libmoduletestplugin_a.la libmoduletestplugin_b.la +endif libmoduletestplugin_a_la_SOURCES = libmoduletestplugin_a.c -libmoduletestplugin_a_la_LDFLAGS = $(G_MODULE_LDFLAGS) -avoid-version -module $(no_undefined) -rpath $(libdir) +libmoduletestplugin_a_la_LDFLAGS = $(G_MODULE_LDFLAGS) -avoid-version -module $(no_undefined) -rpath $(insttestdir) libmoduletestplugin_a_la_LIBADD = $(G_MODULE_LIBS) $(libadd_libgmodule) $(libadd_libglib) libmoduletestplugin_b_la_SOURCES = libmoduletestplugin_b.c -libmoduletestplugin_b_la_LDFLAGS = $(G_MODULE_LDFLAGS) -avoid-version -module $(no_undefined) -rpath $(libdir) +libmoduletestplugin_b_la_LDFLAGS = $(G_MODULE_LDFLAGS) -avoid-version -module $(no_undefined) -rpath $(insttestdir) libmoduletestplugin_b_la_LIBADD = $(G_MODULE_LIBS) $(libadd_libgmodule) $(libadd_libglib) dist-hook: $(BUILT_EXTRA_DIST) diff --git a/tests/gobject/Makefile.am b/tests/gobject/Makefile.am index b0125a195..9345a6857 100644 --- a/tests/gobject/Makefile.am +++ b/tests/gobject/Makefile.am @@ -60,16 +60,18 @@ test_programs = \ defaultiface \ dynamictype \ override \ - performance \ - performance-threaded \ singleton \ references +performance_programs = \ + performance \ + performance-threaded + performance_LDADD = $(libgobject) $(libgthread) performance_threaded_LDADD = $(libgobject) $(libgthread) check_PROGRAMS = $(test_programs) -TESTS = $(test_programs) +TESTS = $(test_programs) $(performance_programs) TESTS_ENVIRONMENT = srcdir=$(srcdir) \ LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset \ MALLOC_CHECK_=2 \ diff --git a/tests/iochannel-test.c b/tests/iochannel-test.c index 492b47e20..81c04daa5 100644 --- a/tests/iochannel-test.c +++ b/tests/iochannel-test.c @@ -11,6 +11,8 @@ #define BUFFER_SIZE 1024 +static const gchar *datapath; + static void test_small_writes (void) { @@ -58,16 +60,18 @@ gint main (gint argc, gchar * argv[]) GError *gerr = NULL; GString *buffer; char *filename; - char *srcdir = getenv ("srcdir"); gint rlength = 0; glong wlength = 0; gsize length_out; const gchar encoding[] = "EUC-JP"; GIOStatus status; - if (!srcdir) - srcdir = "."; - filename = g_strconcat (srcdir, G_DIR_SEPARATOR_S, "iochannel-test-infile", NULL); + if (g_getenv ("G_TEST_DATA")) + datapath = g_getenv ("G_TEST_DATA"); + else + datapath = "."; + + filename = g_build_filename (datapath, "iochannel-test-infile", NULL); setbuf (stdout, NULL); /* For debugging */ diff --git a/tests/module-test.c b/tests/module-test.c index dd99b710f..644fba9ab 100644 --- a/tests/module-test.c +++ b/tests/module-test.c @@ -30,6 +30,8 @@ #include #include +static const gchar *datapath; + gchar* global_state; G_MODULE_EXPORT void g_clash_func (void); @@ -85,12 +87,13 @@ main (int arg, if (!g_module_supported ()) g_error ("dynamic modules not supported"); - dir = g_get_current_dir (); + if (g_getenv ("G_TEST_DATA")) + datapath = g_getenv ("G_TEST_DATA"); + else + datapath = "."; - plugin_a = g_strconcat (dir, G_DIR_SEPARATOR_S "libmoduletestplugin_a", - NULL); - plugin_b = g_strconcat (dir, G_DIR_SEPARATOR_S "libmoduletestplugin_b", - NULL); + plugin_a = g_build_filename (datapath, "libmoduletestplugin_a", NULL); + plugin_b = g_build_filename (datapath, "libmoduletestplugin_b", NULL); g_free (dir); diff --git a/tests/unicode-caseconv.c b/tests/unicode-caseconv.c index 0563ab6c5..0147a3b38 100644 --- a/tests/unicode-caseconv.c +++ b/tests/unicode-caseconv.c @@ -12,7 +12,7 @@ int main (int argc, char **argv) FILE *infile; char buffer[1024]; char **strings; - char *srcdir = getenv ("srcdir"); + const char *srcdir; char *filename; const char *locale; const char *test; @@ -21,10 +21,13 @@ int main (int argc, char **argv) char *current_locale = setlocale (LC_CTYPE, NULL); gint result = 0; - if (!srcdir) + if (g_getenv ("G_TEST_DATA")) + srcdir = g_getenv ("G_TEST_DATA"); + else srcdir = "."; + filename = g_strconcat (srcdir, G_DIR_SEPARATOR_S, "casemap.txt", NULL); - + infile = fopen (filename, "r"); if (!infile) { diff --git a/tests/unicode-encoding.c b/tests/unicode-encoding.c index 09b339297..0d187a863 100644 --- a/tests/unicode-encoding.c +++ b/tests/unicode-encoding.c @@ -308,7 +308,7 @@ process (gint line, int main (int argc, char **argv) { - gchar *srcdir = getenv ("srcdir"); + const gchar *srcdir; gchar *testfile; gchar *contents; GError *error = NULL; @@ -321,7 +321,9 @@ main (int argc, char **argv) GArray *ucs4; Status status = VALID; /* Quiet GCC */ - if (!srcdir) + if (g_getenv ("G_TEST_DATA")) + srcdir = g_getenv ("G_TEST_DATA"); + else srcdir = "."; testfile = g_strconcat (srcdir, G_DIR_SEPARATOR_S "utf8.txt", NULL);