[Spice-devel] [PATCH 2/4] add test for QXL parsing functions

Frediano Ziglio fziglio at redhat.com
Fri Jan 8 08:51:10 PST 2016


> 
> On Fri, Jan 08, 2016 at 12:11:43PM +0000, Frediano Ziglio wrote:
> > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> > Acked-by: Christophe Fergeau <cfergeau at redhat.com>
> > ---
> >  server/tests/Makefile.am   |  7 ++++
> >  server/tests/regression1.c | 87
> >  ++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 94 insertions(+)
> >  create mode 100644 server/tests/regression1.c
> > 
> > diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
> > index 94a4103..d7ce31b 100644
> > --- a/server/tests/Makefile.am
> > +++ b/server/tests/Makefile.am
> > @@ -48,6 +48,7 @@ noinst_PROGRAMS =				\
> >  
> >  TESTS =	\
> >  	stat_test				\
> > +	regression1				\
> >  	$(NULL)
> >  
> >  check_PROGRAMS = $(TESTS)
> > @@ -145,3 +146,9 @@ libstat_test3_a_CPPFLAGS = $(AM_CPPFLAGS)
> > -DTEST_COMPRESS_STAT=1 -DTEST_RED_WORK
> >  
> >  libstat_test4_a_SOURCES = stat-test.c
> >  libstat_test4_a_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_COMPRESS_STAT=1
> >  -DTEST_RED_WORKER_STAT=1 -DTEST_NAME=stat_test4
> > +
> > +regression1_SOURCES =           \
> > +	regression1.c           \
> > +	../red-parse-qxl.c      \
> > +	../memslot.c            \
> > +	$(NULL)
> > diff --git a/server/tests/regression1.c b/server/tests/regression1.c
> > new file mode 100644
> > index 0000000..3b01d3b
> > --- /dev/null
> > +++ b/server/tests/regression1.c
> > @@ -0,0 +1,87 @@
> > +/* Do some tests on memory parsing
> > + */
> > +
> > +#undef NDEBUG
> > +#include <string.h>
> > +#include <stdlib.h>
> > +#include <stdio.h>
> > +#include <strings.h>
> > +#include <assert.h>
> > +
> > +#include <spice/macros.h>
> > +#include "memslot.h"
> > +#include "red-parse-qxl.h"
> > +
> > +static int exit_code = EXIT_SUCCESS;
> > +static const char *test_name = NULL;
> > +
> > +static void
> > +failure(void)
> > +{
> > +    assert(test_name);
> > +    printf("Test %s FAILED!\n", test_name);
> > +    exit_code = EXIT_FAILURE;
> > +}
> > +
> > +static void
> > +test(const char *desc)
> > +{
> > +    test_name = desc;
> > +    printf("Starting test %s\n", desc);
> > +}
> > +
> > +static inline QXLPHYSICAL
> > +to_physical(const void *ptr)
> > +{
> > +    return (uintptr_t) ptr;
> > +}
> > +
> > +int main(int argc, char **argv)
> > +{
> > +    RedMemSlotInfo mem_info;
> > +    memslot_info_init(&mem_info, 1 /* groups */, 1 /* slots */, 1, 1, 0);
> > +    memslot_info_add_slot(&mem_info, 0, 0, 0 /* delta */, 0 /* start */,
> > ~0ul /* end */, 0 /* generation */);
> > +
> > +    RedSurfaceCmd cmd;
> > +    QXLSurfaceCmd qxl;
> > +
> > +    memset(&qxl, 0, sizeof(qxl));
> > +
> > +    qxl.surface_id = 123;
> > +
> > +    /* try create a surface with no issues, should succeed */
> 
> "try to create"
> 
> Still Acked-by: Christophe Fergeau <cfergeau at redhat.com>
> Note that these tests are not really related to the 2 commits in this
> series as the test does not seem to fail if these commits are reverted.

No, the test check some old problem which were merged as part of the
security work so everything not strictly related to fixing the issue
were not merged.

> Also, some name better than 'regression1' could be nice
> 'test-qxl-parsing' ?
> 
> Christophoe
> 

Sending another version with all changes.

Frediano


More information about the Spice-devel mailing list