From dceb293f15e60ee6a932499b6c63b2a6fb84f38a Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Sun, 30 Apr 2017 12:34:37 +0100 Subject: [PATCH] Add unit test suites with initial successful dummy test (#781978) Now 'make check' will additionally build and run the test suites in the ./tests directory. Add initial always successful dummy test suite. This is done using Automake support for testing. Automake Manual, 15 Support for test suites https://www.gnu.org/software/automake/manual/automake.html#Tests ./tests/Makefile.am takes some influence from the same file in the minimal-gtest-autotools template project. https://github.com/octol/minimal-gtest-autotools/blob/654848ec0164a80f851fa80b8355099f35c025a2/tests/Makefile.am Bug 781978 - Add Google Test C++ test framework --- .gitignore | 5 +++++ Makefile.am | 2 +- configure.ac | 1 + tests/Makefile.am | 19 +++++++++++++++++++ tests/test_dummy.cc | 14 ++++++++++++++ 5 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 tests/Makefile.am create mode 100644 tests/test_dummy.cc diff --git a/.gitignore b/.gitignore index d0cc7ab6..86710b3a 100644 --- a/.gitignore +++ b/.gitignore @@ -43,5 +43,10 @@ missing mkinstalldirs omf.make stamp-* +test-driver testbuild.log +tests/*.log +tests/*.trs +tests/test-suite.log +tests/test_dummy xmldocs.make diff --git a/Makefile.am b/Makefile.am index 481ff2ae..50458770 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = compose data doc include lib po src +SUBDIRS = compose data doc include lib po src tests # Only build GParted help documentation when enabled. (Can be disabled # with './configure --disable-doc'). if BUILD_HELP_DOC diff --git a/configure.ac b/configure.ac index 702ad3dc..8368c10b 100644 --- a/configure.ac +++ b/configure.ac @@ -383,6 +383,7 @@ lib/Makefile lib/gtest/Makefile src/Makefile po/Makefile.in +tests/Makefile ]) AC_OUTPUT diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 00000000..e3475517 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,19 @@ +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/lib/gtest/include \ + $(GTEST_CPPFLAGS) +AM_CXXFLAGS = -Wall $(GTEST_CXXFLAGS) +AM_LDFLAGS = $(GTEST_LDFLAGS) +LDADD = \ + $(GTEST_LIBS) \ + $(top_srcdir)/lib/gtest/lib/libgtest_main.la \ + $(top_srcdir)/lib/gtest/lib/libgtest.la + +# Programs to be built by "make check" +check_PROGRAMS = \ + test_dummy + +# Test cases to be run by "make check" +TESTS = $(check_PROGRAMS) + +test_dummy_SOURCES = test_dummy.cc diff --git a/tests/test_dummy.cc b/tests/test_dummy.cc new file mode 100644 index 00000000..22453a4c --- /dev/null +++ b/tests/test_dummy.cc @@ -0,0 +1,14 @@ +/* Copyright (C) 2017 Mike Fleetwood + * + * Copying and distribution of this file, with or without modification, + * are permitted in any medium without royalty provided the copyright + * notice and this notice are preserved. This file is offered as-is, + * without any warranty. + */ + +#include "gtest/gtest.h" + +TEST( DummyTest, Success ) +{ + EXPECT_TRUE( true ); +}