tests: Convert test/xi1/ to single binary
Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Mihail Konev <k.mvc@ya.ru>
This commit is contained in:
parent
ff66bca3e8
commit
371576f64b
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
#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 */
|
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef TESTS_H
|
||||||
|
#define TESTS_H
|
||||||
|
|
||||||
|
int protocol_xchangedevicecontrol_test(void);
|
||||||
|
|
||||||
|
#endif /* TESTS_H */
|
|
@ -1 +1 @@
|
||||||
protocol-xchangedevicecontrol
|
tests
|
||||||
|
|
|
@ -1,27 +1,36 @@
|
||||||
if ENABLE_UNIT_TESTS
|
if ENABLE_UNIT_TESTS
|
||||||
if HAVE_LD_WRAP
|
if HAVE_LD_WRAP
|
||||||
noinst_PROGRAMS = \
|
noinst_PROGRAMS = tests
|
||||||
protocol-xchangedevicecontrol
|
|
||||||
|
TESTS = tests
|
||||||
|
|
||||||
TESTS=$(noinst_PROGRAMS)
|
|
||||||
TESTS_ENVIRONMENT = $(XORG_MALLOC_DEBUG_ENV)
|
TESTS_ENVIRONMENT = $(XORG_MALLOC_DEBUG_ENV)
|
||||||
|
|
||||||
AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
|
tests_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
|
||||||
AM_CPPFLAGS = @XORG_INCS@ -I$(srcdir)/../xi2
|
tests_CPPFLAGS = \
|
||||||
TEST_LDADD=../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
|
@XORG_INCS@ \
|
||||||
COMMON_SOURCES=$(srcdir)/../xi2/protocol-common.c
|
-I$(srcdir)/.. \
|
||||||
COMMON_LD_FLAGS = -Wl,-wrap,dixLookupWindow -Wl,-wrap,dixLookupClient
|
-I$(srcdir)/../xi2 \
|
||||||
|
$()
|
||||||
|
|
||||||
|
tests_LDFLAGS = \
|
||||||
|
-Wl,-wrap,dixLookupWindow \
|
||||||
|
-Wl,-wrap,dixLookupClient \
|
||||||
|
-Wl,-wrap,WriteToClient \
|
||||||
|
$()
|
||||||
|
|
||||||
|
tests_LDADD =../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
|
||||||
|
|
||||||
|
tests_SOURCES = \
|
||||||
|
$(srcdir)/../tests-common.c \
|
||||||
|
$(srcdir)/../xi2/protocol-common.c \
|
||||||
|
protocol-xchangedevicecontrol.c \
|
||||||
|
tests.c
|
||||||
|
|
||||||
if SPECIAL_DTRACE_OBJECTS
|
if SPECIAL_DTRACE_OBJECTS
|
||||||
TEST_LDADD += $(OS_LIB) $(DIX_LIB)
|
tests_LDADD += $(OS_LIB) $(DIX_LIB)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
protocol_xchangedevicecontrol_LDADD=$(TEST_LDADD)
|
|
||||||
|
|
||||||
protocol_xchangedevicecontrol_LDFLAGS=$(COMMON_LD_FLAGS) -Wl,-wrap,WriteToClient
|
|
||||||
|
|
||||||
protocol_xchangedevicecontrol_SOURCES=$(COMMON_SOURCES) protocol-xchangedevicecontrol.c
|
|
||||||
|
|
||||||
else
|
else
|
||||||
# Print that xi1-tests were skipped (exit code 77 for automake test harness)
|
# Print that xi1-tests were skipped (exit code 77 for automake test harness)
|
||||||
TESTS = xi1-tests
|
TESTS = xi1-tests
|
||||||
|
|
|
@ -113,7 +113,7 @@ test_ChangeDeviceControl(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
protocol_xchangedevicecontrol_test(void)
|
||||||
{
|
{
|
||||||
init_simple();
|
init_simple();
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -17,7 +17,10 @@ TESTS=$(noinst_PROGRAMS)
|
||||||
TESTS_ENVIRONMENT = $(XORG_MALLOC_DEBUG_ENV)
|
TESTS_ENVIRONMENT = $(XORG_MALLOC_DEBUG_ENV)
|
||||||
|
|
||||||
AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
|
AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
|
||||||
AM_CPPFLAGS = @XORG_INCS@
|
AM_CPPFLAGS = \
|
||||||
|
@XORG_INCS@ \
|
||||||
|
-I$(srcdir)/..
|
||||||
|
|
||||||
TEST_LDADD=../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
|
TEST_LDADD=../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
|
||||||
COMMON_SOURCES=protocol-common.h protocol-common.c
|
COMMON_SOURCES=protocol-common.h protocol-common.c
|
||||||
COMMON_LD_FLAGS= -Wl,-wrap,dixLookupWindow -Wl,-wrap,dixLookupClient
|
COMMON_LD_FLAGS= -Wl,-wrap,dixLookupWindow -Wl,-wrap,dixLookupClient
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include "exevents.h"
|
#include "exevents.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "tests.h"
|
||||||
|
|
||||||
#ifndef PROTOCOL_COMMON_H
|
#ifndef PROTOCOL_COMMON_H
|
||||||
#define PROTOCOL_COMMON_H
|
#define PROTOCOL_COMMON_H
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue