*.stp
*.exe
*.def
+*.test
# autofoo stuff here
compile
AS_HELP_STRING([--disable-modular-tests],
[Disable build of test programs (default: no)]),,
[enable_modular_tests=yes])
-AM_CONDITIONAL(BUILD_MODULAR_TESTS, test x$enable_modular_tests = xyes)
+AC_ARG_ENABLE(installed_tests,
+ AS_HELP_STRING([--enable-installed-tests],
+ [Install test programs (default: no)]),,
+ [enable_installed_tests=no])
+AM_CONDITIONAL(BUILD_MODULAR_TESTS, test x$enable_modular_tests = xyes || test x$enable_installed_tests=xyes)
+AM_CONDITIONAL(BUILDOPT_INSTALL_TESTS, test x$enable_installed_tests = xyes)
AC_MSG_CHECKING([whether to enable garbage collector friendliness])
AS_IF([test "x$enable_gc_friendly" = "xyes"], [
include $(top_srcdir)/Makefile.decl
NULL =
+insttestdir=$(pkglibexecdir)/installed-tests
+
bookmark_test_files = \
bookmarks/fail-01.xbel \
bookmarks/fail-02.xbel \
LDADD = $(top_builddir)/glib/libglib-2.0.la -lm
-TEST_PROGS += \
+TEST_PROGS += \
+ 1bit-emufutex \
+ gwakeup \
+ $(NULL)
+
+all_test_programs = \
array-test \
asyncqueue \
atomic \
fileutils \
gdatetime \
gvariant \
- gwakeup \
hash \
hmac \
hook \
unicode \
uri \
1bit-mutex \
- 1bit-emufutex \
642026 \
642026-ec
-noinst_PROGRAMS = $(TEST_PROGS) test-spawn-echo
+if OS_UNIX
+all_test_programs += unix
+all_test_programs += include
+endif
+
+extra_test_binaries = test-spawn-echo
+
+if BUILD_MODULAR_TESTS
+TEST_PROGS += $(all_test_programs)
+noinst_PROGRAMS = $(TEST_PROGS) $(extra_test_binaries)
+endif
+
+if BUILDOPT_INSTALL_TESTS
+insttest_PROGRAMS = $(all_test_programs) $(extra_test_binaries)
+testmetadir = $(datadir)/installed-tests/$(PACKAGE)
+testmeta_DATA = $(all_test_programs:=.test)
+
+testdatadir=$(insttestdir)
+testdata_DATA = $(test_files)
+
+testdata_SCRIPTS = $(test_script_files)
+
+bookmarksdir=$(insttestdir)/bookmarks
+bookmarks_DATA = $(bookmark_test_files)
+
+markupsdir=$(insttestdir)/markups
+markups_DATA = $(all_markup_test_files)
+endif
+
+%.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 $@)
atomic_CFLAGS = $(AM_CFLAGS)
if HAVE_GCC
if OS_UNIX
-TEST_PROGS += unix
-TEST_PROGS += include
-
# some testing of gtester functionality
XMLLINT = xmllint
GError *error;
const gchar *name;
gchar *path;
+ const gchar *datapath;
g_test_init (&argc, &argv, NULL);
}
error = NULL;
- dir = g_dir_open (SRCDIR "/bookmarks", 0, &error);
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
+ path = g_build_filename (datapath, "bookmarks", NULL);
+ dir = g_dir_open (path, 0, &error);
+ g_free (path);
g_assert_no_error (error);
while ((name = g_dir_read_name (dir)) != NULL)
{
path = g_strdup_printf ("/bookmarks/parse/%s", name);
- g_test_add_data_func_full (path, g_build_filename (SRCDIR, "bookmarks", name, NULL),
+ g_test_add_data_func_full (path, g_build_filename (datapath, "bookmarks", name, NULL),
test_file, g_free);
g_free (path);
}
#include <string.h>
#include <stdlib.h>
+static const gchar *datapath;
+
static GKeyFile *
load_data (const gchar *data,
GKeyFileFlags flags)
{
GKeyFile *file;
GError *error;
+ gchar *path;
file = g_key_file_new ();
error = NULL;
- g_assert (!g_key_file_load_from_file (file, SRCDIR "/keyfile.c", 0, &error));
+ path = g_build_filename (datapath, "keyfile.c", NULL);
+ g_assert (!g_key_file_load_from_file (file, path, 0, &error));
+ g_free (path);
g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE);
g_clear_error (&error);
g_assert (!g_key_file_load_from_file (file, "/nosuchfile", 0, &error));
GKeyFile *file;
GError *error;
gint i;
+ gchar *path;
#define GROUP "main_section"
#define KEY_PREFIX "fill_abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw_"
file = g_key_file_new ();
error = NULL;
- g_key_file_load_from_file (file, SRCDIR "/pages.ini", G_KEY_FILE_NONE, &error);
+ path = g_build_filename (datapath, "pages.ini", NULL);
+ g_key_file_load_from_file (file, path, G_KEY_FILE_NONE, &error);
+ g_free (path);
g_assert_no_error (error);
for (i = FIRST_KEY; i <= LAST_KEY; i++)
int
main (int argc, char *argv[])
{
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
+
#ifdef G_OS_UNIX
- g_setenv ("XDG_DATA_HOME", SRCDIR, TRUE);
+ g_setenv ("XDG_DATA_HOME", datapath, TRUE);
#endif
g_test_init (&argc, &argv, NULL);
#include <sys/types.h>
#include <fcntl.h>
+static const gchar *datapath;
+
static void
test_basic (void)
{
GMappedFile *file;
GError *error;
+ gchar *path;
error = NULL;
- file = g_mapped_file_new (SRCDIR "/empty", FALSE, &error);
+ path = g_build_filename (datapath, "empty", NULL);
+ file = g_mapped_file_new (path, FALSE, &error);
+ g_free (path);
g_assert_no_error (error);
g_mapped_file_ref (file);
{
GMappedFile *file;
GError *error;
+ gchar *path;
error = NULL;
- file = g_mapped_file_new (SRCDIR "/empty", FALSE, &error);
+ path = g_build_filename (datapath, "empty", NULL);
+ file = g_mapped_file_new (path, FALSE, &error);
+ g_free (path);
g_assert_no_error (error);
g_assert (g_mapped_file_get_contents (file) == NULL);
char *srcpath;
gchar *tmp_copy_path;
- srcpath = g_build_filename (SRCDIR, "4096-random-bytes", NULL);
+ srcpath = g_build_filename (datapath, "4096-random-bytes", NULL);
tmp_copy_path = g_build_filename (g_get_user_runtime_dir (), "glib-test-4096-random-bytes", NULL);
g_file_get_contents (srcpath, &contents, &len, &error);
char *srcpath;
gchar *tmp_copy_path;
- srcpath = g_build_filename (SRCDIR, "4096-random-bytes", NULL);
+ srcpath = g_build_filename (datapath, "4096-random-bytes", NULL);
tmp_copy_path = g_build_filename (g_get_user_runtime_dir (), "glib-test-4096-random-bytes", NULL);
g_file_get_contents (srcpath, &contents, &len, &error);
GMappedFile *file;
GBytes *bytes;
GError *error;
+ gchar *path;
error = NULL;
- file = g_mapped_file_new (SRCDIR "/empty", FALSE, &error);
+ path = g_build_filename (datapath, "empty", NULL);
+ file = g_mapped_file_new (path, FALSE, &error);
+ g_free (path);
g_assert_no_error (error);
bytes = g_mapped_file_get_bytes (file);
int
main (int argc, char *argv[])
{
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
+
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/mappedfile/basic", test_basic);
static int depth = 0;
static GString *string;
+static const gchar *datapath;
static void
indent (int extra)
const gchar *name;
gchar *path;
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
+
g_setenv ("LANG", "en_US.utf-8", TRUE);
setlocale (LC_ALL, "");
}
error = NULL;
- dir = g_dir_open (SRCDIR "/markups", 0, &error);
+ path = g_build_filename (datapath, "markups", NULL);
+ dir = g_dir_open (path, 0, &error);
+ g_free (path);
g_assert_no_error (error);
while ((name = g_dir_read_name (dir)) != NULL)
{
continue;
path = g_strdup_printf ("/markup/parse/%s", name);
- g_test_add_data_func_full (path, g_build_filename (SRCDIR, "markups", name, NULL),
+ g_test_add_data_func_full (path, g_build_filename (datapath, "markups", name, NULL),
test_parse, g_free);
g_free (path);
}
#define pipe(fds) _pipe(fds, 4096, _O_BINARY)
#endif
+static const char *argv0;
+
static void
debug (void)
{
test_message (void)
{
gchar* argv[] = {
- "./protocol",
+ argv0,
NULL,
"--GTestSubprocess",
"-p", "/glib/testing/protocol/debug",
for (i = 0; i < G_N_ELEMENTS (tests); i++)
{
gchar* argv[] = {
- "./protocol",
+ argv0,
NULL,
"--GTestSubprocess",
"-p", tests[i],
main (int argc,
char**argv)
{
+ argv0 = argv[0];
+
g_test_init (&argc, &argv, NULL);
/* we use ourself as the testcase, these are the ones we need internally */