From c2c6b8f8e7a8d4edfd45f09855444bca51488a9f Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sat, 1 Jun 2019 10:27:15 -0400 Subject: [PATCH] Add library test for libdiscid And establish a basic scheme to cover these macros in the test suite. --- .gitignore | 1 + Makefile.am | 2 ++ configure.ac | 1 + m4/libdiscid.m4 | 39 ++++++++++++++++++++++ t/libdummy.c | 3 ++ tests/libs.at | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/macros.at | 16 --------- testsuite.at | 18 ++++++++++ 8 files changed, 151 insertions(+), 16 deletions(-) create mode 100644 m4/libdiscid.m4 create mode 100644 t/libdummy.c create mode 100644 tests/libs.at diff --git a/.gitignore b/.gitignore index 621f62f..ae53a69 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ Makefile .deps *.lo *.o +*.a diff --git a/Makefile.am b/Makefile.am index de51272..17cf7d5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,6 +8,8 @@ ACLOCAL_AMFLAGS = -I m4 AM_CFLAGS = -I$(top_srcdir)/src +check_LIBRARIES = t/libdummy.a + check_PROGRAMS = t/packtestu t/packtests t/packtestu64 t/packtests64 t_packtestu_SOURCES = t/packtestu.c src/pack.c src/tap.c diff --git a/configure.ac b/configure.ac index abfccf7..a74cd71 100644 --- a/configure.ac +++ b/configure.ac @@ -9,6 +9,7 @@ AC_INIT([dxcommon], [0], [nbowler@draconx.ca]) AC_CONFIG_SRCDIR([m4/base.m4]) AC_PROG_CC +AC_PROG_RANLIB AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects]) AM_SILENT_RULES([yes]) diff --git a/m4/libdiscid.m4 b/m4/libdiscid.m4 new file mode 100644 index 0000000..7e28c4a --- /dev/null +++ b/m4/libdiscid.m4 @@ -0,0 +1,39 @@ +AC_DEFUN([DX_LIB_LIBDISCID], +[DX_LIB_SETUP([libdiscid])dnl +DX_LIB_PKGCONFIG_FLAGS([libdiscid]) +AC_MSG_CHECKING([for libdiscid[]m4_ifnblank([$1], [ at least version $1])]) +DX_LIB_SEARCH_LINK([libdiscid], + [m4_apply([_DX_LIB_LIBDISCID_TEST], m4_split([$1], [\.]))], + [ [[$LIBDISCID_CFLAGS], [$LIBDISCID_LIBS]], + [[$dx_cv_libdiscid_pkg_cflags], [$dx_cv_libdiscid_pkg_libs], + [test x"$dx_cv_libdiscid_pkg_found" = x"yes"]], + [[], [-ldiscid]] ]) +AS_IF([test x"$dx_cv_libdiscid_lib_found" = x"yes"], [$2], + [m4_default([$3], [AC_MSG_FAILURE( +[libdiscid[]m4_ifnblank([$1], [ version $1 or newer]) is required. The latest +version may be found at . +m4_newline([DX_LIB_USERFLAG_BLURB([libdiscid])]) +m4_newline([DX_LIB_PKGCONFIG_BLURB([libdiscid])]) +])])])]) + +dnl Internal test program for libdiscid. Check that the version numbers in the +dnl header are sufficient and that some important functions are defined. +m4_define([_DX_LIB_LIBDISCID_TEST], [AC_LANG_PROGRAM( +[#include +m4_ifnblank([$1], [dnl +#if DISCID_VERSION_MAJOR < $1 +DX_LIB_COMPILE_ERROR([major version insufficient]) +m4_ifnblank([$2], [dnl +#elif DISCID_VERSION_MAJOR == $1 +# if DISCID_VERSION_MINOR < $2 +DX_LIB_COMPILE_ERROR([minor version insufficient]) +m4_ifnblank([$3], [dnl +# elif DISCID_VERSION_MINOR == $2 +# if DISCID_VERSION_PATCH < $3 +DX_LIB_COMPILE_ERROR([patch version insufficient]) +# endif +])dnl +# endif +])dnl +#endif +])], [discid_free(discid_new());])]) diff --git a/t/libdummy.c b/t/libdummy.c new file mode 100644 index 0000000..5404a08 --- /dev/null +++ b/t/libdummy.c @@ -0,0 +1,3 @@ +/* Stub function definitions to satisfy link tests, as required. */ +void discid_new(void) {} +void discid_free(void) {} diff --git a/tests/libs.at b/tests/libs.at new file mode 100644 index 0000000..ab348de --- /dev/null +++ b/tests/libs.at @@ -0,0 +1,87 @@ +dnl Copyright © 2019 Nick Bowler +dnl +dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2. +dnl This is free software: you are free to do what the fuck you want to. +dnl There is NO WARRANTY, to the extent permitted by law. + +AT_BANNER([Library tests]) + +dnl TEST_DUMMY_PKGCONFIG([cflags], [libs]) +dnl +dnl Create a hack pkg-config script in the current working directory which +dnl responds to --cflags and --libs with the provided values. The macro +dnl arguments should each be a single shell word, suitable for the right +dnl hand side of a shell assignment. +m4_define([TEST_DUMMY_PKGCONFIG], +[[cat >pkg-config <