Skip to content

Commit 550e5b3

Browse files
committed
Support building without gudev
Don't fail the configure step if gudev isn't available. Just skip the corresponding unit tests in that case. Fixes #80
1 parent e50964b commit 550e5b3

File tree

2 files changed

+36
-24
lines changed

2 files changed

+36
-24
lines changed

Makefile.am

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,12 @@ tests_readbyte_CFLAGS = \
245245
$(AM_CFLAGS) \
246246
$(NULL)
247247

248-
noinst_PROGRAMS += tests/test-umockdev tests/test-ioctl-tree
248+
noinst_PROGRAMS += tests/test-ioctl-tree
249+
250+
if HAVE_GUDEV
251+
252+
noinst_PROGRAMS += tests/test-umockdev tests/test-umockdev-vala
253+
CHECKS += tests/test-umockdev tests/test-umockdev-vala
249254

250255
tests_test_umockdev_SOURCES = tests/test-umockdev.c
251256

@@ -264,6 +269,27 @@ tests_test_umockdev_LDADD = \
264269
$(GUDEV_LIBS) \
265270
$(NULL)
266271

272+
tests_test_umockdev_vala_SOURCES = \
273+
tests/test-umockdev-vala.vala \
274+
tests/assertions.vapi \
275+
tests/ioctl.vapi \
276+
src/posix_extra.vapi \
277+
$(NULL)
278+
279+
tests_test_umockdev_vala_CFLAGS = $(GLIB_CFLAGS) $(GUDEV_CFLAGS) -I $(srcdir)/src -I src -w
280+
tests_test_umockdev_vala_LDADD = $(GLIB_LIBS) $(GUDEV_LIBS) libumockdev.la
281+
tests_test_umockdev_vala_VALAFLAGS = \
282+
--vapidir tests \
283+
--vapidir $(top_builddir)/src \
284+
--pkg umockdev-1.0 \
285+
--pkg glib-2.0 \
286+
--pkg gio-2.0 \
287+
--pkg gudev-1.0 \
288+
$(AM_VALAFLAGS) \
289+
$(NULL)
290+
291+
endif # HAVE_GUDEV
292+
267293
tests_test_ioctl_tree_SOURCES = \
268294
src/ioctl_tree.c \
269295
tests/test-ioctl-tree.c \
@@ -281,30 +307,11 @@ tests_test_ioctl_tree_LDADD = \
281307
$(GLIB_LIBS) \
282308
$(NULL)
283309

284-
CHECKS += tests/test-umockdev tests/test-ioctl-tree
310+
CHECKS += tests/test-ioctl-tree
285311

286312
EXTRA_DIST += tests/test-umockdev.py tests/xorg-dummy.conf tests/test-static-code
287313

288-
noinst_PROGRAMS += tests/test-umockdev-vala tests/test-umockdev-run tests/test-umockdev-record
289-
290-
tests_test_umockdev_vala_SOURCES = \
291-
tests/test-umockdev-vala.vala \
292-
tests/assertions.vapi \
293-
tests/ioctl.vapi \
294-
src/posix_extra.vapi \
295-
$(NULL)
296-
297-
tests_test_umockdev_vala_CFLAGS = $(GLIB_CFLAGS) $(GUDEV_CFLAGS) -I $(srcdir)/src -I src -w
298-
tests_test_umockdev_vala_LDADD = $(GLIB_LIBS) $(GUDEV_LIBS) libumockdev.la
299-
tests_test_umockdev_vala_VALAFLAGS = \
300-
--vapidir tests \
301-
--vapidir $(top_builddir)/src \
302-
--pkg umockdev-1.0 \
303-
--pkg glib-2.0 \
304-
--pkg gio-2.0 \
305-
--pkg gudev-1.0 \
306-
$(AM_VALAFLAGS) \
307-
$(NULL)
314+
noinst_PROGRAMS += tests/test-umockdev-run tests/test-umockdev-record
308315

309316
tests_test_umockdev_run_SOURCES = \
310317
tests/test-umockdev-run.vala \
@@ -351,7 +358,7 @@ DISTCLEANFILES += \
351358
$(srcdir)/tests_test_umockdev_record_vala.stamp \
352359
$(NULL)
353360

354-
CHECKS += tests/test-umockdev-vala tests/test-umockdev-run tests/test-umockdev-record
361+
CHECKS += tests/test-umockdev-run tests/test-umockdev-record
355362

356363
# we do not use TESTS to avoid using the parallel test runner which does not
357364
# give any useful output on failures
@@ -367,10 +374,12 @@ check-local: $(CHECKS)
367374

368375
if HAVE_INTROSPECTION
369376
if HAVE_PYTHON
377+
if HAVE_GUDEV
370378
@if [ -z "$(T)" ]; then \
371379
echo "== Running GI test with $(PYTHON) against build tree =="; \
372380
$(PYTEST_TREE) $(srcdir)/tests/test-umockdev.py; \
373381
fi
382+
endif
374383
endif
375384
echo "== Running static code tests against build tree =="
376385
$(srcdir)/tests/test-static-code
@@ -386,10 +395,12 @@ check-installed: $(CHECKS)
386395

387396
if HAVE_INTROSPECTION
388397
if HAVE_PYTHON
398+
if HAVE_GUDEV
389399
@echo "== Running GI test with $(PYTHON) against installed system =="
390400
$(PYTEST_INSTALL) $(srcdir)/tests/test-umockdev.py
391401
endif
392402
endif
403+
endif
393404

394405
check-valgrind:
395406
EXEC_NAME="valgrind --leak-check=full --show-possibly-lost=no -q" G_DEBUG=gc-friendly $(MAKE) check

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ m4_ifdef([GOBJECT_INTROSPECTION_CHECK],
7171
AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([Dynamic linking loader library not found])])
7272
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.32.0 gobject-2.0 >= 2.32.0 gio-2.0 >= 2.32.0 gio-unix-2.0 >= 2.32.0])
7373
PKG_CHECK_MODULES([LIBUDEV], [libudev])
74-
PKG_CHECK_MODULES([GUDEV], [gudev-1.0])
74+
PKG_CHECK_MODULES([GUDEV], [gudev-1.0],[have_gudev=yes], [have_gudev=])
75+
AM_CONDITIONAL([HAVE_GUDEV], [test x$have_gudev != x])
7576
7677
7778
# if we have Python 2 or 3, run the GI test (they will skip if gi.repository is

0 commit comments

Comments
 (0)