summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2017-07-13 14:13:18 +0200
committerBastien Nocera <hadess@hadess.net>2017-07-13 14:31:19 +0200
commit4ffc78b66b60ac8741bc78be60386b3ddb0b33ba (patch)
treeef182b8c203a042784e450fe161a79dd0092a67d /tests
parentd64805f91cbd5e1db595234964423fbaa72d9cb8 (diff)
downloadgdk-pixbuf-4ffc78b66b60ac8741bc78be60386b3ddb0b33ba.tar.gz
tests: Split off failing test into 2 separate tests
One with the tiniest of buffers, one with the biggest one possible. This catches some crashes that weren't caught with the original "1 byte" buffers test. This makes it possible to reproduce the crasher in https://bugzilla.gnome.org/show_bug.cgi?id=784866
Diffstat (limited to 'tests')
-rw-r--r--tests/pixbuf-fail.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/tests/pixbuf-fail.c b/tests/pixbuf-fail.c
index 0e37c2da0..322d5f6f2 100644
--- a/tests/pixbuf-fail.c
+++ b/tests/pixbuf-fail.c
@@ -26,17 +26,16 @@
#include "test-common.h"
static void
-test_fail (gconstpointer data)
+test_fail_size (GFile *file,
+ guint chunk_size)
{
GdkPixbufLoader *loader;
GError *error = NULL;
- GFile *file;
guchar *contents;
gsize i, contents_length;
char *filename, *content_type, *mime_type;
gboolean success;
- file = G_FILE (data);
if (!file_supported (file))
{
g_test_skip ("format not supported");
@@ -57,9 +56,9 @@ test_fail (gconstpointer data)
g_assert_no_error (error);
g_assert (loader != NULL);
- for (i = 0; i < contents_length; i++)
+ for (i = 0; i < contents_length; i += chunk_size)
{
- success = gdk_pixbuf_loader_write (loader, &contents[i], 1, &error);
+ success = gdk_pixbuf_loader_write (loader, &contents[i], MIN(chunk_size, contents_length - i), &error);
if (!success)
{
g_assert (error);
@@ -82,6 +81,22 @@ out:
g_free (filename);
}
+static void
+test_fail_tiny (gconstpointer data)
+{
+ GFile *file = (GFile *) data;
+
+ test_fail_size (file, 1);
+}
+
+static void
+test_fail_huge (gconstpointer data)
+{
+ GFile *file = (GFile *) data;
+
+ test_fail_size (file, G_MAXUINT);
+}
+
int
main (int argc, char **argv)
{
@@ -96,7 +111,8 @@ main (int argc, char **argv)
test_images = g_build_filename (g_test_get_dir (G_TEST_DIST), "test-images/fail", NULL);
dir = g_file_new_for_path (test_images);
- add_test_for_all_images ("/pixbuf/fail", dir, dir, test_fail, NULL);
+ add_test_for_all_images ("/pixbuf/fail_tiny", dir, dir, test_fail_tiny, NULL);
+ add_test_for_all_images ("/pixbuf/fail_huge", dir, dir, test_fail_huge, NULL);
g_object_unref (dir);
g_free (test_images);
@@ -109,7 +125,8 @@ main (int argc, char **argv)
{
GFile *file = g_file_new_for_commandline_arg (argv[i]);
- add_test_for_all_images ("/pixbuf/fail", NULL, file, test_fail, NULL);
+ add_test_for_all_images ("/pixbuf/fail_tiny", NULL, file, test_fail_tiny, NULL);
+ add_test_for_all_images ("/pixbuf/fail_huge", NULL, file, test_fail_huge, NULL);
g_object_unref (file);
}