[PATCH v4 xserver 4/6] tests: Convert test/ to single binary
Mihail Konev
k.mvc at ya.ru
Thu Jan 12 08:21:10 UTC 2017
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>
---
test/.gitignore | 12 +-----------
test/Makefile.am | 51 ++++++++++++++++++++++++++-------------------------
test/fixes.c | 4 +++-
test/hashtabletest.c | 4 +++-
test/input.c | 4 +++-
test/list.c | 4 +++-
test/misc.c | 4 +++-
test/signal-logging.c | 4 +++-
test/string.c | 3 ++-
test/tests-common.h | 2 ++
test/tests.c | 25 +++++++++++++++++++++++++
test/tests.h | 12 ++++++++++++
test/touch.c | 6 +++++-
test/xfree86.c | 4 +++-
test/xkb.c | 4 +++-
test/xtest.c | 4 +++-
16 files changed, 100 insertions(+), 47 deletions(-)
create mode 100644 test/tests.c
diff --git a/test/.gitignore b/test/.gitignore
index 47f766c5f620..5fd66e3f4ec7 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -1,16 +1,6 @@
-fixes
-hashtabletest
-input
-list
-misc
+tests
os
sdksyms.c
-string
-touch
-xfree86
-xkb
-xtest
-signal-logging
piglit-results
simple-xinit
*.log
diff --git a/test/Makefile.am b/test/Makefile.am
index 064e1c5b736f..8fdf08c3db96 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,21 +1,20 @@
if ENABLE_UNIT_TESTS
SUBDIRS= .
-TEST_PROGS = list string
+AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
+AM_CPPFLAGS = $(XORG_INCS)
+
if XORG
# Tests that require at least some DDX functions in order to fully link
# For now, requires xf86 ddx, could be adjusted to use another
SUBDIRS += xi1 xi2
-TEST_PROGS += xkb input xtest misc fixes xfree86 signal-logging touch
if RES
-TEST_PROGS += hashtabletest
+RES_SRCS = hashtabletest.c
+AM_CPPFLAGS += -DRES_TESTS
endif
endif
check_LTLIBRARIES = libxservertest.la
-noinst_PROGRAMS = \
- simple-xinit \
- $(TEST_PROGS) \
- $(NULL)
+noinst_PROGRAMS = simple-xinit tests
if XVFB
XVFB_TESTS = scripts/xvfb-piglit.sh
@@ -31,8 +30,7 @@ SCRIPT_TESTS = \
$(XEPHYR_GLAMOR_TESTS) \
$(NULL)
-TESTS = \
- $(TEST_PROGS) \
+TESTS = tests \
$(SCRIPT_TESTS) \
$(NULL)
@@ -42,8 +40,6 @@ TESTS_ENVIRONMENT = \
$(XORG_MALLOC_DEBUG_ENV) \
$(NULL)
-AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
-AM_CPPFLAGS = $(XORG_INCS)
if XORG
AM_CPPFLAGS += -I$(top_srcdir)/hw/xfree86/parser \
-I$(top_srcdir)/hw/xfree86/ddc \
@@ -51,21 +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/dri2 -I$(top_srcdir)/dri3
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
-TEST_LDADD += $(OS_LIB) $(DIX_LIB)
-endif
-
-xkb_LDADD=$(TEST_LDADD)
-input_LDADD=$(TEST_LDADD)
-xtest_LDADD=$(TEST_LDADD)
-misc_LDADD=$(TEST_LDADD)
-fixes_LDADD=$(TEST_LDADD)
-xfree86_LDADD=$(TEST_LDADD)
-touch_LDADD=$(TEST_LDADD)
-signal_logging_LDADD=$(TEST_LDADD)
-hashtabletest_LDADD=$(TEST_LDADD)
+tests_LDADD += $(OS_LIB) $(DIX_LIB)
+endif
+
+tests_SOURCES = \
+ tests-common.c \
+ fixes.c \
+ input.c \
+ list.c \
+ misc.c \
+ signal-logging.c \
+ string.c \
+ touch.c \
+ xfree86.c \
+ xkb.c \
+ xtest.c \
+ $(RES_SRCS) \
+ tests.c
libxservertest_la_LIBADD = $(XSERVER_LIBS)
if XORG
@@ -153,7 +154,7 @@ endif
if XQUARTZ
libxservertest_la_LIBADD += \
$(top_builddir)/miext/rootless/librootless.la
-TEST_LDADD += -lXplugin
+tests_LDADD += -lXplugin
endif
if XWIN_MULTIWINDOWEXTWM
diff --git a/test/fixes.c b/test/fixes.c
index 4ac6750e4179..573d948dc0e0 100644
--- a/test/fixes.c
+++ b/test/fixes.c
@@ -31,6 +31,8 @@
#include <xfixesint.h>
#include <X11/extensions/xfixeswire.h>
+#include "tests-common.h"
+
static void
_fixes_test_direction(struct PointerBarrier *barrier, int d[4], int permitted)
{
@@ -343,7 +345,7 @@ fixes_pointer_barrier_clamp_test(void)
}
int
-main(int argc, char **argv)
+fixes_test(void)
{
fixes_pointer_barriers_test();
diff --git a/test/hashtabletest.c b/test/hashtabletest.c
index 86a0c58c6bb0..0387587cb5d1 100644
--- a/test/hashtabletest.c
+++ b/test/hashtabletest.c
@@ -8,6 +8,8 @@
#include "hashtable.h"
#include "resource.h"
+#include "tests-common.h"
+
static void
print_xid(void* ptr, void* v)
{
@@ -154,7 +156,7 @@ test3(void)
}
int
-main(void)
+hashtabletest_test(void)
{
int ok = test1();
ok = ok && test2();
diff --git a/test/input.c b/test/input.c
index 91ee43c46ad9..4cd39bb48073 100644
--- a/test/input.c
+++ b/test/input.c
@@ -43,6 +43,8 @@
#include "mi.h"
#include "assert.h"
+#include "tests-common.h"
+
/**
* Init a device with axes.
* Verify values set on the device.
@@ -1904,7 +1906,7 @@ dix_enqueue_events(void)
}
int
-main(int argc, char **argv)
+input_test(void)
{
dix_enqueue_events();
dix_double_fp_conversion();
diff --git a/test/list.c b/test/list.c
index 28d9609eff5a..d710f46931a5 100644
--- a/test/list.c
+++ b/test/list.c
@@ -31,6 +31,8 @@
#include <assert.h>
#include <stdlib.h>
+#include "tests-common.h"
+
struct parent {
int a;
struct xorg_list children;
@@ -369,7 +371,7 @@ test_nt_list_delete(void)
}
int
-main(int argc, char **argv)
+list_test(void)
{
test_xorg_list_init();
test_xorg_list_add();
diff --git a/test/misc.c b/test/misc.c
index 66330a140614..ae46ccccbab9 100644
--- a/test/misc.c
+++ b/test/misc.c
@@ -31,6 +31,8 @@
#include "dix.h"
#include "dixstruct.h"
+#include "tests-common.h"
+
ScreenInfo screenInfo;
static void
@@ -192,7 +194,7 @@ dix_request_size_checks(void)
int
-main(int argc, char **argv)
+misc_test(void)
{
dix_version_compare();
dix_update_desktop_dimensions();
diff --git a/test/signal-logging.c b/test/signal-logging.c
index 3d2d04801c88..b00ee588ead9 100644
--- a/test/signal-logging.c
+++ b/test/signal-logging.c
@@ -30,6 +30,8 @@
#include "assert.h"
#include "misc.h"
+#include "tests-common.h"
+
struct number_format_test {
uint64_t number;
char string[21];
@@ -395,7 +397,7 @@ static void logging_format(void)
#pragma GCC diagnostic pop /* "-Wformat-security" */
int
-main(int argc, char **argv)
+signal_logging_test(void)
{
number_formatting();
logging_format();
diff --git a/test/string.c b/test/string.c
index 93867e04aa0b..406b7bf8a8dd 100644
--- a/test/string.c
+++ b/test/string.c
@@ -32,6 +32,7 @@
#include <assert.h>
#include "os.h"
+#include "tests-common.h"
/* Ensure we're testing our functions, even on platforms with libc versions */
#include <string.h>
@@ -62,7 +63,7 @@ strndup_checks(void)
}
int
-main(int argc, char **argv)
+string_test(void)
{
strndup_checks();
diff --git a/test/tests-common.h b/test/tests-common.h
index b02f746f6f56..e7812872aa16 100644
--- a/test/tests-common.h
+++ b/test/tests-common.h
@@ -1,6 +1,8 @@
#ifndef TESTS_COMMON_H
#define TESTS_COMMON_H
+#include "tests.h"
+
#define run_test(func) run_test_in_child(func, #func)
void run_test_in_child(int (*func)(void), const char *funcname);
diff --git a/test/tests.c b/test/tests.c
new file mode 100644
index 000000000000..cf72acafb65b
--- /dev/null
+++ b/test/tests.c
@@ -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;
+}
diff --git a/test/tests.h b/test/tests.h
index 0b673ee7ae79..b96ca78bbdad 100644
--- a/test/tests.h
+++ b/test/tests.h
@@ -1,6 +1,18 @@
#ifndef 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_xiqueryversion_test(void);
diff --git a/test/touch.c b/test/touch.c
index 19c68784ded4..16aaf4bbb2cb 100644
--- a/test/touch.c
+++ b/test/touch.c
@@ -30,6 +30,8 @@
#include "assert.h"
#include "scrnintstr.h"
+#include "tests-common.h"
+
static void
touch_grow_queue(void)
{
@@ -278,13 +280,15 @@ touch_init(void)
}
int
-main(int argc, char **argv)
+touch_test(void)
{
+ printf("touch_test: start...\n");
touch_grow_queue();
touch_find_ddxid();
touch_begin_ddxtouch();
touch_init();
touch_begin_touch();
+ printf("touch_test: exiting successfully\n");
return 0;
}
diff --git a/test/xfree86.c b/test/xfree86.c
index a986711834a5..ff8ad2d2d258 100644
--- a/test/xfree86.c
+++ b/test/xfree86.c
@@ -30,6 +30,8 @@
#include "xf86.h"
#include "xf86Parser.h"
+#include "tests-common.h"
+
static void
xfree86_option_list_duplicate(void)
{
@@ -96,7 +98,7 @@ xfree86_add_comment(void)
}
int
-main(int argc, char **argv)
+xfree86_test(void)
{
xfree86_option_list_duplicate();
xfree86_add_comment();
diff --git a/test/xkb.c b/test/xkb.c
index 9047f594cf25..23d5b22a641b 100644
--- a/test/xkb.c
+++ b/test/xkb.c
@@ -48,6 +48,8 @@
#include "../xkb/xkb.h"
#include <assert.h>
+#include "tests-common.h"
+
/**
* Initialize an empty XkbRMLVOSet.
* Call XkbGetRulesDflts to obtain the default ruleset.
@@ -164,7 +166,7 @@ xkb_set_get_rules_test(void)
}
int
-main(int argc, char **argv)
+xkb_test(void)
{
xkb_set_get_rules_test();
xkb_get_rules_test();
diff --git a/test/xtest.c b/test/xtest.c
index e9fabfbb9c2c..05d7ec1d350e 100644
--- a/test/xtest.c
+++ b/test/xtest.c
@@ -35,6 +35,8 @@
#include "xserver-properties.h"
#include "syncsrv.h"
+#include "tests-common.h"
+
/**
*/
@@ -123,7 +125,7 @@ xtest_properties(void)
}
int
-main(int argc, char **argv)
+xtest_test(void)
{
xtest_init_devices();
xtest_properties();
--
2.9.2
More information about the xorg-devel
mailing list