[cairo] [PATCH 2/3] test: improve selective execution of Cairo tests based on FORMAT option

Bryce Harrington bryce at osg.samsung.com
Thu Aug 14 16:16:04 PDT 2014


On Tue, Aug 05, 2014 at 04:25:57PM -0700, Bryce Harrington wrote:
> On Tue, Aug 05, 2014 at 02:31:37PM +0530, Ravi Nanjundappa wrote:
> > This patch improves the patch "test: Selective execution of Cairo tests based on FORMAT option"
> > by extending the usage of FORMAT option even in the case of user not
> > providing TARGETS= option
> > 
> > For ex:
> > (1). CAIRO_TESTS="zero-alpha" make test FORMAT=rgba
> > This command runs the zero-alpha test for all the backends with
> > argb32 content format and so on.
> > (2). CAIRO_TESTS="zero-alpha" make test FORMAT=rgba,rgb
> > This command runs the zero-alpha test for all the backends with
> > argb32 and rgb24 content formats.
> > 
> > Signed-off-by: Ravi Nanjundappa <nravi.n at samsung.com>
> 
> Reviewed-by: Bryce Harrington <b.harrington at samsung.com>
> 
> While I don't see any obvious faults in the logic here, it feels like
> there's a bit more code than necessary.  But I know this is being
> modeled after existing code so probably best for this patch to just
> follow suit.  However, would be nice to have a follow up patch that
> factors out common code chunks into a helper function or two to condense
> the code a bit.

I still have a suspicion a function might condense some redundant code
here and make the logic a bit easier to follow, but don't see anything
obvious to be done, so am merging it as is (modulo a few whitespace
fixups).

Bryce
 
> > ---
> >  boilerplate/cairo-boilerplate.c |   68 +++++++++++++++++++++++++++++++--------
> >  1 file changed, 55 insertions(+), 13 deletions(-)
> > 
> > diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
> > index 29b3a12..ef44629 100644
> > --- a/boilerplate/cairo-boilerplate.c
> > +++ b/boilerplate/cairo-boilerplate.c
> > @@ -683,20 +683,62 @@ cairo_boilerplate_get_targets (int	    *pnum_targets,
> >  	    tname = end;
> >  	}
> >      } else {
> > -	/* check all compiled in targets */
> > -	num_targets = 0;
> > -	for (list = cairo_boilerplate_targets; list != NULL; list = list->next)
> > -	    num_targets++;
> > +	    int found = 0;
> > +	    int not_found_targets = 0;
> > +	    num_targets = 0;
> > +	    targets_to_test = xmalloc (sizeof(cairo_boilerplate_target_t*) * num_targets);
> > +	    for (list = cairo_boilerplate_targets; list != NULL; list = list->next)
> > +	    {
> > +		    const cairo_boilerplate_target_t *target = list->target;
> > +		    const char *tcontent_name;
> > +		    const char *tcontent_end;
> > +		    if ((tcontent_name = getenv ("CAIRO_TEST_TARGET_FORMAT")) != NULL && *tcontent_name) {
> > +			    while(tcontent_name) {
> > +				    tcontent_end = strpbrk (tcontent_name, " \t\r\n;:,");
> > +				    if (tcontent_end == tcontent_name) {
> > +					    tcontent_name = tcontent_end + 1;
> > +					    continue;
> > +				    }
> > +				    if(_cairo_boilerplate_target_format_matches_name (target,
> > +							    tcontent_name, tcontent_end)) {
> > +					    /* realloc isn't exactly the best thing here, but meh. */
> > +					    targets_to_test = xrealloc (targets_to_test, 
> > +							    sizeof(cairo_boilerplate_target_t *) * (num_targets+1));
> > +					    targets_to_test[num_targets++] = target;
> > +					    found =1;
> > +				    }
> > +				    else 
> > +				    {
> > +					    not_found_targets++;
> > +				    }		
> > +
> > +				    if (tcontent_end)
> > +					    tcontent_end++;
> > +
> > +				    tcontent_name = tcontent_end;
> > +			    }
> > +		    }
> > +		    else 
> > +		    {
> > +			    num_targets++;
> > +		    }
> > +	    }
> > +	    if(!found) 
> > +	    {
> > +		    /* check all compiled in targets */
> > +		    num_targets = num_targets + not_found_targets;
> > +		    targets_to_test = xrealloc (targets_to_test,
> > +				    sizeof(cairo_boilerplate_target_t*) * num_targets);
> > +		    num_targets = 0;
> > +		    for (list = cairo_boilerplate_targets;
> > +				    list != NULL;
> > +				    list = list->next)
> > +		    {
> > +			    const cairo_boilerplate_target_t *target = list->target;
> > +			    targets_to_test[num_targets++] = target;
> > +		    }
> > +	    }
> >  
> > -	targets_to_test = xmalloc (sizeof(cairo_boilerplate_target_t*) * num_targets);
> > -	num_targets = 0;
> > -	for (list = cairo_boilerplate_targets;
> > -	     list != NULL;
> > -	     list = list->next)
> > -	{
> > -	    const cairo_boilerplate_target_t *target = list->target;
> > -	    targets_to_test[num_targets++] = target;
> > -	}
> >      }
> >  
> >      /* exclude targets as specified by the user */
> > -- 
> > 1.7.9.5
> > 
> > -- 
> > cairo mailing list
> > cairo at cairographics.org
> > http://lists.cairographics.org/mailman/listinfo/cairo
> -- 
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo


More information about the cairo mailing list