From 5b0b2df48b0d84086c0050628e95bd93eca94a38 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Tue, 29 Nov 2022 23:08:42 -0600 Subject: Add tests for mixed C/C++ unit test library usage --- ChangeLog | 7 +++- Makefile.am | 4 +- Makefile.in | 19 ++++++++- testsuite/libdejagnu/unit-ccxxmix.cxx | 78 +++++++++++++++++++++++++++++++++++ testsuite/libdejagnu/unit.exp | 6 +++ 5 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 testsuite/libdejagnu/unit-ccxxmix.cxx diff --git a/ChangeLog b/ChangeLog index 693f077..ce4cdc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2022-11-29 Jacob Bachmeyer + * Makefile.in: Regenerate. + * Makefile.am (check_PROGRAMS): Add testsuite/libdejagnu/unit-ccxxmix. + (testsuite_libdejagnu_unit_ccxxmix_SOURCES): Add. + * testsuite/libdejagnu/unit.exp: Add tests for C/C++ mixed usage. + * testsuite/libdejagnu/unit-ccxxmix.cxx: New file. + * testsuite/libdejagnu/unit.exp: Add note that tests for the framework side of the unit testing protocol are located in testsuite/runtest.main/stats.exp and its nested testsuite. @@ -17,7 +23,6 @@ * Makefile.am (check_PROGRAMS): Add testsuite/libdejagnu/unit-cxx. (testsuite_libdejagnu_unit_cxx_SOURCES): Add. * testsuite/libdejagnu/unit.exp: Add tests for C++ unit test API. - * testsuite/libdejagnu/unit-cxx.cxx: New file. * dejagnu.h (TestState::totals): Emit header line, like the C version. diff --git a/Makefile.am b/Makefile.am index 41243c8..41f8579 100644 --- a/Makefile.am +++ b/Makefile.am @@ -232,9 +232,11 @@ RUNTEST = ${top_srcdir}/runtest AM_CPPFLAGS = -I$(top_srcdir) check_PROGRAMS = \ testsuite/libdejagnu/unit-c \ - testsuite/libdejagnu/unit-cxx + testsuite/libdejagnu/unit-cxx \ + testsuite/libdejagnu/unit-ccxxmix testsuite_libdejagnu_unit_c_SOURCES = testsuite/libdejagnu/unit-c.c testsuite_libdejagnu_unit_cxx_SOURCES = testsuite/libdejagnu/unit-cxx.cxx +testsuite_libdejagnu_unit_ccxxmix_SOURCES = testsuite/libdejagnu/unit-ccxxmix.cxx # Documentation. diff --git a/Makefile.in b/Makefile.in index cdf958d..f6965a5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -109,7 +109,8 @@ NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : check_PROGRAMS = testsuite/libdejagnu/unit-c$(EXEEXT) \ - testsuite/libdejagnu/unit-cxx$(EXEEXT) + testsuite/libdejagnu/unit-cxx$(EXEEXT) \ + testsuite/libdejagnu/unit-ccxxmix$(EXEEXT) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac @@ -129,6 +130,11 @@ am_testsuite_libdejagnu_unit_c_OBJECTS = \ testsuite_libdejagnu_unit_c_OBJECTS = \ $(am_testsuite_libdejagnu_unit_c_OBJECTS) testsuite_libdejagnu_unit_c_LDADD = $(LDADD) +am_testsuite_libdejagnu_unit_ccxxmix_OBJECTS = \ + testsuite/libdejagnu/unit-ccxxmix.$(OBJEXT) +testsuite_libdejagnu_unit_ccxxmix_OBJECTS = \ + $(am_testsuite_libdejagnu_unit_ccxxmix_OBJECTS) +testsuite_libdejagnu_unit_ccxxmix_LDADD = $(LDADD) am_testsuite_libdejagnu_unit_cxx_OBJECTS = \ testsuite/libdejagnu/unit-cxx.$(OBJEXT) testsuite_libdejagnu_unit_cxx_OBJECTS = \ @@ -209,8 +215,10 @@ am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = SOURCES = $(testsuite_libdejagnu_unit_c_SOURCES) \ + $(testsuite_libdejagnu_unit_ccxxmix_SOURCES) \ $(testsuite_libdejagnu_unit_cxx_SOURCES) DIST_SOURCES = $(testsuite_libdejagnu_unit_c_SOURCES) \ + $(testsuite_libdejagnu_unit_ccxxmix_SOURCES) \ $(testsuite_libdejagnu_unit_cxx_SOURCES) AM_V_DVIPS = $(am__v_DVIPS_@AM_V@) am__v_DVIPS_ = $(am__v_DVIPS_@AM_DEFAULT_V@) @@ -593,6 +601,7 @@ RUNTEST = ${top_srcdir}/runtest AM_CPPFLAGS = -I$(top_srcdir) testsuite_libdejagnu_unit_c_SOURCES = testsuite/libdejagnu/unit-c.c testsuite_libdejagnu_unit_cxx_SOURCES = testsuite/libdejagnu/unit-cxx.cxx +testsuite_libdejagnu_unit_ccxxmix_SOURCES = testsuite/libdejagnu/unit-ccxxmix.cxx # Documentation. TEXINFO_TEX = doc/texinfo.tex @@ -656,6 +665,13 @@ testsuite/libdejagnu/unit-c.$(OBJEXT): \ testsuite/libdejagnu/unit-c$(EXEEXT): $(testsuite_libdejagnu_unit_c_OBJECTS) $(testsuite_libdejagnu_unit_c_DEPENDENCIES) $(EXTRA_testsuite_libdejagnu_unit_c_DEPENDENCIES) testsuite/libdejagnu/$(am__dirstamp) @rm -f testsuite/libdejagnu/unit-c$(EXEEXT) $(AM_V_CCLD)$(LINK) $(testsuite_libdejagnu_unit_c_OBJECTS) $(testsuite_libdejagnu_unit_c_LDADD) $(LIBS) +testsuite/libdejagnu/unit-ccxxmix.$(OBJEXT): \ + testsuite/libdejagnu/$(am__dirstamp) \ + testsuite/libdejagnu/$(DEPDIR)/$(am__dirstamp) + +testsuite/libdejagnu/unit-ccxxmix$(EXEEXT): $(testsuite_libdejagnu_unit_ccxxmix_OBJECTS) $(testsuite_libdejagnu_unit_ccxxmix_DEPENDENCIES) $(EXTRA_testsuite_libdejagnu_unit_ccxxmix_DEPENDENCIES) testsuite/libdejagnu/$(am__dirstamp) + @rm -f testsuite/libdejagnu/unit-ccxxmix$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(testsuite_libdejagnu_unit_ccxxmix_OBJECTS) $(testsuite_libdejagnu_unit_ccxxmix_LDADD) $(LIBS) testsuite/libdejagnu/unit-cxx.$(OBJEXT): \ testsuite/libdejagnu/$(am__dirstamp) \ testsuite/libdejagnu/$(DEPDIR)/$(am__dirstamp) @@ -742,6 +758,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@testsuite/libdejagnu/$(DEPDIR)/unit-c.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@testsuite/libdejagnu/$(DEPDIR)/unit-ccxxmix.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@testsuite/libdejagnu/$(DEPDIR)/unit-cxx.Po@am__quote@ .c.o: diff --git a/testsuite/libdejagnu/unit-ccxxmix.cxx b/testsuite/libdejagnu/unit-ccxxmix.cxx new file mode 100644 index 0000000..a57b073 --- /dev/null +++ b/testsuite/libdejagnu/unit-ccxxmix.cxx @@ -0,0 +1,78 @@ +// Exerciser for Dejagnu C/C++ unit test support library mixed usage +// +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of DejaGnu. +// +// DejaGnu is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// DejaGnu is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with DejaGnu; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. +// +// This file was written by Jacob Bachmeyer. + +// This version of the program allows verifying that the shared counters +// between the C API and the C++ API really are shared as documented. + +#include +#include + +#include +#include + +#include "dejagnu.h" + +TestState DGT; + +int +main(int argc, char ** argv) +{ + if (argc < 2) { + std::cerr <<"usage: " <..."<