mirror of https://github.com/nirenjan/libx52.git
Change libx52 mock tests to use preprocessor overrides
Prior to this change, libx52 tests needed a linker that supported the --wrap argument. This is not available on OSX, and therefore, we had to disable the unit tests on non-Linux systems. Since we needed to rebuild the libx52 library anyway for the test, it is simpler to just define libusb_control_transfer to point to our mock function. This allows us to verify libx52 on all supported platforms.pull/22/head
parent
8388f3308e
commit
681a8e8aa1
|
@ -73,11 +73,10 @@ AM_COND_IF([HAVE_DOXYGEN],
|
||||||
[AC_CONFIG_FILES([Doxyfile])],
|
[AC_CONFIG_FILES([Doxyfile])],
|
||||||
[AC_MSG_WARN(["Doxygen not found; continuing without doxygen support"])])
|
[AC_MSG_WARN(["Doxygen not found; continuing without doxygen support"])])
|
||||||
|
|
||||||
# cmocka unit tests, currently only supported on Linux
|
# cmocka unit tests
|
||||||
AX_PKG_CHECK_MODULES([CMOCKA], [cmocka >= 1.1], [], [have_cmocka=yes], [have_cmocka=no])
|
AX_PKG_CHECK_MODULES([CMOCKA], [cmocka >= 1.1], [], [have_cmocka=yes], [have_cmocka=no])
|
||||||
AM_CONDITIONAL([HAVE_CMOCKA], [test "x$have_cmocka" = xyes])
|
AM_CONDITIONAL([HAVE_CMOCKA], [test "x$have_cmocka" = xyes])
|
||||||
AM_COND_IF([HAVE_CMOCKA], [AM_COND_IF([LINUX], [],
|
AM_COND_IF([HAVE_CMOCKA], [],
|
||||||
[AC_MSG_WARN(["cmocka found; disabling mock tests on ${host_os}])])],
|
|
||||||
[AC_MSG_WARN(["cmocka not found; disabling unit test build"])])
|
[AC_MSG_WARN(["cmocka not found; disabling unit test build"])])
|
||||||
|
|
||||||
# Check for the presence of tm_gmtoff in struct tm. If we have this, then we
|
# Check for the presence of tm_gmtoff in struct tm. If we have this, then we
|
||||||
|
|
|
@ -31,7 +31,6 @@ x52include_HEADERS = libx52.h
|
||||||
# pkg-config files
|
# pkg-config files
|
||||||
pkgconfig_DATA = libx52.pc
|
pkgconfig_DATA = libx52.pc
|
||||||
|
|
||||||
if LINUX
|
|
||||||
if HAVE_CMOCKA
|
if HAVE_CMOCKA
|
||||||
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh
|
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh
|
||||||
TESTS = libx52test
|
TESTS = libx52test
|
||||||
|
@ -40,15 +39,14 @@ check_PROGRAMS = libx52test
|
||||||
nodist_libx52test_SOURCES = test_libx52.c
|
nodist_libx52test_SOURCES = test_libx52.c
|
||||||
libx52test_SOURCES = $(libx52_la_SOURCES)
|
libx52test_SOURCES = $(libx52_la_SOURCES)
|
||||||
libx52test_CFLAGS = @LIBUSB_CFLAGS@ -DLOCALEDIR='"$(localedir)"' -I $(top_srcdir)
|
libx52test_CFLAGS = @LIBUSB_CFLAGS@ -DLOCALEDIR='"$(localedir)"' -I $(top_srcdir)
|
||||||
libx52test_CFLAGS += -DGENERATED_TESTS='"test_libx52.c"'
|
libx52test_CFLAGS += -Dlibusb_control_transfer=__wrap_libusb_control_transfer
|
||||||
libx52test_LDFLAGS = -Wl,--wrap=libusb_control_transfer @CMOCKA_LIBS@ @LIBUSB_LIBS@
|
libx52test_LDFLAGS = @CMOCKA_LIBS@ @LIBUSB_LIBS@
|
||||||
libx52test_LDADD = libx52.la
|
libx52test_LDADD = libx52.la
|
||||||
|
|
||||||
CLEANFILES = test_libx52.c
|
CLEANFILES = test_libx52.c
|
||||||
test_libx52.c: $(srcdir)/x52_test_gen.py $(srcdir)/x52_tests.json
|
test_libx52.c: $(srcdir)/x52_test_gen.py $(srcdir)/x52_tests.json
|
||||||
$(AM_V_GEN) $(PYTHON) $(srcdir)/x52_test_gen.py $(srcdir)/x52_tests.json > $@
|
$(AM_V_GEN) $(PYTHON) $(srcdir)/x52_test_gen.py $(srcdir)/x52_tests.json > $@
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
|
|
||||||
# Extra files that need to be in the distribution
|
# Extra files that need to be in the distribution
|
||||||
EXTRA_DIST = libx52.h x52_commands.h x52_common.h README.md
|
EXTRA_DIST = libx52.h x52_commands.h x52_common.h README.md
|
||||||
|
|
Loading…
Reference in New Issue