Re: Make'em suffer!



On Fri, 2006-08-04 at 19:07 +0200, ext Manu Cornet wrote:

> 
> > 3) A way to run the performance tests non-interactively. (Running all
> >    would be fine with me, though maybe someone else would find it
> >    useful to select a subset of the tests).
> 
> Okay, that would be useful indeed, adding it to my TODO list :)

Attached is a patch to use GOption command line arguments to run in
non-interactive mode:


Application Options:
  -t, --torture-full                                                        Run full torture
  -w, --torture-widgets=GType coma separated list of widgets to torture     Run torture over specified widgets
  -x, --torture-level=[1-100]                                               Torture level
  -l, --list-torture-widgets                                                List supported widgets
  -c, --crash-full                                                          Run full crashes
  -f, --crash-funtions=coma separated list of funtions to crash             Run crashes over specified functions
  -z, --list-crash-funtions                                                 List supported crash functions

So now we can integrate this great torture test into the continuous
integration systems like jhautobuild or buildbot, for automatic
testing/profiling to detect performance regressions and so.

Salu2

diff --git a/gtk-theme-torturer/paint.c b/gtk-theme-torturer/paint.c
index 4747689..f58b438 100644
--- a/gtk-theme-torturer/paint.c
+++ b/gtk-theme-torturer/paint.c
@@ -255,7 +255,6 @@ set_layout (PangoLayout *layout, GtkWidg
   return layout;
 }
 
-#define TEST_IS_ACTIVE(i) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkboxes[i]))
 
 /* All gtk_paint_* functions use at least these 6 parameters: style, window, detail,
  * state_type, area, widget.
@@ -270,6 +269,7 @@ test_state_shadow_area_detail_size_funct
   GtkDetailDummyType detail;
   GtkAreaDummyType area;
   GtkSizeDummyType size;
+  guint32 tests = GPOINTER_TO_UINT(data);
 
   gint          width, height, i = 0;
   gchar        *detail_string;
@@ -291,43 +291,43 @@ test_state_shadow_area_detail_size_funct
   rectangle = set_area (area);
   printf ("\n");
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_BOXES)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_BOXES)) {
     printf ("Testing box... ");
     fflush (NULL); /* Flush all open streams (i.e. stdout) so that everything gets printed before the crash, if any */
     gtk_paint_box (style, window, state, shadow, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height);
     printf ("OK\n");
   }
-  if (TEST_IS_ACTIVE (GTK_PAINT_CHECKS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_CHECKS)) {
     printf ("Testing check... ");
     fflush (NULL);
     gtk_paint_check (style, window, state, shadow, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height);
     printf ("OK\n");
   }
-  if (TEST_IS_ACTIVE (GTK_PAINT_DIAMONDS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_DIAMONDS)) {
     printf ("Testing diamond... ");
     fflush (NULL);
     gtk_paint_diamond (style, window, state, shadow, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height);
     printf ("OK\n");
   }
-  if (TEST_IS_ACTIVE (GTK_PAINT_FLAT_BOXES)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_FLAT_BOXES)) {
     printf ("Testing flat box... ");
     fflush (NULL);
     gtk_paint_flat_box (style, window, state, shadow, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height);
     printf ("OK\n");
   }
-  if (TEST_IS_ACTIVE (GTK_PAINT_OPTIONS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_OPTIONS)) {
     printf ("Testing option... ");
     fflush (NULL);
     gtk_paint_option (style, window, state, shadow, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height);
     printf ("OK\n");
   }
-  if (TEST_IS_ACTIVE (GTK_PAINT_SHADOWS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_SHADOWS)) {
     printf ("Testing shadow... ");
     fflush (NULL);
     gtk_paint_shadow (style, window, state, shadow, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height);
     printf ("OK\n");
   }
-  if (TEST_IS_ACTIVE (GTK_PAINT_TABS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_TABS)) {
     printf ("Testing tab... ");
     fflush (NULL);
     gtk_paint_tab (style, window, state, shadow, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height);
@@ -348,6 +348,7 @@ test_state_area_detail_size_functions (i
   GtkDetailDummyType detail;
   GtkAreaDummyType area;
   GtkSizeDummyType size;
+  guint32 tests = GPOINTER_TO_UINT(data);
 
   gint          width, height, i = 0;
   gchar        *detail_string;
@@ -368,7 +369,7 @@ test_state_area_detail_size_functions (i
   rectangle = set_area (area);
   printf ("\n");
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_HLINES)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_HLINES)) {
     printf ("(hline : x1 = %i   x2 = %i   y = %i) ", POS_X, POS_X + width, POS_Y);
     printf ("Testing hline... ");
     fflush (NULL);
@@ -376,7 +377,7 @@ test_state_area_detail_size_functions (i
     printf ("OK\n");
   }
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_VLINES)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_VLINES)) {
     printf ("(vline : y1 = %i   y2 = %i   x = %i) ", POS_Y, POS_Y + height, POS_X);
     printf ("Testing vline... ");
     fflush (NULL);
@@ -384,7 +385,7 @@ test_state_area_detail_size_functions (i
     printf ("OK\n");
   }
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_FOCUSES)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_FOCUSES)) {
     printf ("Testing focus... ");
     fflush (NULL);
     gtk_paint_focus (style, window, state, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height);
@@ -408,6 +409,7 @@ test_state_shadow_area_detail_arrow_fill
   GtkAreaDummyType   area;
   GtkBoolDummyType   fill;
   GtkSizeDummyType   size;
+  guint32 tests = GPOINTER_TO_UINT(data);
 
   gint          width, height, i = 0;
   gchar        *detail_string;
@@ -432,7 +434,7 @@ test_state_shadow_area_detail_arrow_fill
   height = width;
   rectangle = set_area (area);
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_ARROWS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_ARROWS)) {
     printf ("Testing arrow... ");
     fflush (NULL); /* Flush all open streams (i.e. stdout) so that everything gets printed before the crash, if any */
     gtk_paint_arrow (style, window, state, shadow, rectangle, drawing_area, detail_string, arrow, fill, POS_X, POS_Y, width, height);
@@ -461,6 +463,7 @@ test_state_shadow_area_detail_size_gaps_
   gint          width, height, gap_x_int, gap_width_int, i = 0;
   gchar        *detail_string;
   GdkRectangle *rectangle;
+  guint32 tests = GPOINTER_TO_UINT(data);
   
   state     = values[i++];
   shadow    = values[i++];
@@ -483,14 +486,14 @@ test_state_shadow_area_detail_size_gaps_
   gap_width_int = set_gap_width (gap_width);
   printf ("\n");
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_BOX_GAPS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_BOX_GAPS)) {
     printf ("Testing box gap... ");
     fflush (NULL); /* Flush all open streams (i.e. stdout) so that everything gets printed before the crash, if any */
     gtk_paint_box_gap (style, window, state, shadow, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height, gap_side, gap_x_int, gap_width_int);
     printf ("OK\n");
   }
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_SHADOW_GAPS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_SHADOW_GAPS)) {
     printf ("Testing shadow gap... ");
     fflush (NULL);
     gtk_paint_shadow_gap (style, window, state, shadow, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height, gap_side, gap_x_int, gap_width_int);
@@ -517,6 +520,7 @@ test_state_shadow_area_detail_size_gapsi
   gint          width, height, i = 0;
   gchar        *detail_string;
   GdkRectangle *rectangle;
+  guint32 tests = GPOINTER_TO_UINT(data);
   
   state     = values[i++];
   shadow    = values[i++];
@@ -534,7 +538,7 @@ test_state_shadow_area_detail_size_gapsi
   height = width;
   rectangle = set_area (area);
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_EXTENSIONS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_EXTENSIONS)) {
     printf ("Testing extension... ");
     fflush (NULL); /* Flush all open streams (i.e. stdout) so that everything gets printed before the crash, if any */
     gtk_paint_extension (style, window, state, shadow, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height, gap_side);
@@ -561,6 +565,7 @@ test_state_shadow_area_detail_size_orien
   gint          width, height, i = 0;
   gchar        *detail_string;
   GdkRectangle *rectangle;
+  guint32 tests = GPOINTER_TO_UINT(data);
   
   state        = values[i++];
   shadow       = values[i++];
@@ -579,14 +584,14 @@ test_state_shadow_area_detail_size_orien
   rectangle = set_area (area);
   printf ("\n");
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_HANDLES)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_HANDLES)) {
     printf ("Testing handle... ");
     fflush (NULL); /* Flush all open streams (i.e. stdout) so that everything gets printed before the crash, if any */
     gtk_paint_handle (style, window, state, shadow, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height, orientation);
     printf ("OK\n");
   }
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_SLIDERS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_SLIDERS)) {
     printf ("Testing slider... ");
     fflush (NULL);
     gtk_paint_slider (style, window, state, shadow, rectangle, drawing_area, detail_string, POS_X, POS_Y, width, height, orientation);
@@ -617,6 +622,7 @@ test_state_shadow_area_detail_fill_point
   gchar        *detail_string;
   GdkRectangle *rectangle;
   gboolean      fill_gboolean;
+  guint32 tests = GPOINTER_TO_UINT(data);
   
   state  = values[i++];
   shadow = values[i++];
@@ -635,7 +641,7 @@ test_state_shadow_area_detail_fill_point
   /* Set the polygon */
   points = set_polygon (points, &npoints);
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_POLYGONS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_POLYGONS)) {
     printf ("Testing polygon... ");
     fflush (NULL); /* Flush all open streams (i.e. stdout) so that everything gets printed before the crash, if any */
     gtk_paint_polygon (style, window, state, shadow, rectangle, drawing_area, detail_string, points, npoints, fill);
@@ -662,6 +668,7 @@ test_state_area_detail_expander_function
   gint          i = 0;
   gchar        *detail_string;
   GdkRectangle *rectangle;
+  guint32 tests = GPOINTER_TO_UINT(data);
   
   state        = values[i++];
   expander     = values[i++];
@@ -675,7 +682,7 @@ test_state_area_detail_expander_function
   detail_string = set_detail (detail);
   rectangle = set_area (area);
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_EXPANDERS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_EXPANDERS)) {
     printf ("Testing expander... ");
     fflush (NULL);
     gtk_paint_expander (style, window, state, rectangle, drawing_area, detail_string, POS_X, POS_Y, expander);
@@ -704,6 +711,7 @@ test_state_usetext_area_detail_layout_fu
   gchar        *detail_string;
   GdkRectangle *rectangle;
   gboolean      use_text_gboolean;
+  guint32 tests = GPOINTER_TO_UINT(data);
   
   state    = values[i++];
   detail   = values[i++];
@@ -721,7 +729,7 @@ test_state_usetext_area_detail_layout_fu
   /* Set the layout */
   layout = set_layout (layout, drawing_area);
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_LAYOUTS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_LAYOUTS)) {
     printf ("Testing layout... ");
     fflush (NULL); /* Flush all open streams (i.e. stdout) so that everything gets printed before the crash, if any */
     gtk_paint_layout (style, window, state, use_text_gboolean, rectangle, drawing_area, detail_string, POS_X, POS_Y, layout);
@@ -749,6 +757,7 @@ test_state_area_detail_edge_size_functio
   gint          width, height, i = 0;
   gchar        *detail_string;
   GdkRectangle *rectangle;
+  guint32 tests = GPOINTER_TO_UINT(data);
   
   state  = values[i++];
   edge   = values[i++];
@@ -765,7 +774,7 @@ test_state_area_detail_edge_size_functio
   height = width;
   rectangle = set_area (area);
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_RESIZE_GRIPS)) {
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_RESIZE_GRIPS)) {
     printf ("Testing resize grip... ");
     fflush (NULL);
     gtk_paint_resize_grip (style, window, state, rectangle, drawing_area, detail_string, edge, POS_X, POS_Y, width, height);
@@ -780,7 +789,7 @@ test_state_area_detail_edge_size_functio
 
 /* Now the functions that define enums and do the "foreach" loop */
 static void
-test_all_state_shadow_area_detail_size (void)
+test_all_state_shadow_area_detail_size (guint32 tests)
 {
   GType enum_types[] = {
     GTK_TYPE_STATE_TYPE,
@@ -791,11 +800,11 @@ test_all_state_shadow_area_detail_size (
   };
   int num_enum_types = G_N_ELEMENTS (enum_types);
   
-  foreach_combination_of_enums (enum_types, num_enum_types, test_state_shadow_area_detail_size_functions, NULL);
+  foreach_combination_of_enums (enum_types, num_enum_types, test_state_shadow_area_detail_size_functions, GUINT_TO_POINTER(tests));
 }
 
 static void
-test_all_state_area_detail_size (void)
+test_all_state_area_detail_size (guint32 tests)
 {
   GType enum_types[] = {
     GTK_TYPE_STATE_TYPE,
@@ -805,11 +814,11 @@ test_all_state_area_detail_size (void)
   };
   int num_enum_types = G_N_ELEMENTS (enum_types);
   
-  foreach_combination_of_enums (enum_types, num_enum_types, test_state_area_detail_size_functions, NULL);
+  foreach_combination_of_enums (enum_types, num_enum_types, test_state_area_detail_size_functions, GUINT_TO_POINTER(tests));
 }
 
 static void
-test_all_state_shadow_area_detail_arrow_fill_size (void)
+test_all_state_shadow_area_detail_arrow_fill_size (guint32 tests)
 {
   GType enum_types[] = {
     GTK_TYPE_STATE_TYPE,
@@ -822,11 +831,11 @@ test_all_state_shadow_area_detail_arrow_
   };
   int num_enum_types = G_N_ELEMENTS (enum_types);
   
-  foreach_combination_of_enums (enum_types, num_enum_types, test_state_shadow_area_detail_arrow_fill_size_functions, NULL);
+  foreach_combination_of_enums (enum_types, num_enum_types, test_state_shadow_area_detail_arrow_fill_size_functions, GUINT_TO_POINTER(tests));
 }
 
 static void
-test_all_state_shadow_area_detail_size_gaps_functions (void)
+test_all_state_shadow_area_detail_size_gaps_functions (guint32 tests)
 {
   GType enum_types[] = {
     GTK_TYPE_STATE_TYPE,
@@ -840,11 +849,11 @@ test_all_state_shadow_area_detail_size_g
   };
   int num_enum_types = G_N_ELEMENTS (enum_types);
   
-  foreach_combination_of_enums (enum_types, num_enum_types, test_state_shadow_area_detail_size_gaps_functions, NULL);
+  foreach_combination_of_enums (enum_types, num_enum_types, test_state_shadow_area_detail_size_gaps_functions, GUINT_TO_POINTER(tests));
 }
 
 static void
-test_all_state_shadow_area_detail_size_gapside_functions (void)
+test_all_state_shadow_area_detail_size_gapside_functions (guint32 tests)
 {
   GType enum_types[] = {
     GTK_TYPE_STATE_TYPE,
@@ -856,11 +865,11 @@ test_all_state_shadow_area_detail_size_g
   };
   int num_enum_types = G_N_ELEMENTS (enum_types);
   
-  foreach_combination_of_enums (enum_types, num_enum_types, test_state_shadow_area_detail_size_gapside_functions, NULL);
+  foreach_combination_of_enums (enum_types, num_enum_types, test_state_shadow_area_detail_size_gapside_functions, GUINT_TO_POINTER(tests));
 }
 
 static void
-test_all_state_shadow_area_detail_size_orientation_functions (void)
+test_all_state_shadow_area_detail_size_orientation_functions (guint32 tests)
 {
   GType enum_types[] = {
     GTK_TYPE_STATE_TYPE,
@@ -872,11 +881,11 @@ test_all_state_shadow_area_detail_size_o
   };
   int num_enum_types = G_N_ELEMENTS (enum_types);
   
-  foreach_combination_of_enums (enum_types, num_enum_types, test_state_shadow_area_detail_size_orientation_functions, NULL);
+  foreach_combination_of_enums (enum_types, num_enum_types, test_state_shadow_area_detail_size_orientation_functions, GUINT_TO_POINTER(tests));
 }
 
 static void
-test_all_state_shadow_area_detail_fill_points_npoints_functions (void)
+test_all_state_shadow_area_detail_fill_points_npoints_functions (guint32 tests)
 {
   GType enum_types[] = {
     GTK_TYPE_STATE_TYPE,
@@ -887,11 +896,11 @@ test_all_state_shadow_area_detail_fill_p
   };
   int num_enum_types = G_N_ELEMENTS (enum_types);
   
-  foreach_combination_of_enums (enum_types, num_enum_types, test_state_shadow_area_detail_fill_points_npoints_functions, NULL);
+  foreach_combination_of_enums (enum_types, num_enum_types, test_state_shadow_area_detail_fill_points_npoints_functions, GUINT_TO_POINTER(tests));
 }
 
 static void
-test_all_state_area_detail_expander_functions (void)
+test_all_state_area_detail_expander_functions (guint32 tests)
 {
   GType enum_types[] = {
     GTK_TYPE_STATE_TYPE,
@@ -901,11 +910,11 @@ test_all_state_area_detail_expander_func
   };
   int num_enum_types = G_N_ELEMENTS (enum_types);
   
-  foreach_combination_of_enums (enum_types, num_enum_types, test_state_area_detail_expander_functions, NULL);
+  foreach_combination_of_enums (enum_types, num_enum_types, test_state_area_detail_expander_functions, GUINT_TO_POINTER(tests));
 }
 
 static void
-test_all_state_usetext_area_detail_layout_functions (void)
+test_all_state_usetext_area_detail_layout_functions (guint32 tests)
 {
   GType enum_types[] = {
     GTK_TYPE_STATE_TYPE,
@@ -915,11 +924,11 @@ test_all_state_usetext_area_detail_layou
   };
   int num_enum_types = G_N_ELEMENTS (enum_types);
   
-  foreach_combination_of_enums (enum_types, num_enum_types, test_state_usetext_area_detail_layout_functions, NULL);
+  foreach_combination_of_enums (enum_types, num_enum_types, test_state_usetext_area_detail_layout_functions, GUINT_TO_POINTER(tests));
 }
 
 static void
-test_all_state_area_detail_edge_size_functions (void)
+test_all_state_area_detail_edge_size_functions (guint32 tests)
 {
   GType enum_types[] = {
     GTK_TYPE_STATE_TYPE,
@@ -930,7 +939,7 @@ test_all_state_area_detail_edge_size_fun
   };
   int num_enum_types = G_N_ELEMENTS (enum_types);
   
-  foreach_combination_of_enums (enum_types, num_enum_types, test_state_area_detail_edge_size_functions, NULL);
+  foreach_combination_of_enums (enum_types, num_enum_types, test_state_area_detail_edge_size_functions, GUINT_TO_POINTER(tests));
 }
 
 int area_width;
@@ -939,6 +948,7 @@ int area_height;
 static gboolean
 map_event_cb (GtkWidget *widget, GdkEventAny *event, gpointer data)
 {
+  guint32 tests = GPOINTER_TO_UINT(data);
   style = gtk_widget_get_style (widget);
 
   window = widget->window;
@@ -947,48 +957,48 @@ map_event_cb (GtkWidget *widget, GdkEven
   while (gtk_events_pending ())
     gtk_main_iteration ();
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_BOXES) || TEST_IS_ACTIVE (GTK_PAINT_CHECKS)
-      || TEST_IS_ACTIVE (GTK_PAINT_DIAMONDS) || TEST_IS_ACTIVE (GTK_PAINT_FLAT_BOXES)
-      || TEST_IS_ACTIVE (GTK_PAINT_OPTIONS) || TEST_IS_ACTIVE (GTK_PAINT_SHADOWS)
-      || TEST_IS_ACTIVE (GTK_PAINT_TABS)) {
-    test_all_state_shadow_area_detail_size ();
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_BOXES) || TEST_IS_ACTIVE (tests, GTK_PAINT_CHECKS)
+      || TEST_IS_ACTIVE (tests, GTK_PAINT_DIAMONDS) || TEST_IS_ACTIVE (tests, GTK_PAINT_FLAT_BOXES)
+      || TEST_IS_ACTIVE (tests, GTK_PAINT_OPTIONS) || TEST_IS_ACTIVE (tests, GTK_PAINT_SHADOWS)
+      || TEST_IS_ACTIVE (tests, GTK_PAINT_TABS)) {
+    test_all_state_shadow_area_detail_size (tests);
   }
   
-  if (TEST_IS_ACTIVE (GTK_PAINT_FOCUSES) || TEST_IS_ACTIVE (GTK_PAINT_HLINES)
-      || TEST_IS_ACTIVE (GTK_PAINT_VLINES)) {
-    test_all_state_area_detail_size ();
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_FOCUSES) || TEST_IS_ACTIVE (tests, GTK_PAINT_HLINES)
+      || TEST_IS_ACTIVE (tests, GTK_PAINT_VLINES)) {
+    test_all_state_area_detail_size (tests);
   }
   
-  if (TEST_IS_ACTIVE (GTK_PAINT_ARROWS)) {
-    test_all_state_shadow_area_detail_arrow_fill_size ();
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_ARROWS)) {
+    test_all_state_shadow_area_detail_arrow_fill_size (tests);
   }
   
-  if (TEST_IS_ACTIVE (GTK_PAINT_BOX_GAPS) || TEST_IS_ACTIVE (GTK_PAINT_SHADOW_GAPS)) {
-    test_all_state_shadow_area_detail_size_gaps_functions ();
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_BOX_GAPS) || TEST_IS_ACTIVE (tests, GTK_PAINT_SHADOW_GAPS)) {
+    test_all_state_shadow_area_detail_size_gaps_functions (tests);
   }
   
-  if (TEST_IS_ACTIVE (GTK_PAINT_EXTENSIONS)) {
-    test_all_state_shadow_area_detail_size_gapside_functions ();
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_EXTENSIONS)) {
+    test_all_state_shadow_area_detail_size_gapside_functions (tests);
   }
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_HANDLES) || TEST_IS_ACTIVE (GTK_PAINT_SLIDERS)) {
-    test_all_state_shadow_area_detail_size_orientation_functions ();
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_HANDLES) || TEST_IS_ACTIVE (tests, GTK_PAINT_SLIDERS)) {
+    test_all_state_shadow_area_detail_size_orientation_functions (tests);
   }
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_POLYGONS)) {
-    test_all_state_shadow_area_detail_fill_points_npoints_functions ();
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_POLYGONS)) {
+    test_all_state_shadow_area_detail_fill_points_npoints_functions (tests);
   }
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_EXPANDERS)) {
-    test_all_state_area_detail_expander_functions ();
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_EXPANDERS)) {
+    test_all_state_area_detail_expander_functions (tests);
   }
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_LAYOUTS)) {
-    test_all_state_usetext_area_detail_layout_functions ();
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_LAYOUTS)) {
+    test_all_state_usetext_area_detail_layout_functions (tests);
   }
 
-  if (TEST_IS_ACTIVE (GTK_PAINT_RESIZE_GRIPS)) {
-    test_all_state_area_detail_edge_size_functions ();
+  if (TEST_IS_ACTIVE (tests, GTK_PAINT_RESIZE_GRIPS)) {
+    test_all_state_area_detail_edge_size_functions (tests);
   }
 
   gtk_label_set_text (GTK_LABEL (crash_test_label), "Finished. No crashes occurred.");
@@ -999,7 +1009,7 @@ map_event_cb (GtkWidget *widget, GdkEven
 }
 
 void
-gtk_paint_functions_test (GtkWidget *useless, GtkWidget **incoming_checkboxes)
+gtk_paint_functions_test (guint32 tests)
 {
   /* GTK initializations */
   test_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -1009,9 +1019,8 @@ gtk_paint_functions_test (GtkWidget *use
 
   drawing_area = gtk_drawing_area_new ();
   g_signal_connect (drawing_area, "map-event",
-		    G_CALLBACK (map_event_cb), NULL);
+		    G_CALLBACK (map_event_cb), GUINT_TO_POINTER(tests));
   gtk_container_add (GTK_CONTAINER (test_window), drawing_area);
-  checkboxes = incoming_checkboxes;
 
   gtk_widget_show_all (test_window);
 }
diff --git a/gtk-theme-torturer/paint.h b/gtk-theme-torturer/paint.h
index fd59214..b5d596d 100644
--- a/gtk-theme-torturer/paint.h
+++ b/gtk-theme-torturer/paint.h
@@ -1,3 +1,3 @@
 #include <gtk/gtk.h>
 
-void gtk_paint_functions_test ();
+void gtk_paint_functions_test (guint32 tests);
diff --git a/gtk-theme-torturer/torturer.c b/gtk-theme-torturer/torturer.c
index 7088ad8..e5f0f0e 100644
--- a/gtk-theme-torturer/torturer.c
+++ b/gtk-theme-torturer/torturer.c
@@ -1,3 +1,5 @@
+#include <string.h>
+
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
 
@@ -6,6 +8,7 @@
 #include "gtkwidgetprofiler.h"
 
 GType     *types;
+gchar    **function_name;
 GtkWidget *crash_test_label;
 int        torture_level = 7;
 int        current_widget_type;
@@ -36,6 +39,36 @@ initialize_types (void) {
 }
 
 static void
+initialize_functions (void) {
+	
+  function_name = g_new (gchar *, N_GTK_PAINT_FUNCTIONS);
+
+  function_name[GTK_PAINT_ARROWS]       = g_strdup_printf ("Arrows");
+  function_name[GTK_PAINT_BOXES]        = g_strdup_printf ("Boxes");
+  function_name[GTK_PAINT_BOX_GAPS]     = g_strdup_printf ("Box gaps");
+  function_name[GTK_PAINT_CHECKS]       = g_strdup_printf ("Checks");
+  function_name[GTK_PAINT_DIAMONDS]     = g_strdup_printf ("Diamonds");
+  function_name[GTK_PAINT_EXTENSIONS]   = g_strdup_printf ("Extensions");
+  function_name[GTK_PAINT_FLAT_BOXES]   = g_strdup_printf ("Flat boxes");
+  function_name[GTK_PAINT_FOCUSES]      = g_strdup_printf ("Focuses");
+  function_name[GTK_PAINT_HANDLES]      = g_strdup_printf ("Handles");
+  function_name[GTK_PAINT_HLINES]       = g_strdup_printf ("HLines");
+
+  function_name[GTK_PAINT_OPTIONS]      = g_strdup_printf ("Options");
+  function_name[GTK_PAINT_POLYGONS]     = g_strdup_printf ("Polygons");
+  function_name[GTK_PAINT_SHADOWS]      = g_strdup_printf ("Shadows");
+  function_name[GTK_PAINT_SHADOW_GAPS]  = g_strdup_printf ("Shadow gaps");
+  function_name[GTK_PAINT_SLIDERS]      = g_strdup_printf ("Sliders");
+  function_name[GTK_PAINT_TABS]         = g_strdup_printf ("Tabs");
+  function_name[GTK_PAINT_VLINES]       = g_strdup_printf ("VLines");
+  function_name[GTK_PAINT_EXPANDERS]    = g_strdup_printf ("Expanders");
+  function_name[GTK_PAINT_LAYOUTS]      = g_strdup_printf ("Layouts");
+  function_name[GTK_PAINT_RESIZE_GRIPS] = g_strdup_printf ("Resize grips");
+}
+
+
+
+static void
 reset_total_expose_timer (void) {
   total_expose = 0.;
 }
@@ -231,8 +264,38 @@ crash_test_uncheck_all (GtkWidget *usele
   }
 }
 
-int
-main (int argc, char **argv) {
+static void
+run_crash_test (GtkButton *useless, gpointer data) {
+  int i;
+  GtkWidget **function_checkboxes;
+  guint32 tests = 0;
+  
+  function_checkboxes = (GtkWidget **) data;
+  for (i = 0; i < N_GTK_PAINT_FUNCTIONS; i++) {
+    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (function_checkboxes[i]))) {
+	    ACTIVE(tests,i);
+    }
+  }
+
+  gtk_paint_functions_test (tests);
+}
+
+static void
+run_all_crash_test ()
+{
+  int i;
+  guint32 tests = 0;
+
+  for (i = 0; i < N_GTK_PAINT_FUNCTIONS; i++)
+    ACTIVE(tests,i);
+
+  gtk_paint_functions_test (tests);
+  while (gtk_events_pending())
+	  gtk_main_iteration();
+}
+
+void
+create_main_window (void) {
   
   GtkWidget *window, *main_vbox, *notebook, *close_button, // General widgets
     *torture_tab_label, *main_torture_vbox, *widget_vbox, *middle_hbox, *label, *scrolled_window, // Torture widgets 
@@ -241,12 +304,8 @@ main (int argc, char **argv) {
     *crash_test_checkboxes_vbox1, *crash_test_checkboxes_vbox2, *crash_test_check_all_button,
     *crash_test_uncheck_all_button, *crash_test_check_uncheck_hbox;  // Crash test widgets
   int i;
-  gchar   **function_name;
-
-  g_set_application_name ("GTK+ Theme Torture Program");
 
   /* Usual GTK starting blocks */
-  gtk_init (&argc, &argv);
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_container_set_border_width (GTK_CONTAINER (window), 10);
   g_signal_connect (window, "delete-event", G_CALLBACK (gtk_false), NULL);
@@ -295,7 +354,6 @@ main (int argc, char **argv) {
   gtk_box_pack_start (GTK_BOX (middle_hbox), scrolled_window, TRUE, TRUE, 2);
 
   /* The widget list */
-  initialize_types ();
   make_widget_list (widget_vbox);
 
   /* The torture level */
@@ -334,31 +392,7 @@ main (int argc, char **argv) {
 
   /* The checkboxes */
   function_checkboxes = g_new (GtkWidget *, N_GTK_PAINT_FUNCTIONS);
-  function_name = g_new (gchar *, N_GTK_PAINT_FUNCTIONS);
-
   i = 0;
-  function_name[GTK_PAINT_ARROWS]       = g_strdup_printf ("Arrows");
-  function_name[GTK_PAINT_BOXES]        = g_strdup_printf ("Boxes");
-  function_name[GTK_PAINT_BOX_GAPS]     = g_strdup_printf ("Box gaps");
-  function_name[GTK_PAINT_CHECKS]       = g_strdup_printf ("Checks");
-  function_name[GTK_PAINT_DIAMONDS]     = g_strdup_printf ("Diamonds");
-  function_name[GTK_PAINT_EXTENSIONS]   = g_strdup_printf ("Extensions");
-  function_name[GTK_PAINT_FLAT_BOXES]   = g_strdup_printf ("Flat boxes");
-  function_name[GTK_PAINT_FOCUSES]      = g_strdup_printf ("Focuses");
-  function_name[GTK_PAINT_HANDLES]      = g_strdup_printf ("Handles");
-  function_name[GTK_PAINT_HLINES]       = g_strdup_printf ("HLines");
-
-  function_name[GTK_PAINT_OPTIONS]      = g_strdup_printf ("Options");
-  function_name[GTK_PAINT_POLYGONS]     = g_strdup_printf ("Polygons");
-  function_name[GTK_PAINT_SHADOWS]      = g_strdup_printf ("Shadows");
-  function_name[GTK_PAINT_SHADOW_GAPS]  = g_strdup_printf ("Shadow gaps");
-  function_name[GTK_PAINT_SLIDERS]      = g_strdup_printf ("Sliders");
-  function_name[GTK_PAINT_TABS]         = g_strdup_printf ("Tabs");
-  function_name[GTK_PAINT_VLINES]       = g_strdup_printf ("VLines");
-  function_name[GTK_PAINT_EXPANDERS]    = g_strdup_printf ("Expanders");
-  function_name[GTK_PAINT_LAYOUTS]      = g_strdup_printf ("Layouts");
-  function_name[GTK_PAINT_RESIZE_GRIPS] = g_strdup_printf ("Resize grips");
-
   for (i = 0; i < N_GTK_PAINT_FUNCTIONS; i++) {
     function_checkboxes[i] = gtk_check_button_new_with_label (function_name[i]);
     if (i < 10)
@@ -382,7 +416,7 @@ main (int argc, char **argv) {
 
   /* The "Crash test" button */
   crash_test_button = gtk_button_new_with_mnemonic ("S_tart crash test");
-  g_signal_connect (crash_test_button, "clicked", G_CALLBACK (gtk_paint_functions_test), function_checkboxes);
+  g_signal_connect (crash_test_button, "clicked", G_CALLBACK (run_crash_test), function_checkboxes);
   gtk_box_pack_start (GTK_BOX (crash_test_main_vbox), crash_test_button, FALSE, FALSE, 10);
 
   /* Label */
@@ -402,5 +436,136 @@ main (int argc, char **argv) {
   }
   g_free (function_name);
 
+}
+
+int
+main (int argc, char **argv) {
+  gboolean torture_full = FALSE;
+  gboolean list_widgets = FALSE;
+  gchar *widgets_str = NULL;
+  gboolean crash_full = FALSE;
+  gchar *crash_str = NULL;
+  gboolean list_crash = FALSE;
+  GError *error = NULL;
+
+
+  GOptionEntry options[] = {
+    { "torture-full", 't', 0, G_OPTION_ARG_NONE, &torture_full, "Run full torture", NULL },
+    { "torture-widgets", 'w', 0, G_OPTION_ARG_STRING, &widgets_str, "Run torture over specified widgets", "GType coma separated list of widgets to torture" },
+    { "torture-level", 'x', 0, G_OPTION_ARG_INT, &torture_level, "Torture level", "[1-100]" },
+    { "list-torture-widgets", 'l', 0, G_OPTION_ARG_NONE, &list_widgets, "List supported widgets", NULL },
+    { "crash-full", 'c', 0, G_OPTION_ARG_NONE, &crash_full, "Run full crashes", NULL },
+    { "crash-functions", 'f', 0, G_OPTION_ARG_STRING, &crash_str, "Run crashes over specified functions", "coma separated list of functions to crash" },
+    { "list-crash-functions", 'z', 0, G_OPTION_ARG_NONE, &list_crash, "List supported crash functions", NULL },
+    { NULL }
+  };
+  GOptionContext *ctx;
+
+  g_set_application_name ("GTK+ Theme Torture Program");
+  ctx = g_option_context_new("GTK+ Theme Torture Program");
+  g_option_context_add_main_entries(ctx, options, "options");
+  g_option_context_parse(ctx, &argc, &argv, &error);
+  g_option_context_free(ctx);
+
+  if (error) {
+    g_print ("Error parsing command line arguments: %s\n", error->message);
+    g_error_free (error);
+    return 1;
+  }
+
+
+  gtk_init (&argc, &argv);
+
+  initialize_types ();
+
+  if (torture_level < 1 || torture_level > 100) {
+    g_print ("Torture level shuld be between 1 and 100\n");
+    return 1;
+  }
+
+  if (list_widgets) {
+    int i;
+    g_print ("List of supported widgets:\n");
+    for (i = 0; types[i] != 0; i++) {
+      g_print ("%s\n", g_type_name (types[i]));
+    }
+    return 0;
+  }
+
+
+  if (torture_full) {
+    full_torture ();
+    return 0;
+  }
+  if (widgets_str) {
+    int i,j;
+    gchar **widgets = g_strsplit (widgets_str, ",", 0);
+    for (i = 0; widgets[i];  i++) {
+      gboolean run = FALSE;
+      for (j = 0; types[j] != 0; j++) {
+        if (strcmp (widgets[i], g_type_name (types[j])) == 0) {
+          torture_widget (NULL, GINT_TO_POINTER (j));
+          run = TRUE;
+          break;
+        }
+      }
+      if (!run) {
+         g_print ("Widget %s not supported\n", widgets[i]);
+         g_strfreev(widgets);
+         return 1;
+      }
+    }
+    g_strfreev(widgets);
+    return 0;
+  }
+
+  initialize_functions ();
+
+  if (crash_full) {
+    run_all_crash_test ();
+    return 0;
+  }
+
+  if (crash_str) {
+    int i,j;
+    guint32 tests = 0;
+    gchar **functions = g_strsplit (crash_str, ",", 0);
+    for (i = 0; functions[i];  i++) {
+      gboolean run = FALSE;
+      for (j = 0; function_name[j] != 0; j++) {
+        if (strcmp (functions[i], function_name[j]) == 0) {
+          run = TRUE;
+          ACTIVE(tests,j);
+          break;
+        }
+      }
+      if (!run) {
+        g_print ("function %s not supported\n", functions[i]);
+        g_strfreev(functions);
+        return 1;
+      }
+    }
+    gtk_paint_functions_test (tests);
+
+    while (gtk_events_pending())
+      gtk_main_iteration();
+    
+    g_strfreev(functions);
+    return 0;
+  }
+
+  if (list_crash) {
+    int i;
+    g_print ("List of supported funtions:\n");
+    for (i = 0; function_name[i] != 0; i++) {
+      g_print ("%s\n", function_name[i]);
+    }
+    return 0;
+  }
+
+  create_main_window ();
+
   return 0;
 }
+  
+
diff --git a/gtk-theme-torturer/torturer.h b/gtk-theme-torturer/torturer.h
index 0aa2ba7..19b4484 100644
--- a/gtk-theme-torturer/torturer.h
+++ b/gtk-theme-torturer/torturer.h
@@ -22,3 +22,7 @@ enum {
   GTK_PAINT_RESIZE_GRIPS,
   N_GTK_PAINT_FUNCTIONS
 };
+
+#define ACTIVE(list,i) list |= 1<<i
+#define DEACTIVE(list,i) list ^= 1<<i
+#define TEST_IS_ACTIVE(list,i) list & 1<<i


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