[PATCH xserver 2/6] tests: Convert test/xi1/ to single binary

Peter Hutterer peter.hutterer at who-t.net
Mon Jan 9 03:20:38 UTC 2017


On Wed, Jan 04, 2017 at 11:31:40AM +0500, Mihail Konev wrote:
> Part of refactoring the tests into a single binary,
> to make partial rebuild slightly faster and less verbose.
> 
> Signed-off-by: Mihail Konev <k.mvc at ya.ru>

protocol-common.h:33:19: fatal error: tests.h: No such file or directory

hint:
  git rebase -i origin/master --exec make 

to run make on all commits to avoid this situation. Or write a little script
that calls make && make check and use that as argument to --exec.

quick skim shows that you're missing the  updated CFLAGS/CPPFLAGS in the
xi2/Makefile.am

Also, when you're sending out updated versions, please give a quick summary
of what changed since the previous version, it makes reviews a lot easier.

Cheers,
   Peter


> ---
>  test/tests-common.c                      | 33 ++++++++++++++++++++++++++++
>  test/tests-common.h                      |  9 ++++++++
>  test/tests.h                             |  7 ++++++
>  test/xi1/.gitignore                      |  2 +-
>  test/xi1/Makefile.am                     | 37 ++++++++++++++++++++------------
>  test/xi1/protocol-xchangedevicecontrol.c |  2 +-
>  test/xi1/tests.c                         | 11 ++++++++++
>  test/xi2/protocol-common.h               |  2 ++
>  8 files changed, 87 insertions(+), 16 deletions(-)
>  create mode 100644 test/tests-common.c
>  create mode 100644 test/tests-common.h
>  create mode 100644 test/tests.h
>  create mode 100644 test/xi1/tests.c
> 
> diff --git a/test/tests-common.c b/test/tests-common.c
> new file mode 100644
> index 000000000000..686852827765
> --- /dev/null
> +++ b/test/tests-common.c
> @@ -0,0 +1,33 @@
> +#include <sys/types.h>
> +#include <sys/wait.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +
> +#include "tests-common.h"
> +
> +void
> +run_test_in_child(int (*func)(void), const char *funcname)
> +{
> +    int cpid;
> +    int csts;
> +    int exit_code = -1;
> +
> +    printf("\n---------------------\n%s...\n", funcname);
> +    cpid = fork();
> +    if (cpid) {
> +        waitpid(cpid, &csts, 0);
> +        if (!WIFEXITED(csts))
> +            goto child_failed;
> +        exit_code = WEXITSTATUS(csts);
> +        if (exit_code == 0)
> +            printf(" Pass\n");
> +        else {
> +child_failed:
> +            printf(" FAIL\n");
> +            exit(exit_code);
> +        }
> +    } else {
> +        exit(func());
> +    }
> +}
> diff --git a/test/tests-common.h b/test/tests-common.h
> new file mode 100644
> index 000000000000..b02f746f6f56
> --- /dev/null
> +++ b/test/tests-common.h
> @@ -0,0 +1,9 @@
> +#ifndef TESTS_COMMON_H
> +#define TESTS_COMMON_H
> +
> +#define run_test(func) run_test_in_child(func, #func)
> +
> +void run_test_in_child(int (*func)(void), const char *funcname);
> +
> +#endif /* TESTS_COMMON_H */
> +
> diff --git a/test/tests.h b/test/tests.h
> new file mode 100644
> index 000000000000..8a42aa0da592
> --- /dev/null
> +++ b/test/tests.h
> @@ -0,0 +1,7 @@
> +#ifndef TESTS_H
> +#define TESTS_H
> +
> +int protocol_xchangedevicecontrol_test(void);
> +
> +#endif /* TESTS_H */
> +
> diff --git a/test/xi1/.gitignore b/test/xi1/.gitignore
> index c1b9024ee958..2b29f27645f8 100644
> --- a/test/xi1/.gitignore
> +++ b/test/xi1/.gitignore
> @@ -1 +1 @@
> -protocol-xchangedevicecontrol
> +tests
> diff --git a/test/xi1/Makefile.am b/test/xi1/Makefile.am
> index 813241c0aeed..7a054dd80966 100644
> --- a/test/xi1/Makefile.am
> +++ b/test/xi1/Makefile.am
> @@ -1,26 +1,35 @@
>  if ENABLE_UNIT_TESTS
>  if HAVE_LD_WRAP
> -noinst_PROGRAMS =  \
> -	protocol-xchangedevicecontrol
> +noinst_PROGRAMS = tests
> +
> +TESTS = tests
>  
> -TESTS=$(noinst_PROGRAMS)
>  TESTS_ENVIRONMENT = $(XORG_MALLOC_DEBUG_ENV)
>  
> -AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
> -AM_CPPFLAGS = @XORG_INCS@ -I$(srcdir)/../xi2
> -TEST_LDADD=../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
> -COMMON_SOURCES=$(srcdir)/../xi2/protocol-common.c
> -COMMON_LDFLAGS= -Wl,-wrap,dixLookupWindow -Wl,-wrap,dixLookupClient
> +tests_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
> +tests_CPPFLAGS = \
> +	@XORG_INCS@ \
> +	-I$(srcdir)/.. \
> +	-I$(srcdir)/../xi2 \
> +	$()
>  
> -if SPECIAL_DTRACE_OBJECTS
> -TEST_LDADD += $(OS_LIB) $(DIX_LIB)
> -endif
> +tests_LDFLAGS = \
> +	-Wl,-wrap,dixLookupWindow \
> +	-Wl,-wrap,dixLookupClient \
> +	-Wl,-wrap,WriteToClient \
> +	$()
>  
> -protocol_xchangedevicecontrol_LDADD=$(TEST_LDADD)
> +tests_LDADD =../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
>  
> -protocol_xchangedevicecontrol_LDFLAGS=$(COMMON_LDFLAGS) -Wl,-wrap,WriteToClient
> +tests_SOURCES = \
> +	$(srcdir)/../tests-common.c \
> +	$(srcdir)/../xi2/protocol-common.c \
> +	protocol-xchangedevicecontrol.c \
> +	tests.c
>  
> -protocol_xchangedevicecontrol_SOURCES=$(COMMON_SOURCES) protocol-xchangedevicecontrol.c
> +if SPECIAL_DTRACE_OBJECTS
> +tests_LDADD += $(OS_LIB) $(DIX_LIB)
> +endif
>  
>  else
>  # Print that xi1-tests were skipped (exit code 77 for automake test harness)
> diff --git a/test/xi1/protocol-xchangedevicecontrol.c b/test/xi1/protocol-xchangedevicecontrol.c
> index 64d2ca29bb95..57a15c4076f5 100644
> --- a/test/xi1/protocol-xchangedevicecontrol.c
> +++ b/test/xi1/protocol-xchangedevicecontrol.c
> @@ -113,7 +113,7 @@ test_ChangeDeviceControl(void)
>  }
>  
>  int
> -main(int argc, char **argv)
> +protocol_xchangedevicecontrol_test(void)
>  {
>      init_simple();
>  
> diff --git a/test/xi1/tests.c b/test/xi1/tests.c
> new file mode 100644
> index 000000000000..df4638dc98ab
> --- /dev/null
> +++ b/test/xi1/tests.c
> @@ -0,0 +1,11 @@
> +#include <string.h>
> +#include "tests.h"
> +#include "tests-common.h"
> +
> +int
> +main(int argc, char **argv)
> +{
> +    run_test(protocol_xchangedevicecontrol_test);
> +
> +    return 0;
> +}
> diff --git a/test/xi2/protocol-common.h b/test/xi2/protocol-common.h
> index f8504787f790..7190ef0ddb22 100644
> --- a/test/xi2/protocol-common.h
> +++ b/test/xi2/protocol-common.h
> @@ -30,6 +30,8 @@
>  #include "exevents.h"
>  #include <assert.h>
>  
> +#include "tests.h"
> +
>  #ifndef PROTOCOL_COMMON_H
>  #define PROTOCOL_COMMON_H
>  
> -- 
> 2.9.2
> 


More information about the xorg-devel mailing list