From ce91785a89e0ee1701cc668358a1d7b3cb07a37d Mon Sep 17 00:00:00 2001 From: Tim Hentenaar Date: Wed, 19 Jul 2023 22:54:20 -0400 Subject: [PATCH] s/travis/gha/ --- .github/workflows/ci.yml | 35 ++++++ .github/workflows/coverity.yml | 22 ++++ .github/workflows/release.yml | 21 ++++ .gitignore | 4 +- .travis-install.sh | 15 --- .travis.yml | 50 -------- Makefile.in | 7 +- README.md | 4 +- configure | 206 ++++++++++++++++++++++++++++++--- configure.ac | 7 +- m4/ax_check_dep.m4 | 14 ++- m4/ax_strict_cflags.m4 | 8 ++ src/db/mysql.c | 4 +- src/db/pgsql.c | 2 +- test/Makefile.in | 38 +++--- 15 files changed, 316 insertions(+), 121 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/coverity.yml create mode 100644 .github/workflows/release.yml delete mode 100755 .travis-install.sh delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d772553 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + build: + if: github.repository == 'thentenaar/mmm' + strategy: + matrix: + CC: [gcc, clang] + env: + CC: ${{ matrix.CC }} + runs-on: ubuntu-latest + name: linux-${{ matrix.CC }} + steps: + - uses: actions/checkout@v3 + - name: Install deps + run: | + sudo apt install libpq-dev libmysqlclient-dev libsqlite3-dev libgit2-dev check gcovr llvm + - name: Build + run: | + ./configure + make coveralls + - uses: coverallsapp/github-action@v2 + if: matrix.CC == 'gcc' + with: + format: coveralls + file: ${{ github.workspace }}/test/coveralls.json + compare-ref: master + github-token: ${{ secrets.GITHUB_TOKEN }} + diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml new file mode 100644 index 0000000..a7fb6de --- /dev/null +++ b/.github/workflows/coverity.yml @@ -0,0 +1,22 @@ +name: Coverity +on: + push: + branches: + - covscan +jobs: + coverity: + if: github.repository == 'thentenaar/mmm' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Pre-build + run: | + sudo apt install libpq-dev libmysqlclient-dev libsqlite3-dev libgit2-dev + ./configure + - uses: vapier/coverity-scan-action@v1 + with: + project: thentenaar/mmm + email: ${{ secrets.COVERITY_SCAN_EMAIL }} + token: ${{ secrets.COVERITY_SCAN_TOKEN }} + command: make + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0114ab1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,21 @@ +name: Release +on: + push: + tags: + - v* +permissions: + contents: write +jobs: + release: + if: github.repository == 'thentenaar/mmm' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - id: changelog + uses: metcalfc/changelog-generator@v4.1.0 + with: + myToken: ${{ secrets.GITHUB_TOKEN }} + - uses: softprops/action-gh-release@v1 + with: + body: ${{ steps.changelog.outputs.changelog }} + diff --git a/.gitignore b/.gitignore index bf2d39c..cd27562 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,10 @@ Makefile -test/Makefile -test/test_runner +test_runner config.log config.status autom4te.cache configure~ *.o *.sw? +*.gc[nd][oa] mmm diff --git a/.travis-install.sh b/.travis-install.sh deleted file mode 100755 index 3680e02..0000000 --- a/.travis-install.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -if [ "$TRAVIS_OS_NAME" == "linux" ] -then - pip install --user cpp-coveralls gcovr -fi - -# Build libgit2 -mkdir -p $HOME/deproot -wget https://github.com/libgit2/libgit2/archive/v0.26.8.tar.gz -tar -xzf v0.26.8.tar.gz -mkdir -p libgit2-build && cd libgit2-build -cmake -DCMAKE_INSTALL_PREFIX=$HOME/deproot --build=. ../libgit2-0.26.8 -make && make install -cd .. ; rm -rf libgit2-build libgit2-0.26.8 - diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9f90982..0000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -# Configuration for Travis CI - -env: - global: - - secure: "EHHzggqcLY/IfN9FhPHXjaF/8P02IBhmKEEHb1kP6NsmzAp3GfI/nhJnHRrXNGlH+PwwRErkZjTFXI+DHYOz9wPvaYBsrt2p0XZka0kGGPJkOIx9ibBnyQt1BcJigrt8MvFEBNkx+u8Jv147Sp9lbJlovl7NC2DCdY4ELR4ebNN1ZNfqhbheFPLMsFNQmCDl86nG4BaWctRkaE1rJBKWARrjfRGuNzveI52/AG1f0zsgbmmIvHpzmQM73cEI6+MNGiEnUVFqm+FEIS06GjHkqdbjjmMRotxx0vusqlroE8anlOi1uecJ5O2Y7vNKzV9rx8mBI14QaWJtddgFzS2+al4mpAaRtQKhVSu3hpW/wh4PhWEq+gahhZBboe+bDttrng4q+lqZPFwnNU2PpzPCbXWyxbLXFVR3eep5ryHltga7AzoNR5c7g8z1/qoPSIeA9CnW+0grkCQLWxIkjtCnydB09brmW8q7p+uJfvPnYNjguproRbYaTN1NNd3ybcLE5qQxXdfoUTd72jBHs3YHIJASOPeg8UL+8ca7b/mIUTG3F/9nd9wMXzBXz3EFSj0inZcbstcmE1Vf33O1eOKpa2IbFr/NMBMn3DX6JWnr2BjG2p4QTpqiqtryvmpwbTFqYUG8rWxqf4GP/5RhLi5niATTTo2l71S+cZZmxysEB9s=" - -languages: c - -branches: - only: - - master - - covscan - -sudo: false - -os: - - linux - -compilers: - - gcc - - clang - -matrix: - fast_finish: true - -install: - - ./.travis-install.sh - -script: - - if [ -z ${COVERITY_SCAN_BRANCH} ] || [ ${COVERITY_SCAN_BRANCH} != 1 ] ; then CPPFLAGS="-isystem $HOME/deproot/include" ./configure --with-libgit2=$HOME/deproot && make && make test ; fi - -after_success: - - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then COVERALLS=1 make clean coverage ; fi - -addons: - apt: - packages: - - libpq-dev - - libmysqlclient-dev - - libsqlite3-dev - - libcunit1 - - libcunit1-dev - coverity_scan: - project: - name: "thentenaar/mmm" - description: "Minimal Migration Manager" - notification_email: tim@hentenaar.com - build_command_prepend: ./configure --with-libgit2=$HOME/deproot - build_command: make - branch_pattern: covscan diff --git a/Makefile.in b/Makefile.in index 4aee3bd..2f0b47a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -94,7 +94,10 @@ check: @$(MAKE) -C test check coverage: - @COVERAGE=1 $(MAKE) -C test coverage + @COVERAGE=1 $(MAKE) -C test clean coverage + +coveralls: + @COVERAGE=1 $(MAKE) -C test clean coveralls indent: ifneq (,$(INDENT)) @@ -109,5 +112,5 @@ endif @$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< .SUFFIXES: .c .o -.PHONY: all install uninstall clean check coverage indent +.PHONY: all install uninstall clean check coverage coveralls indent diff --git a/README.md b/README.md index f7c76d9..2d90a74 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ Minimal Migration Manager ========================= -[![Travis CI Status](https://secure.travis-ci.org/thentenaar/mmm.svg?branch=master)](https://travis-ci.org/thentenaar/mmm) -[![Coverage Status](https://coveralls.io/repos/thentenaar/mmm/badge.svg?branch=master)](https://coveralls.io/r/thentenaar/mmm) +[![CI Status](https://github.com/thentenaar/mmm/workflows/CI/badge.svg)](https://github.com/thentenaar/mmm/actions) +[![Coverage Status](https://coveralls.io/repos/github/thentenaar/mmm/badge.svg?branch=master)](https://coveralls.io/github/thentenaar/mmm?branch=master) [![Coverity Status](https://scan.coverity.com/projects/5663/badge.svg)](https://scan.coverity.com/projects/5663) Synopsis diff --git a/configure b/configure index 2983da5..c79ee1c 100755 --- a/configure +++ b/configure @@ -650,13 +650,19 @@ ac_includes_default="\ ac_header_c_list= ac_subst_vars='LTLIBOBJS LIBOBJS +ax_cc_gcov_command INDENT GCOVR have_libgit2 +LIBS_libgit2 have_mysql +LIBS_mysql have_pgsql +LIBS_pgsql have_sqlite3 +LIBS_sqlite3 have_check +LIBS_check INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM @@ -4346,6 +4352,7 @@ fi else $as_nop + LIBS_check="$LIBS" if test "x$with_check" != "x$prefix" then : @@ -4369,6 +4376,160 @@ fi + +if test "x$have_check" != "xyes" +then : + + + + have_check=no + +# Check whether --with-check was given. +if test ${with_check+y} +then : + withval=$with_check; with_check=$withval +else $as_nop + with_check=yes + +fi + + + if test "$with_check" != "no" +then : + + have_check=yes + save_cppflags=$CPPFLAGS + save_ldflags=$LDFLAGS + save_libs=$LIBS + + if test "$with_check" == "yes" +then : + with_check=$prefix +fi + if test "$with_check" != "$prefix" +then : + + CPPFLAGS="$CPPFLAGS -I$with_check/include" + +fi + ac_fn_c_check_header_compile "$LINENO" "check.h" "ac_cv_header_check_h" "$ac_includes_default" +if test "x$ac_cv_header_check_h" = xyes +then : + +else $as_nop + have_check=no +fi + + + if test "$have_check" != "no" +then : + + if test "$with_check" != "$prefix" +then : + + LDFLAGS="$LDFLAGS -L$with_check/lib" + +fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suite_create in -lcheck" >&5 +printf %s "checking for suite_create in -lcheck... " >&6; } +if test ${ac_cv_lib_check_suite_create+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcheck -lsubunit -lm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char suite_create (void); +int +main (void) +{ +return suite_create (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_check_suite_create=yes +else $as_nop + ac_cv_lib_check_suite_create=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_check_suite_create" >&5 +printf "%s\n" "$ac_cv_lib_check_suite_create" >&6; } +if test "x$ac_cv_lib_check_suite_create" = xyes +then : + printf "%s\n" "#define HAVE_LIBCHECK 1" >>confdefs.h + + LIBS="-lcheck $LIBS" + +else $as_nop + have_check=no +fi + + +fi + + if test "$have_check" == "no" +then : + + CPPFLAGS=$save_cppflags + LDFLAGS=$save_ldflags + LIBS=$save_libs + if test "xnonfatal" != "x" +then : + +else $as_nop + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "check not found. +See \`config.log' for more details" "$LINENO" 5; } + +fi + +else $as_nop + + LIBS_check="$LIBS-lsubunit -lm" + if test "x$with_check" != "x$prefix" +then : + + if test "x$RPATHS" != "x" +then : + + RPATH="$RPATH:$with_check/lib" + +else $as_nop + + RPATH="$with_check/lib" + +fi + +fi + +fi + +fi + + + + + + +fi LIBS= @@ -4494,6 +4655,7 @@ fi else $as_nop + LIBS_sqlite3="$LIBS" if test "x$with_sqlite3" != "x$prefix" then : @@ -4519,6 +4681,7 @@ fi + have_pgsql=no # Check whether --with-pgsql was given. @@ -4549,8 +4712,8 @@ then : CPPFLAGS="$CPPFLAGS -I$with_pgsql/include" fi - ac_fn_c_check_header_compile "$LINENO" "libpq-fe.h" "ac_cv_header_libpq_fe_h" "$ac_includes_default" -if test "x$ac_cv_header_libpq_fe_h" = xyes + ac_fn_c_check_header_compile "$LINENO" "postgresql/libpq-fe.h" "ac_cv_header_postgresql_libpq_fe_h" "$ac_includes_default" +if test "x$ac_cv_header_postgresql_libpq_fe_h" = xyes then : else $as_nop @@ -4640,6 +4803,7 @@ fi else $as_nop + LIBS_pgsql="$LIBS" if test "x$with_pgsql" != "x$prefix" then : @@ -4665,6 +4829,7 @@ fi + have_mysql=no # Check whether --with-mysql was given. @@ -4695,8 +4860,8 @@ then : CPPFLAGS="$CPPFLAGS -I$with_mysql/include" fi - ac_fn_c_check_header_compile "$LINENO" "mysql.h" "ac_cv_header_mysql_h" "$ac_includes_default" -if test "x$ac_cv_header_mysql_h" = xyes + ac_fn_c_check_header_compile "$LINENO" "mysql/mysql.h" "ac_cv_header_mysql_mysql_h" "$ac_includes_default" +if test "x$ac_cv_header_mysql_mysql_h" = xyes then : else $as_nop @@ -4713,14 +4878,14 @@ then : LDFLAGS="$LDFLAGS -L$with_mysql/lib" fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for mysql_library_init in -lmysql" >&5 -printf %s "checking for mysql_library_init in -lmysql... " >&6; } -if test ${ac_cv_lib_mysql_mysql_library_init+y} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for mysql_server_init in -lmysqlclient" >&5 +printf %s "checking for mysql_server_init in -lmysqlclient... " >&6; } +if test ${ac_cv_lib_mysqlclient_mysql_server_init+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS -LIBS="-lmysql $LIBS" +LIBS="-lmysqlclient $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -4733,32 +4898,32 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char mysql_library_init (void); +char mysql_server_init (void); int main (void) { -return mysql_library_init (); +return mysql_server_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_mysql_mysql_library_init=yes + ac_cv_lib_mysqlclient_mysql_server_init=yes else $as_nop - ac_cv_lib_mysql_mysql_library_init=no + ac_cv_lib_mysqlclient_mysql_server_init=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mysql_mysql_library_init" >&5 -printf "%s\n" "$ac_cv_lib_mysql_mysql_library_init" >&6; } -if test "x$ac_cv_lib_mysql_mysql_library_init" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mysqlclient_mysql_server_init" >&5 +printf "%s\n" "$ac_cv_lib_mysqlclient_mysql_server_init" >&6; } +if test "x$ac_cv_lib_mysqlclient_mysql_server_init" = xyes then : - printf "%s\n" "#define HAVE_LIBMYSQL 1" >>confdefs.h + printf "%s\n" "#define HAVE_LIBMYSQLCLIENT 1" >>confdefs.h - LIBS="-lmysql $LIBS" + LIBS="-lmysqlclient $LIBS" else $as_nop have_mysql=no @@ -4786,6 +4951,7 @@ fi else $as_nop + LIBS_mysql="$LIBS" if test "x$with_mysql" != "x$prefix" then : @@ -4810,6 +4976,7 @@ fi + if test "$have_sqlite3" != "yes" then : @@ -4950,6 +5117,7 @@ fi else $as_nop + LIBS_libgit2="$LIBS" if test "x$with_libgit2" != "x$prefix" then : @@ -4974,6 +5142,7 @@ fi + # Extract the first word of "gcovr", so it can be a program name with args. set dummy gcovr; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -5120,6 +5289,7 @@ fi if test "$ax_cc_clang" == "yes" then : + ax_cc_gcov_command="llvm-cov gcov" @@ -5191,6 +5361,7 @@ done else $as_nop + ax_cc_gcov_command="gcov" @@ -5403,6 +5574,7 @@ done fi + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' diff --git a/configure.ac b/configure.ac index c94064e..65d98d9 100644 --- a/configure.ac +++ b/configure.ac @@ -39,12 +39,15 @@ AC_TYPE_SIZE_T dnl Check for check AX_SET_PREFIX AX_CHECK_DEP([check], [check.h], [check], [srunner_run_all], [nonfatal]) +AS_IF([test "x$have_check" != "xyes"],[ + AX_CHECK_DEP([check], [check.h], [check], [suite_create], [nonfatal], [-lsubunit -lm]) +]) LIBS= dnl Check for Databases AX_CHECK_DEP([sqlite3], [sqlite3.h], [sqlite3], [sqlite3_open], [nonfatal]) -AX_CHECK_DEP([pgsql], [libpq-fe.h], [pq], [PQconnectdb], [nonfatal]) -AX_CHECK_DEP([mysql], [mysql.h], [mysql], [mysql_library_init], [nonfatal]) +AX_CHECK_DEP([pgsql], [postgresql/libpq-fe.h], [pq], [PQconnectdb], [nonfatal]) +AX_CHECK_DEP([mysql], [mysql/mysql.h], [mysqlclient], [mysql_server_init], [nonfatal]) dnl Ensure at least one supported database is available AS_IF([test "$have_sqlite3" != "yes"], [ diff --git a/m4/ax_check_dep.m4 b/m4/ax_check_dep.m4 index 2aac234..af6eed1 100644 --- a/m4/ax_check_dep.m4 +++ b/m4/ax_check_dep.m4 @@ -11,15 +11,15 @@ dnl AX_CHECK_DEP - Check for a dependant library dnl dnl USAGE dnl -dnl AX_CHECK_DEP(dep, header, library, function, nonfatal) +dnl AX_CHECK_DEP(dep, header, library, function, nonfatal, otherlibs) dnl dnl PARAMETERS dnl -dnl dep - Name of the dependency -dnl header - Header file to look for -dnl library - Library to look for -dnl function - Function to look for within the library -dnl nonfatal - If set, don't abort if this dep is missing +dnl dep - Name of the dependency +dnl header - Header file to look for +dnl library - Library to look for +dnl function - Function to look for within the library +dnl nonfatal - If set, don't abort if this dep is missing dnl otherlibs - Other needed libraries dnl dnl DESCRIPTION @@ -75,6 +75,7 @@ AC_DEFUN([AX_CHECK_DEP],[ [AC_MSG_FAILURE([DEP not found.]) ]) ],[ + LIBS_[]DEP[]="$LIBS$6" AS_IF([test "x$with_[]DEP" != "x$prefix" ],[ AS_IF([test "x$RPATHS" != "x" ], [ RPATH="$RPATH:$with_[]DEP[/lib]" @@ -85,6 +86,7 @@ AC_DEFUN([AX_CHECK_DEP],[ ]) ]) + AC_SUBST([LIBS_]DEP[]) AC_SUBST([have_]DEP[]) popdef([DEP]) ]) dnl AX_CHECK_DEP diff --git a/m4/ax_strict_cflags.m4 b/m4/ax_strict_cflags.m4 index 2ae6bed..1b07695 100644 --- a/m4/ax_strict_cflags.m4 +++ b/m4/ax_strict_cflags.m4 @@ -16,6 +16,11 @@ dnl Clang, and adds supoprted options to CFLAGS. -Werror doesn't dnl get added here, simply because having -Werror and -Wstrict-prototypes dnl will cause compilations from autoconf to fail. dnl +dnl COVERAGE +dnl +dnl This macro exports ax_cc_gcov_command as the proper gcov command +dnl to invoke (i.e. llvm-cov gcov on clang.) +dnl AC_DEFUN([AX_STRICT_CFLAGS],[ AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) @@ -28,6 +33,7 @@ AC_DEFUN([AX_STRICT_CFLAGS],[ [ax_cc_clang="no"]) AS_IF([test "$ax_cc_clang" == "yes"],[ + ax_cc_gcov_command="llvm-cov gcov" AX_APPEND_COMPILE_FLAGS([ dnl -pedantic dnl -Weverything dnl @@ -43,6 +49,7 @@ AC_DEFUN([AX_STRICT_CFLAGS],[ -Qunused-arguments dnl ]) ],[ dnl Assume GCC + ax_cc_gcov_command="gcov" AX_APPEND_COMPILE_FLAGS([ dnl -pedantic dnl -Wall dnl @@ -69,5 +76,6 @@ AC_DEFUN([AX_STRICT_CFLAGS],[ AX_APPEND_COMPILE_FLAGS([-Wc90-c99-compat]) ]) + AC_SUBST([ax_cc_gcov_command]) AC_LANG_POP([C]) ]) dnl AX_STRICT_CFLAGS diff --git a/src/db/mysql.c b/src/db/mysql.c index c92b9fc..ace64b1 100644 --- a/src/db/mysql.c +++ b/src/db/mysql.c @@ -10,6 +10,8 @@ #include #ifndef IN_TESTS +/* The newer mysql headers aren't ANSI-friendly :/ */ +#define inline #include #endif @@ -20,7 +22,7 @@ * Constant representing a value of 'TRUE' for * MySQL options. */ -static const my_bool tr = 1; +static const int tr = 1; /** * Initialize the mysql library. diff --git a/src/db/pgsql.c b/src/db/pgsql.c index f2e979d..12fdbf3 100644 --- a/src/db/pgsql.c +++ b/src/db/pgsql.c @@ -10,7 +10,7 @@ #include #ifndef IN_TESTS -#include +#include #endif #include "driver.h" diff --git a/test/Makefile.in b/test/Makefile.in index f0e356a..17df971 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -7,30 +7,20 @@ # CC=@CC@ GCOVR=@GCOVR@ +GCOVR_FLAGS=-r .. -e '^test/' --gcov-executable "@ax_cc_gcov_command@" -CPPFLAGS=-DIN_TESTS @DEFS@ @CPPFLAGS@ +CPPFLAGS=-DIN_TESTS @CPPFLAGS@ +CFLAGS=@CFLAGS@ LDFLAGS=@LDFLAGS@ -LIBS=-lcheck -CFLAGS=-g @CFLAGS@ +LIBS=@LIBS_check@ HAVE_CHECK=@have_check@ # Gather the test sources SRCS := $(wildcard *.c) -# Default flags for gcovr -GCOVR_FLAGS = -d -r .. -e '^test/' - -# If COVERAGE is defined, generate a coverage report. -ifneq ($(origin COVERAGE), undefined) -ifneq (,$(GCOVR)) - CFLAGS := -O0 -coverage $(filter-out -O2,$(CFLAGS)) - -# Don't remove gcov files when using coveralls -ifneq ($(origin COVERALLS), undefined) - GCOVR_FLAGS := $(filter-out -d,$(GCOVR_FLAGS)) -endif # COVERALLS -endif # GCOVR -endif # COVERAGE +ifneq (,$(COVERAGE)) +CFLAGS:=-g -O0 -fprofile-arcs -ftest-coverage $(filter-out -O2,@CFLAGS@) +endif # # Targets @@ -39,7 +29,7 @@ endif # COVERAGE all: check clean: - @$(RM) test_runner + @$(RM) test_runner *.gc[nd][oa] coveralls.json ifeq (no, $(HAVE_CHECK)) check: ;$(warning check must be installed to build the tests.) @@ -53,15 +43,17 @@ test_runner: $(SRCS) ifeq (,$(GCOVR)) coverage: ;$(warning gcovr must be installed for coverage reports.) +coveralls: ;$(warning gcovr must be installed for coverage reports.) else coverage: check @echo @$(GCOVR) $(GCOVR_FLAGS) -ifneq ($(origin COVERALLS), undefined) - @coveralls -r .. --gcov-options '\-lp' -endif - @$(RM) -f *.gc[nd][oa] + +coveralls: check + @echo + @$(GCOVR) $(GCOVR_FLAGS) -s --coveralls coveralls.json endif # GCOVR endif # HAVE_CHECK -.PHONY: all clean check coverage +.PHONY: all clean check coverage coveralls +