mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-07 03:02:17 +00:00
tests/check/libs/utils.c: Don't hard-code temp directory for test helper; use GLib functions to write out file and do...
Original commit message from CVS: * tests/check/libs/utils.c: (test_base_utils_install_plugins_do_callout): Don't hard-code temp directory for test helper; use GLib functions to write out file and do error checking etc.
This commit is contained in:
parent
17a02da2fd
commit
92c11d5d24
3 changed files with 109 additions and 84 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2007-02-03 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
* tests/check/libs/utils.c:
|
||||||
|
(test_base_utils_install_plugins_do_callout):
|
||||||
|
Don't hard-code temp directory for test helper; use GLib functions
|
||||||
|
to write out file and do error checking etc.
|
||||||
|
|
||||||
2007-02-02 Tim-Philipp Müller <tim at centricular dot net>
|
2007-02-02 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* gst-libs/gst/utils/Makefile.am:
|
* gst-libs/gst/utils/Makefile.am:
|
||||||
|
|
|
@ -29,16 +29,16 @@
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
#include <glib/gprintf.h>
|
#include <glib/gprintf.h>
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h> /* for unlink() */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h> /* for fchmod() */
|
#include <sys/types.h> /* for chmod() and getpid () */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_STAT_H
|
#ifdef HAVE_SYS_STAT_H
|
||||||
#include <sys/stat.h> /* for fchmod() */
|
#include <sys/stat.h> /* for chmod() */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h> /* for unlink() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -460,7 +460,6 @@ result_cb (GstInstallPluginsReturn result, gpointer user_data)
|
||||||
marker = result;
|
marker = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FAKE_INSTALL_PLUGINS_HELPER "/tmp/gst-plugins-base-unit-test-helper"
|
|
||||||
#define SCRIPT_NO_XID \
|
#define SCRIPT_NO_XID \
|
||||||
"#!/bin/sh\n" \
|
"#!/bin/sh\n" \
|
||||||
"if test x$1 != xdetail1; then exit 21; fi;\n" \
|
"if test x$1 != xdetail1; then exit 21; fi;\n" \
|
||||||
|
@ -482,17 +481,26 @@ test_base_utils_install_plugins_do_callout (gchar ** details,
|
||||||
{
|
{
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
GstInstallPluginsReturn ret;
|
GstInstallPluginsReturn ret;
|
||||||
FILE *f;
|
GError *err = NULL;
|
||||||
|
gchar *path;
|
||||||
|
|
||||||
unlink (FAKE_INSTALL_PLUGINS_HELPER);
|
path = g_strdup_printf ("%s/gst-plugins-base-unit-test-helper.%s.%lu",
|
||||||
|
g_get_tmp_dir (), (g_get_user_name ())? g_get_user_name () : "nobody",
|
||||||
|
(gulong) getpid ());
|
||||||
|
|
||||||
f = g_fopen (FAKE_INSTALL_PLUGINS_HELPER, "w");
|
if (!g_file_set_contents (path, script, -1, &err)) {
|
||||||
if (f == NULL)
|
GST_DEBUG ("Failed to write test script to %s: %s", path, err->message);
|
||||||
return;
|
g_error_free (err);
|
||||||
if (g_fprintf (f, "%s", script) > 0 &&
|
goto done;
|
||||||
fchmod (fileno (f), S_IRUSR | S_IWUSR | S_IXUSR) == 0) {
|
}
|
||||||
fclose (f);
|
|
||||||
g_setenv ("GST_INSTALL_PLUGINS_HELPER", FAKE_INSTALL_PLUGINS_HELPER, 1);
|
if (chmod (path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
|
||||||
|
GST_DEBUG ("Could not set mode u+rwx on '%s'", path);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_LOG ("setting GST_INSTALL_PLUGINS_HELPER to '%s'", path);
|
||||||
|
g_setenv ("GST_INSTALL_PLUGINS_HELPER", path, 1);
|
||||||
|
|
||||||
/* test sync callout */
|
/* test sync callout */
|
||||||
ret = gst_install_plugins_sync (details, ctx);
|
ret = gst_install_plugins_sync (details, ctx);
|
||||||
|
@ -516,10 +524,11 @@ test_base_utils_install_plugins_do_callout (gchar ** details,
|
||||||
/* and check that the callback was called with the expected code */
|
/* and check that the callback was called with the expected code */
|
||||||
fail_unless_equals_int (marker, expected_result);
|
fail_unless_equals_int (marker, expected_result);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fclose (f);
|
done:
|
||||||
}
|
|
||||||
unlink (FAKE_INSTALL_PLUGINS_HELPER);
|
unlink (path);
|
||||||
|
g_free (path);
|
||||||
#endif /* G_OS_UNIX */
|
#endif /* G_OS_UNIX */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,16 +29,16 @@
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
#include <glib/gprintf.h>
|
#include <glib/gprintf.h>
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h> /* for unlink() */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h> /* for fchmod() */
|
#include <sys/types.h> /* for chmod() and getpid () */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_STAT_H
|
#ifdef HAVE_SYS_STAT_H
|
||||||
#include <sys/stat.h> /* for fchmod() */
|
#include <sys/stat.h> /* for chmod() */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h> /* for unlink() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -460,7 +460,6 @@ result_cb (GstInstallPluginsReturn result, gpointer user_data)
|
||||||
marker = result;
|
marker = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FAKE_INSTALL_PLUGINS_HELPER "/tmp/gst-plugins-base-unit-test-helper"
|
|
||||||
#define SCRIPT_NO_XID \
|
#define SCRIPT_NO_XID \
|
||||||
"#!/bin/sh\n" \
|
"#!/bin/sh\n" \
|
||||||
"if test x$1 != xdetail1; then exit 21; fi;\n" \
|
"if test x$1 != xdetail1; then exit 21; fi;\n" \
|
||||||
|
@ -482,17 +481,26 @@ test_base_utils_install_plugins_do_callout (gchar ** details,
|
||||||
{
|
{
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
GstInstallPluginsReturn ret;
|
GstInstallPluginsReturn ret;
|
||||||
FILE *f;
|
GError *err = NULL;
|
||||||
|
gchar *path;
|
||||||
|
|
||||||
unlink (FAKE_INSTALL_PLUGINS_HELPER);
|
path = g_strdup_printf ("%s/gst-plugins-base-unit-test-helper.%s.%lu",
|
||||||
|
g_get_tmp_dir (), (g_get_user_name ())? g_get_user_name () : "nobody",
|
||||||
|
(gulong) getpid ());
|
||||||
|
|
||||||
f = g_fopen (FAKE_INSTALL_PLUGINS_HELPER, "w");
|
if (!g_file_set_contents (path, script, -1, &err)) {
|
||||||
if (f == NULL)
|
GST_DEBUG ("Failed to write test script to %s: %s", path, err->message);
|
||||||
return;
|
g_error_free (err);
|
||||||
if (g_fprintf (f, "%s", script) > 0 &&
|
goto done;
|
||||||
fchmod (fileno (f), S_IRUSR | S_IWUSR | S_IXUSR) == 0) {
|
}
|
||||||
fclose (f);
|
|
||||||
g_setenv ("GST_INSTALL_PLUGINS_HELPER", FAKE_INSTALL_PLUGINS_HELPER, 1);
|
if (chmod (path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
|
||||||
|
GST_DEBUG ("Could not set mode u+rwx on '%s'", path);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_LOG ("setting GST_INSTALL_PLUGINS_HELPER to '%s'", path);
|
||||||
|
g_setenv ("GST_INSTALL_PLUGINS_HELPER", path, 1);
|
||||||
|
|
||||||
/* test sync callout */
|
/* test sync callout */
|
||||||
ret = gst_install_plugins_sync (details, ctx);
|
ret = gst_install_plugins_sync (details, ctx);
|
||||||
|
@ -516,10 +524,11 @@ test_base_utils_install_plugins_do_callout (gchar ** details,
|
||||||
/* and check that the callback was called with the expected code */
|
/* and check that the callback was called with the expected code */
|
||||||
fail_unless_equals_int (marker, expected_result);
|
fail_unless_equals_int (marker, expected_result);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fclose (f);
|
done:
|
||||||
}
|
|
||||||
unlink (FAKE_INSTALL_PLUGINS_HELPER);
|
unlink (path);
|
||||||
|
g_free (path);
|
||||||
#endif /* G_OS_UNIX */
|
#endif /* G_OS_UNIX */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue