tests: Convert test/ to single binary

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Mihail Konev <k.mvc@ya.ru>
This commit is contained in:
Mihail Konev 2017-01-12 13:21:10 +05:00 committed by Adam Jackson
parent 773fc07e4c
commit ead5064581
16 changed files with 98 additions and 47 deletions

12
test/.gitignore vendored
View File

@ -1,16 +1,6 @@
fixes tests
hashtabletest
input
list
misc
os os
sdksyms.c sdksyms.c
string
touch
xfree86
xkb
xtest
signal-logging
piglit-results piglit-results
simple-xinit simple-xinit
*.log *.log

View File

@ -1,21 +1,20 @@
if ENABLE_UNIT_TESTS if ENABLE_UNIT_TESTS
SUBDIRS= . SUBDIRS= .
TEST_PROGS = list string AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
AM_CPPFLAGS = $(XORG_INCS)
if XORG if XORG
# Tests that require at least some DDX functions in order to fully link # Tests that require at least some DDX functions in order to fully link
# For now, requires xf86 ddx, could be adjusted to use another # For now, requires xf86 ddx, could be adjusted to use another
SUBDIRS += xi1 xi2 SUBDIRS += xi1 xi2
TEST_PROGS += xkb input xtest misc fixes xfree86 signal-logging touch
if RES if RES
TEST_PROGS += hashtabletest RES_SRCS = hashtabletest.c
AM_CPPFLAGS += -DRES_TESTS
endif endif
endif endif
check_LTLIBRARIES = libxservertest.la check_LTLIBRARIES = libxservertest.la
noinst_PROGRAMS = \ noinst_PROGRAMS = simple-xinit tests
simple-xinit \
$(TEST_PROGS) \
$(NULL)
if XVFB if XVFB
XVFB_TESTS = scripts/xvfb-piglit.sh XVFB_TESTS = scripts/xvfb-piglit.sh
@ -31,8 +30,7 @@ SCRIPT_TESTS = \
$(XEPHYR_GLAMOR_TESTS) \ $(XEPHYR_GLAMOR_TESTS) \
$(NULL) $(NULL)
TESTS = \ TESTS = tests \
$(TEST_PROGS) \
$(SCRIPT_TESTS) \ $(SCRIPT_TESTS) \
$(NULL) $(NULL)
@ -42,8 +40,6 @@ TESTS_ENVIRONMENT = \
$(XORG_MALLOC_DEBUG_ENV) \ $(XORG_MALLOC_DEBUG_ENV) \
$(NULL) $(NULL)
AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
AM_CPPFLAGS = $(XORG_INCS)
if XORG if XORG
AM_CPPFLAGS += -I$(top_srcdir)/hw/xfree86/parser \ AM_CPPFLAGS += -I$(top_srcdir)/hw/xfree86/parser \
-I$(top_srcdir)/hw/xfree86/ddc \ -I$(top_srcdir)/hw/xfree86/ddc \
@ -51,23 +47,26 @@ AM_CPPFLAGS += -I$(top_srcdir)/hw/xfree86/parser \
-I$(top_srcdir)/hw/xfree86/ramdac -I$(top_srcdir)/hw/xfree86/dri \ -I$(top_srcdir)/hw/xfree86/ramdac -I$(top_srcdir)/hw/xfree86/dri \
-I$(top_srcdir)/hw/xfree86/dri2 -I$(top_srcdir)/dri3 -I$(top_srcdir)/hw/xfree86/dri2 -I$(top_srcdir)/dri3
endif endif
TEST_LDADD=libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS) tests_LDADD = libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
if SPECIAL_DTRACE_OBJECTS if SPECIAL_DTRACE_OBJECTS
TEST_LDADD += $(OS_LIB) $(DIX_LIB) tests_LDADD += $(OS_LIB) $(DIX_LIB)
endif endif
xkb_SOURCES = test_xkb.c tests_SOURCES = \
tests-common.c \
xkb_LDADD=$(TEST_LDADD) fixes.c \
input_LDADD=$(TEST_LDADD) input.c \
xtest_LDADD=$(TEST_LDADD) list.c \
misc_LDADD=$(TEST_LDADD) misc.c \
fixes_LDADD=$(TEST_LDADD) signal-logging.c \
xfree86_LDADD=$(TEST_LDADD) string.c \
touch_LDADD=$(TEST_LDADD) touch.c \
signal_logging_LDADD=$(TEST_LDADD) xfree86.c \
hashtabletest_LDADD=$(TEST_LDADD) test_xkb.c \
xtest.c \
$(RES_SRCS) \
tests.c
libxservertest_la_LIBADD = $(XSERVER_LIBS) libxservertest_la_LIBADD = $(XSERVER_LIBS)
if XORG if XORG
@ -151,7 +150,7 @@ endif
if XQUARTZ if XQUARTZ
libxservertest_la_LIBADD += \ libxservertest_la_LIBADD += \
$(top_builddir)/miext/rootless/librootless.la $(top_builddir)/miext/rootless/librootless.la
TEST_LDADD += -lXplugin tests_LDADD += -lXplugin
endif endif
if XWIN_MULTIWINDOWEXTWM if XWIN_MULTIWINDOWEXTWM

View File

@ -31,6 +31,8 @@
#include <xfixesint.h> #include <xfixesint.h>
#include <X11/extensions/xfixeswire.h> #include <X11/extensions/xfixeswire.h>
#include "tests-common.h"
static void static void
_fixes_test_direction(struct PointerBarrier *barrier, int d[4], int permitted) _fixes_test_direction(struct PointerBarrier *barrier, int d[4], int permitted)
{ {
@ -343,7 +345,7 @@ fixes_pointer_barrier_clamp_test(void)
} }
int int
main(int argc, char **argv) fixes_test(void)
{ {
fixes_pointer_barriers_test(); fixes_pointer_barriers_test();

View File

@ -8,6 +8,8 @@
#include "hashtable.h" #include "hashtable.h"
#include "resource.h" #include "resource.h"
#include "tests-common.h"
static void static void
print_xid(void* ptr, void* v) print_xid(void* ptr, void* v)
{ {
@ -154,7 +156,7 @@ test3(void)
} }
int int
main(void) hashtabletest_test(void)
{ {
int ok = test1(); int ok = test1();
ok = ok && test2(); ok = ok && test2();

View File

@ -43,6 +43,8 @@
#include "mi.h" #include "mi.h"
#include "assert.h" #include "assert.h"
#include "tests-common.h"
/** /**
* Init a device with axes. * Init a device with axes.
* Verify values set on the device. * Verify values set on the device.
@ -1904,7 +1906,7 @@ dix_enqueue_events(void)
} }
int int
main(int argc, char **argv) input_test(void)
{ {
dix_enqueue_events(); dix_enqueue_events();
dix_double_fp_conversion(); dix_double_fp_conversion();

View File

@ -31,6 +31,8 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include "tests-common.h"
struct parent { struct parent {
int a; int a;
struct xorg_list children; struct xorg_list children;
@ -369,7 +371,7 @@ test_nt_list_delete(void)
} }
int int
main(int argc, char **argv) list_test(void)
{ {
test_xorg_list_init(); test_xorg_list_init();
test_xorg_list_add(); test_xorg_list_add();

View File

@ -31,6 +31,8 @@
#include "dix.h" #include "dix.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "tests-common.h"
ScreenInfo screenInfo; ScreenInfo screenInfo;
static void static void
@ -192,7 +194,7 @@ dix_request_size_checks(void)
int int
main(int argc, char **argv) misc_test(void)
{ {
dix_version_compare(); dix_version_compare();
dix_update_desktop_dimensions(); dix_update_desktop_dimensions();

View File

@ -30,6 +30,8 @@
#include "assert.h" #include "assert.h"
#include "misc.h" #include "misc.h"
#include "tests-common.h"
struct number_format_test { struct number_format_test {
uint64_t number; uint64_t number;
char string[21]; char string[21];
@ -395,7 +397,7 @@ static void logging_format(void)
#pragma GCC diagnostic pop /* "-Wformat-security" */ #pragma GCC diagnostic pop /* "-Wformat-security" */
int int
main(int argc, char **argv) signal_logging_test(void)
{ {
number_formatting(); number_formatting();
logging_format(); logging_format();

View File

@ -32,6 +32,7 @@
#include <assert.h> #include <assert.h>
#include "os.h" #include "os.h"
#include "tests-common.h"
/* Ensure we're testing our functions, even on platforms with libc versions */ /* Ensure we're testing our functions, even on platforms with libc versions */
#include <string.h> #include <string.h>
@ -62,7 +63,7 @@ strndup_checks(void)
} }
int int
main(int argc, char **argv) string_test(void)
{ {
strndup_checks(); strndup_checks();

View File

@ -48,6 +48,8 @@
#include "../xkb/xkb.h" #include "../xkb/xkb.h"
#include <assert.h> #include <assert.h>
#include "tests-common.h"
/** /**
* Initialize an empty XkbRMLVOSet. * Initialize an empty XkbRMLVOSet.
* Call XkbGetRulesDflts to obtain the default ruleset. * Call XkbGetRulesDflts to obtain the default ruleset.
@ -164,7 +166,7 @@ xkb_set_get_rules_test(void)
} }
int int
main(int argc, char **argv) xkb_test(void)
{ {
xkb_set_get_rules_test(); xkb_set_get_rules_test();
xkb_get_rules_test(); xkb_get_rules_test();

View File

@ -1,6 +1,8 @@
#ifndef TESTS_COMMON_H #ifndef TESTS_COMMON_H
#define TESTS_COMMON_H #define TESTS_COMMON_H
#include "tests.h"
#define run_test(func) run_test_in_child(func, #func) #define run_test(func) run_test_in_child(func, #func)
void run_test_in_child(int (*func)(void), const char *funcname); void run_test_in_child(int (*func)(void), const char *funcname);

25
test/tests.c Normal file
View File

@ -0,0 +1,25 @@
#include <string.h>
#include "tests.h"
#include "tests-common.h"
int
main(int argc, char **argv)
{
run_test(fixes_test);
#ifdef RES_TESTS
run_test(hashtabletest_test);
#endif
run_test(input_test);
run_test(list_test);
run_test(misc_test);
run_test(signal_logging_test);
run_test(string_test);
run_test(touch_test);
run_test(xfree86_test);
run_test(xkb_test);
run_test(xtest_test);
return 0;
}

View File

@ -1,6 +1,18 @@
#ifndef TESTS_H #ifndef TESTS_H
#define TESTS_H #define TESTS_H
int fixes_test(void);
int hashtabletest_test(void);
int input_test(void);
int list_test(void);
int misc_test(void);
int signal_logging_test(void);
int string_test(void);
int touch_test(void);
int xfree86_test(void);
int xkb_test(void);
int xtest_test(void);
int protocol_xchangedevicecontrol_test(void); int protocol_xchangedevicecontrol_test(void);
int protocol_xiqueryversion_test(void); int protocol_xiqueryversion_test(void);

View File

@ -30,6 +30,8 @@
#include "assert.h" #include "assert.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "tests-common.h"
static void static void
touch_grow_queue(void) touch_grow_queue(void)
{ {
@ -278,13 +280,15 @@ touch_init(void)
} }
int int
main(int argc, char **argv) touch_test(void)
{ {
printf("touch_test: start...\n");
touch_grow_queue(); touch_grow_queue();
touch_find_ddxid(); touch_find_ddxid();
touch_begin_ddxtouch(); touch_begin_ddxtouch();
touch_init(); touch_init();
touch_begin_touch(); touch_begin_touch();
printf("touch_test: exiting successfully\n");
return 0; return 0;
} }

View File

@ -30,6 +30,8 @@
#include "xf86.h" #include "xf86.h"
#include "xf86Parser.h" #include "xf86Parser.h"
#include "tests-common.h"
static void static void
xfree86_option_list_duplicate(void) xfree86_option_list_duplicate(void)
{ {
@ -96,7 +98,7 @@ xfree86_add_comment(void)
} }
int int
main(int argc, char **argv) xfree86_test(void)
{ {
xfree86_option_list_duplicate(); xfree86_option_list_duplicate();
xfree86_add_comment(); xfree86_add_comment();

View File

@ -35,6 +35,8 @@
#include "xserver-properties.h" #include "xserver-properties.h"
#include "syncsrv.h" #include "syncsrv.h"
#include "tests-common.h"
/** /**
*/ */
@ -123,7 +125,7 @@ xtest_properties(void)
} }
int int
main(int argc, char **argv) xtest_test(void)
{ {
xtest_init_devices(); xtest_init_devices();
xtest_properties(); xtest_properties();