[gegl/soc-2012-ville] more informative error messages for operation test tool



commit 199e21be8353e4c3c4c50e84c98047bd220761a6
Author: Ville Sokk <ville sokk gmail com>
Date:   Wed Jul 4 11:20:17 2012 +0300

    more informative error messages for operation test tool

 bin/gegl-tester.c |   84 +++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 56 insertions(+), 28 deletions(-)
---
diff --git a/bin/gegl-tester.c b/bin/gegl-tester.c
index 8f541f1..4c41bcc 100644
--- a/bin/gegl-tester.c
+++ b/bin/gegl-tester.c
@@ -26,7 +26,7 @@ static GRegex *regex;
 static gchar  *data_dir;
 static gchar  *reference_dir;
 static gchar  *output_dir;
-static gchar  *pattern;
+static gchar  *pattern = "";
 
 static const GOptionEntry options[] =
 {
@@ -89,6 +89,9 @@ process_operations (GType type)
             }
           else
             {
+              GeglRectangle ref_bounds, comp_bounds;
+              gint          ref_pixels;
+
               output = gegl_node_new_child (composition,
                                             "operation", "gegl:save",
                                             "path", output_path,
@@ -101,38 +104,63 @@ process_operations (GType type)
                                              "path", image_path,
                                              NULL);
 
-              comparison = gegl_node_create_child (composition, "gegl:image-compare");
-
-              gegl_node_link_many (composition, comparison, NULL);
-              gegl_node_connect_to (ref_img, "output", comparison, "aux");
-              gegl_node_process (comparison);
-              gegl_node_get (comparison, "max diff", &max_diff, NULL);
+              ref_bounds  = gegl_node_get_bounding_box (ref_img);
+              comp_bounds = gegl_node_get_bounding_box (composition);
+              ref_pixels  = ref_bounds.width * ref_bounds.height;
 
-              if (max_diff < 1.0)
+              if (ref_pixels != (comp_bounds.width * comp_bounds.height))
                 {
-                  g_printf ("PASS\n");
-                  result = result && TRUE;
+                  g_printf ("FAIL\n  Reference and composition differ in size\n");
+                  result = FALSE;
                 }
               else
                 {
-                  gint   img_length = strlen (image);
-                  gchar *diff_file  = g_malloc (img_length + 16);
-                  gint   ext_length = strlen (strrchr (image, '.'));
-
-                  memcpy (diff_file, image, img_length + 1);
-                  memcpy (diff_file + img_length - ext_length, "-diff.png", 11);
-
-                  g_free (output_path);
-                  output_path = g_build_path (G_DIR_SEPARATOR_S, output_dir, diff_file, NULL);
-
-                  gegl_node_set (output, "path", output_path, NULL);
-                  gegl_node_link_many (comparison, output, NULL);
-                  gegl_node_process (output);
-
-                  g_free (diff_file);
-
-                  g_printf ("FAIL\n");
-                  result = result && FALSE;
+                  comparison = gegl_node_create_child (composition, "gegl:image-compare");
+
+                  gegl_node_link_many (composition, comparison, NULL);
+                  gegl_node_connect_to (ref_img, "output", comparison, "aux");
+                  gegl_node_process (comparison);
+                  gegl_node_get (comparison, "max diff", &max_diff, NULL);
+
+                  if (max_diff < 1.0)
+                    {
+                      g_printf ("PASS\n");
+                      result = result && TRUE;
+                    }
+                  else
+                    {
+                      gint     img_length = strlen (image);
+                      gchar   *diff_file  = g_malloc (img_length + 16);
+                      gint     ext_length = strlen (strrchr (image, '.'));
+                      gdouble  avg_diff_wrong, avg_diff_total;
+                      gint     wrong_pixels;
+
+                      gegl_node_get (comparison, "avg_diff_wrong", &avg_diff_wrong,
+                                     "avg_diff_total", &avg_diff_total, "wrong_pixels",
+                                     &wrong_pixels, NULL);
+
+                      g_printf ("FAIL\n  Reference image and composition differ\n"
+                                "    wrong pixels : %i/%i (%2.2f%%)\n"
+                                "    max Îe       : %2.3f\n"
+                                "    avg Îe       : %2.3f (wrong) %2.3f (total)\n",
+                                wrong_pixels, ref_pixels, (wrong_pixels * 100.0 / ref_pixels),
+                                max_diff,
+                                avg_diff_wrong, avg_diff_total);
+
+                      memcpy (diff_file, image, img_length + 1);
+                      memcpy (diff_file + img_length - ext_length, "-diff.png", 11);
+
+                      g_free (output_path);
+                      output_path = g_build_path (G_DIR_SEPARATOR_S, output_dir, diff_file, NULL);
+
+                      gegl_node_set (output, "path", output_path, NULL);
+                      gegl_node_link_many (comparison, output, NULL);
+                      gegl_node_process (output);
+
+                      g_free (diff_file);
+
+                      result = FALSE;
+                    }
                 }
             }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]