[glib] Convert more tests to installed tests
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Convert more tests to installed tests
- Date: Tue, 21 May 2013 03:41:38 +0000 (UTC)
commit 7ff5c082213c13c893f583f2bce77fa63a146af2
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 20 21:05:56 2013 -0400
Convert more tests to installed tests
This makes the tests in tests installed, except for
the performance tests.
tests/Makefile.am | 33 +++++++++++++++++++++++++++++++--
tests/gobject/Makefile.am | 8 +++++---
tests/iochannel-test.c | 12 ++++++++----
tests/module-test.c | 13 ++++++++-----
tests/unicode-caseconv.c | 9 ++++++---
tests/unicode-encoding.c | 6 ++++--
6 files changed, 62 insertions(+), 19 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1a69a4e..281c5ff 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 b0125a1..9345a68 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 492b47e..81c04da 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 dd99b71..644fba9 100644
--- a/tests/module-test.c
+++ b/tests/module-test.c
@@ -30,6 +30,8 @@
#include <gmodule.h>
#include <string.h>
+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 0563ab6..0147a3b 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 09b3392..0d187a8 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]