[Swfdec-commits] 2 commits - swfdec/swfdec_audio_decoder.c swfdec/swfdec_video_decoder.c test/swfdec_test.c
Benjamin Otte
company at kemper.freedesktop.org
Sat Sep 6 18:26:37 PDT 2008
swfdec/swfdec_audio_decoder.c | 2 +
swfdec/swfdec_video_decoder.c | 2 +
test/swfdec_test.c | 61 +++++++++++++++++++++++++++++++++++++++++-
3 files changed, 64 insertions(+), 1 deletion(-)
New commits:
commit 89ce851029176e55cd1561354075240779e7b472
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Sep 7 03:20:22 2008 +0200
check that the system is ok for running tests before running them.
Also adds command line arguments to skip or only run the system check.
diff --git a/test/swfdec_test.c b/test/swfdec_test.c
index 27fd554..d8db9c8 100644
--- a/test/swfdec_test.c
+++ b/test/swfdec_test.c
@@ -33,6 +33,51 @@
#include "swfdec_test_initialize.h"
#include "swfdec_test_test.h"
+/*** VERIFICATION OF ENVIRONMENT ***/
+
+static gboolean
+check_cairo (gboolean verbose)
+{
+#define CAIRO_MIN_MAJOR 1
+#define CAIRO_MIN_MINOR 7
+#define CAIRO_MIN_MICRO 1
+ if (CAIRO_VERSION < CAIRO_VERSION_ENCODE (CAIRO_MIN_MAJOR, CAIRO_MIN_MINOR, CAIRO_MIN_MICRO)) {
+ g_print ("ERROR: Cairo version %s cannot be used to run tests; must be at least %u.%u.%u.\n",
+ CAIRO_VERSION_STRING, CAIRO_MIN_MAJOR, CAIRO_MIN_MINOR, CAIRO_MIN_MICRO);
+ return FALSE;
+ } else if (verbose) {
+ g_print (" OK: Cairo version %s is ok; must be at least %u.%u.%u.\n",
+ CAIRO_VERSION_STRING, CAIRO_MIN_MAJOR, CAIRO_MIN_MINOR, CAIRO_MIN_MICRO);
+ }
+ return TRUE;
+}
+
+/* FIXME */
+#include <swfdec/swfdec_audio_decoder.h>
+static gboolean
+check_codecs (gboolean verbose)
+{
+ if (!swfdec_audio_decoder_prepare (SWFDEC_AUDIO_CODEC_MP3,
+ swfdec_audio_format_new (44100, 2, TRUE), NULL)) {
+ g_print ("ERROR: MP3 support is not available.\n");
+ } else if (verbose) {
+ g_print (" OK: MP3 support is available.\n");
+ }
+ return TRUE;
+}
+
+static gboolean
+check_system (gboolean verbose)
+{
+ gboolean ret = TRUE;
+
+ /* We want to run all checks, so don't use && here */
+ ret &= check_cairo (verbose);
+ ret &= check_codecs (verbose);
+
+ return ret;
+}
+
/* Start of script file */
#define SWFDEC_TEST_FILE_ID "Swfdec Test Script\0\1"
@@ -79,9 +124,12 @@ main (int argc, char **argv)
SwfdecAsValue val;
int i, ret;
gboolean dump = FALSE;
+ gboolean no_check = FALSE, only_check = FALSE;
GOptionEntry options[] = {
- { "dump", 'd', 0, G_OPTION_ARG_NONE, &dump, "dump images on failure", FALSE },
+ { "dump", 'd', 0, G_OPTION_ARG_NONE, &dump, "dump informative output on failure", FALSE },
+ { "no-check", 0, 0, G_OPTION_ARG_NONE, &no_check, "don't check if the system is ok for running the testsuite", FALSE },
+ { "self-check", 0, 0, G_OPTION_ARG_NONE, &only_check, "run a system check and exit", FALSE },
{ "player", 'p', 0, G_OPTION_ARG_STRING, &swfdec_test_plugin_name, "player to test", "NAME" },
{ "script", 's', 0, G_OPTION_ARG_STRING, &script_filename, "script to execute if not ./default.sts", "FILENAME" },
{ NULL }
@@ -107,6 +155,17 @@ main (int argc, char **argv)
return EXIT_FAILURE;
}
+ if (only_check || !no_check) {
+ gboolean result = check_system (only_check);
+ if (!result) {
+ g_print ("ERROR: System checked failed, aborting. Use --no-check to disable.\n");
+ return 1;
+ } else if (only_check) {
+ return 0;
+ }
+ }
+ g_assert (!only_check);
+
/* allow env vars instead of options - eases running make check with different settings */
if (swfdec_test_plugin_name == NULL)
swfdec_test_plugin_name = g_strdup (g_getenv ("SWFDEC_TEST_PLAYER"));
commit 177e9c2754e517b6aa50a46f48f517c891b33cc2
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Sep 7 03:17:45 2008 +0200
fix 2 memleaks
diff --git a/swfdec/swfdec_audio_decoder.c b/swfdec/swfdec_audio_decoder.c
index 2c0da78..72be732 100644
--- a/swfdec/swfdec_audio_decoder.c
+++ b/swfdec/swfdec_audio_decoder.c
@@ -74,6 +74,8 @@ swfdec_audio_decoder_prepare (guint codec, SwfdecAudioFormat format, char **miss
}
if (missing)
*missing = detail;
+ else
+ g_free (detail);
return FALSE;
}
diff --git a/swfdec/swfdec_video_decoder.c b/swfdec/swfdec_video_decoder.c
index aee07d5..c09a293 100644
--- a/swfdec/swfdec_video_decoder.c
+++ b/swfdec/swfdec_video_decoder.c
@@ -103,6 +103,8 @@ swfdec_video_decoder_prepare (guint codec, char **missing)
}
if (missing)
*missing = detail;
+ else
+ g_free (detail);
return FALSE;
}
More information about the Swfdec-commits
mailing list