[PATCH rendercheck 3/5] Use ELF sections to make test setup easier.

Pekka Paalanen ppaalanen at gmail.com
Mon Apr 4 07:53:54 UTC 2016


On Sun, 03 Apr 2016 01:20:41 -0700
Jeremy Huddleston Sequoia <jeremyhu at apple.com> wrote:

> The use of __attribute(section()), __start_test_section, and
> __stop_test_section is not portable.  Could you please follow this up
> with a change that allows rendercheck to continue to function on
> non-ELF platforms as well? Preferably by just having alternate
> implementations of the DECLARE_RENDERCHECK_ARG_TEST and for_each_test
> macros.

FWIW, I'd also be interested to see how you can write an anternative
implementation without causing more "duplicate" code to have to be
written by hand for each test. Apart from a parser script collecting
entries from C file and generating the table, I haven't come up with
anything.

The reason I'm interested is that I've heard -flto breaking
Wayland/Weston test suites, which use the same section trick. Maybe
that could be fixed otherwise, but learning about portable solutions is
interesting.


Thanks,
pq

> > On Feb 1, 2016, at 13:48, Eric Anholt <eric at anholt.net> wrote:
> > 
> > Managing the group logic was really error-prone (forget to edit
> > success_mask when copy and pasting?  Forget to printf a description
> > of the group?).  Most new tests being written can be described as a
> > single call that does a couple subtests.
> > 
> > This doesn't convert all of the tests.  Some of the remaining ones
> > use "win" for presenting results (which we may want to just put in a
> > global?), and the rest use the pre-created pictures, which would
> > need some much bigger refactoring if we want to move their test
> > logic into their test files.
> > 
> > Signed-off-by: Eric Anholt <eric at anholt.net>
> > ---
> > main.c               | 47
> > ++++++++++++++++++++++++++++++++++-------------
> > rendercheck.h        | 51
> > ++++++++++++++++++++++++++++++++++++++++++++-------
> > t_gtk_argb_xbgr.c    | 17 ++++++++++++----- t_libreoffice_xrgb.c |
> > 18 ++++++++++++++++-- tests.c              | 37
> > ++++++++++++++----------------------- 5 files changed, 120
> > insertions(+), 50 deletions(-)
> > 

> > diff --git a/rendercheck.h b/rendercheck.h
> > index 2195cb4..f0fa7b7 100644
> > --- a/rendercheck.h
> > +++ b/rendercheck.h
> > @@ -64,6 +64,19 @@ struct op_info {
> > 	bool disabled;
> > };
> > 
> > +struct rendercheck_test_result {
> > +	int tests;
> > +	int passed;
> > +};
> > +
> > +static inline void
> > +record_result(struct rendercheck_test_result *result, bool success)
> > +{
> > +	result->tests++;
> > +	if (success)
> > +		result->passed++;
> > +}
> > +
> > #define TEST_FILL		0x0001
> > #define TEST_DSTCOORDS		0x0002
> > #define TEST_SRCCOORDS		0x0004
> > @@ -77,8 +90,27 @@ struct op_info {
> > #define TEST_REPEAT	  	0x0400
> > #define TEST_TRIANGLES  	0x0800
> > #define TEST_BUG7366		0x1000
> > -#define TEST_GTK_ARGB_XBGR	0x2000
> > -#define TEST_LIBREOFFICE_XRGB	0x4000
> > +#define TEST_gtk_argb_xbgr	0x2000
> > +#define TEST_libreoffice_xrgb	0x4000
> > +
> > +struct rendercheck_test {
> > +	int bit;
> > +	const char *arg_name;
> > +	const char *long_name;
> > +	struct rendercheck_test_result (*func)(Display *dpy);
> > +};
> > +
> > +#define DECLARE_RENDERCHECK_TEST(name)		  \
> > +	const struct rendercheck_test test_desc_##name \
> > +	__attribute__ ((section ("test_section")))
> > +
> > +#define DECLARE_RENDERCHECK_ARG_TEST(arg_name_, long_name_,
> > func_)		\
> > +	DECLARE_RENDERCHECK_TEST(arg_name_) =
> > {				\
> > +		.bit =
> > TEST_##arg_name_,				\
> > +		.arg_name =
> > #arg_name_,					\
> > +		.long_name =
> > long_name_,				\
> > +		.func =
> > func_,						\
> > +	}
> > 
> > struct render_format {
> > 	XRenderPictFormat *format;
> > @@ -88,6 +120,12 @@ struct render_format {
> > extern struct render_format *formats;
> > extern int nformats;
> > 
> > +/* Storage that will point at the start and end of the ELF section
> > for test
> > + * structs.  These are automatically set up by the linker when
> > placing things
> > + * in their sections.
> > + */
> > +extern struct rendercheck_test __start_test_section,
> > __stop_test_section; +
> > extern int pixmap_move_iter;
> > extern int win_width, win_height;
> > extern struct op_info ops[];
> > @@ -226,8 +264,7 @@ trifan_test(Display *dpy, picture_info *win,
> > picture_info *dst, int op, bool
> > bug7366_test(Display *dpy);
> > 
> > -bool
> > -gtk_argb_xbgr_test(Display *dpy);
> > -
> > -bool
> > -libreoffice_xrgb_test(Display *dpy, bool invert);
> > +#define
> > for_each_test(test)						\
> > +	for (struct rendercheck_test *test =
> > &__start_test_section;	\
> > +	     test <
> > &__stop_test_section;				\
> > +	     test++)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <https://lists.x.org/archives/xorg-devel/attachments/20160404/d1f7ce67/attachment.sig>


More information about the xorg-devel mailing list