|
|
159db5 |
From e7f940102d40997f2e23a0589247cfb189dfaa98 Mon Sep 17 00:00:00 2001
|
|
|
159db5 |
From: Iain Lane <iain@orangesquash.org.uk>
|
|
|
159db5 |
Date: Sun, 20 Sep 2015 13:24:21 +0100
|
|
|
159db5 |
Subject: [PATCH] Skip tests when we can't run them due to lack of memory
|
|
|
159db5 |
|
|
|
159db5 |
Check if we have failed due to insufficient memory and skip if
|
|
|
159db5 |
so.
|
|
|
159db5 |
|
|
|
159db5 |
https://bugzilla.gnome.org/show_bug.cgi?id=754387
|
|
|
159db5 |
---
|
|
|
159db5 |
tests/Makefile.am | 2 ++
|
|
|
159db5 |
tests/cve-2015-4491.c | 4 ++++
|
|
|
159db5 |
tests/pixbuf-scale.c | 25 ++++++++++++++++++++++---
|
|
|
159db5 |
tests/test-common.c | 14 ++++++++++++++
|
|
|
159db5 |
tests/test-common.h | 1 +
|
|
|
159db5 |
5 files changed, 43 insertions(+), 3 deletions(-)
|
|
|
159db5 |
|
|
|
159db5 |
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
|
159db5 |
index d5dca44..1f09711 100644
|
|
|
159db5 |
--- a/tests/Makefile.am
|
|
|
159db5 |
+++ b/tests/Makefile.am
|
|
|
159db5 |
@@ -65,6 +65,8 @@ dist_installed_test_data = \
|
|
|
159db5 |
|
|
|
159db5 |
cve_2015_4491_SOURCES = \
|
|
|
159db5 |
cve-2015-4491.c \
|
|
|
159db5 |
+ test-common.c \
|
|
|
159db5 |
+ test-common.h \
|
|
|
159db5 |
resources.h \
|
|
|
159db5 |
resources.c \
|
|
|
159db5 |
$(NULL)
|
|
|
159db5 |
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
|
159db5 |
index d5dca44..1f09711 100644
|
|
|
159db5 |
--- a/tests/Makefile.in
|
|
|
159db5 |
+++ b/tests/Makefile.in
|
|
|
159db5 |
@@ -202,7 +202,7 @@
|
|
|
159db5 |
am__v_lt_1 =
|
|
|
159db5 |
am__objects_1 =
|
|
|
159db5 |
am_cve_2015_4491_OBJECTS = cve-2015-4491.$(OBJEXT) resources.$(OBJEXT) \
|
|
|
159db5 |
- $(am__objects_1)
|
|
|
159db5 |
+ test-common.$(OBJEXT) $(am__objects_1)
|
|
|
159db5 |
cve_2015_4491_OBJECTS = $(am_cve_2015_4491_OBJECTS)
|
|
|
159db5 |
cve_2015_4491_LDADD = $(LDADD)
|
|
|
159db5 |
cve_2015_4491_DEPENDENCIES = $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GDK_PIXBUF_API_VERSION).la \
|
|
|
159db5 |
@@ -879,6 +879,8 @@
|
|
|
159db5 |
|
|
|
159db5 |
cve_2015_4491_SOURCES = \
|
|
|
159db5 |
cve-2015-4491.c \
|
|
|
159db5 |
+ test-common.c \
|
|
|
159db5 |
+ test-common.h \
|
|
|
159db5 |
resources.h \
|
|
|
159db5 |
resources.c \
|
|
|
159db5 |
$(NULL)
|
|
|
159db5 |
diff --git a/tests/cve-2015-4491.c b/tests/cve-2015-4491.c
|
|
|
159db5 |
index 34ba94f..988cb49 100644
|
|
|
159db5 |
--- a/tests/cve-2015-4491.c
|
|
|
159db5 |
+++ b/tests/cve-2015-4491.c
|
|
|
159db5 |
@@ -20,6 +20,8 @@
|
|
|
159db5 |
|
|
|
159db5 |
#include <gdk-pixbuf.h>
|
|
|
159db5 |
|
|
|
159db5 |
+#include "test-common.h"
|
|
|
159db5 |
+
|
|
|
159db5 |
static void
|
|
|
159db5 |
test_original (void)
|
|
|
159db5 |
{
|
|
|
159db5 |
@@ -28,6 +30,8 @@ test_original (void)
|
|
|
159db5 |
GError* err = NULL;
|
|
|
159db5 |
|
|
|
159db5 |
buf = gdk_pixbuf_new_from_resource_at_scale ("/test/resource/cve-2015-4491.bmp", size, size, FALSE, &err;;
|
|
|
159db5 |
+ if (skip_if_insufficient_memory (&err))
|
|
|
159db5 |
+ return;
|
|
|
159db5 |
|
|
|
159db5 |
g_assert_no_error (err);
|
|
|
159db5 |
|
|
|
159db5 |
diff --git a/tests/pixbuf-scale.c b/tests/pixbuf-scale.c
|
|
|
159db5 |
index e2be5f5..60d0a20 100644
|
|
|
159db5 |
--- a/tests/pixbuf-scale.c
|
|
|
159db5 |
+++ b/tests/pixbuf-scale.c
|
|
|
159db5 |
@@ -83,6 +83,9 @@ test_scale_down (gconstpointer data)
|
|
|
159db5 |
|
|
|
159db5 |
path = g_test_get_filename (G_TEST_DIST, filename, NULL);
|
|
|
159db5 |
ref = gdk_pixbuf_new_from_file (path, &error);
|
|
|
159db5 |
+
|
|
|
159db5 |
+ if (skip_if_insufficient_memory (&error))
|
|
|
159db5 |
+ return;
|
|
|
159db5 |
g_assert_no_error (error);
|
|
|
159db5 |
|
|
|
159db5 |
width = gdk_pixbuf_get_width (ref);
|
|
|
159db5 |
diff --git a/tests/test-common.c b/tests/test-common.c
|
|
|
159db5 |
index 7071d4c..0f70a8b 100644
|
|
|
159db5 |
--- a/tests/test-common.c
|
|
|
159db5 |
+++ b/tests/test-common.c
|
|
|
159db5 |
@@ -65,6 +65,20 @@ format_supported (const gchar *filename)
|
|
|
159db5 |
}
|
|
|
159db5 |
|
|
|
159db5 |
gboolean
|
|
|
159db5 |
+skip_if_insufficient_memory (GError **err)
|
|
|
159db5 |
+{
|
|
|
159db5 |
+ if (*err && g_error_matches (*err, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY))
|
|
|
159db5 |
+ {
|
|
|
159db5 |
+ g_test_skip ((*err)->message);
|
|
|
159db5 |
+ g_error_free (*err);
|
|
|
159db5 |
+ *err = NULL;
|
|
|
159db5 |
+ return TRUE;
|
|
|
159db5 |
+ }
|
|
|
159db5 |
+
|
|
|
159db5 |
+ return FALSE;
|
|
|
159db5 |
+}
|
|
|
159db5 |
+
|
|
|
159db5 |
+gboolean
|
|
|
159db5 |
pixdata_equal (GdkPixbuf *p1, GdkPixbuf *p2, GError **error)
|
|
|
159db5 |
{
|
|
|
159db5 |
if (gdk_pixbuf_get_colorspace (p1) != gdk_pixbuf_get_colorspace (p2)) {
|
|
|
159db5 |
diff --git a/tests/test-common.h b/tests/test-common.h
|
|
|
159db5 |
index 56e4418..0514cd7 100644
|
|
|
159db5 |
--- a/tests/test-common.h
|
|
|
159db5 |
+++ b/tests/test-common.h
|
|
|
159db5 |
@@ -28,6 +28,7 @@
|
|
|
159db5 |
G_BEGIN_DECLS
|
|
|
159db5 |
|
|
|
159db5 |
gboolean format_supported (const gchar *filename);
|
|
|
159db5 |
+gboolean skip_if_insufficient_memory (GError **err);
|
|
|
159db5 |
gboolean pixdata_equal (GdkPixbuf *p1, GdkPixbuf *p2, GError **error);
|
|
|
159db5 |
|
|
|
159db5 |
G_END_DECLS
|
|
|
159db5 |
--
|
|
|
159db5 |
2.4.3
|
|
|
159db5 |
|