From 185449d25b2f9c93d2928e4745e8aa64d7d9ab9c Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Thu, 21 Feb 2019 11:26:58 -0500 Subject: [PATCH] Pull in dxcommon for library tests. Use the glib tests from dxcommon and hook up an initial Autotest-based test suite which attempts to replicate the functionality of the old (very basic) test functions. --- .gitignore | 7 +++++ .gitmodules | 3 ++ Makefile.am | 11 +++++--- atlocal.in | 12 ++++++++ bootstrap | 16 +++++++++++ common | 1 + configure.ac | 16 +++++++++-- src/str_test.c | 20 ------------- {src => t}/str.gob | 0 {src => t}/test.gob | 0 tests/general.at | 68 +++++++++++++++++++++++++++++++++++++++++++++ testsuite.at | 24 ++++++++++++++++ 12 files changed, 152 insertions(+), 26 deletions(-) create mode 100644 .gitmodules create mode 100644 atlocal.in create mode 100755 bootstrap create mode 160000 common delete mode 100644 src/str_test.c rename {src => t}/str.gob (100%) rename {src => t}/test.gob (100%) create mode 100644 tests/general.at create mode 100644 testsuite.at diff --git a/.gitignore b/.gitignore index d476b8f..cef6aa1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ .dirstamp /INSTALL /aclocal.m4 +/atconfig +/atlocal /autom4te.cache /compile /config.* @@ -14,7 +16,12 @@ /libtool /ltmain.sh /missing +/package.m4 /stamp-h1 +/testsuite +/testsuite.deps +/testsuite.dir +/testsuite.log /ylwrap Makefile Makefile.in diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a0019b3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "common"] + path = common + url = https://git.draconx.ca/dxcommon.git diff --git a/Makefile.am b/Makefile.am index 83d7b31..5e859a1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,11 +6,11 @@ # This is free software: you are free to change and redistribute it. # There is NO WARRANTY, to the extent permitted by law. -ACLOCAL_AMFLAGS = -I m4 +ACLOCAL_AMFLAGS = -I m4 -I common/m4 AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \ -I$(builddir) -I$(srcdir) -DPKGDATADIR=\"$(pkgdatadir)\" -AM_CFLAGS = $(GLIB_CFLAGS) +AM_CFLAGS = $(LIBGLIB_CFLAGS) AM_YFLAGS = -d -t bin_PROGRAMS = gob2 @@ -20,7 +20,8 @@ EXTRA_DIST = COPYING.generated-code examples/GNOME_Foo_SomeInterface.idl \ examples/gtk-button-count.gob examples/my-glade-main.c \ examples/my-glade.glade examples/my-glade.gob gob2.spec \ src/treefuncs.c src/treefuncs.h src/treefuncs.stamp \ - src/treefuncs.def src/generate_treefuncs.pl + src/treefuncs.def src/generate_treefuncs.pl \ + t/test.gob t/str.gob CLEANFILES = DISTCLEANFILES = @@ -34,7 +35,7 @@ noinst_HEADERS = src/main.h src/treefuncs.h src/out.h src/util.h src/checks.h gob2_SOURCES = src/main.c src/main.h src/treefuncs.c src/out.c src/util.c \ src/checks.c src/parse.y src/lexer.l -gob2_LDADD = $(GLIB_LIBS) @LEXLIB@ +gob2_LDADD = $(LIBGLIB_LIBS) @LEXLIB@ $(gob2_OBJECTS): src/treefuncs.h man_MANS = doc/gob2.1 @@ -84,3 +85,5 @@ uninstall-gob2-html: m4dir = $(datadir)/aclocal dist_m4_DATA = gob2.m4 + +include $(top_srcdir)/common/snippet/autotest.mk diff --git a/atlocal.in b/atlocal.in new file mode 100644 index 0000000..d169bd9 --- /dev/null +++ b/atlocal.in @@ -0,0 +1,12 @@ +: "${CC=@CC@}" +: "${CXX=@CXX@}" +: "${CPPFLAGS=@CPPFLAGS@}" +: "${CFLAGS=@CFLAGS@}" +: "${CXXFLAGS=@CXXFLAGS@}" +: "${LDFLAGS=@LDFLAGS@}" +: "${GTK_CFLAGS=@GTK_CFLAGS@}" +: "${GTK_LIBS=@GTK_LIBS@}" +: "${LIBGOBJECT_CFLAGS=@LIBGOBJECT_CFLAGS@}" +: "${LIBGOBJECT_LIBS=@LIBGOBJECT_LIBS@}" +: "${HAVE_GOBJECT=@HAVE_GOBJECT@}" +: "${HAVE_GTK2=@HAVE_GTK2@}" diff --git a/bootstrap b/bootstrap new file mode 100755 index 0000000..f9cbd41 --- /dev/null +++ b/bootstrap @@ -0,0 +1,16 @@ +#!/bin/sh + +argv0=$0 + +err () { printf '%s: %s\n' "$argv0" "$@" 1>&2; } +die () { err "$@"; exit 1; } + +: "${AUTORECONF=autoreconf}" +: "${GIT=git}" + +$GIT submodule update --init || err "Failed to update submodules from git." + +# Punt some automake-generated files so that Gentoo's wrapper script +# doesn'# try to detect the automake version in use. +rm -f Makefile.in aclocal.m4 +$AUTORECONF -fis diff --git a/common b/common new file mode 160000 index 0000000..9ade2c8 --- /dev/null +++ b/common @@ -0,0 +1 @@ +Subproject commit 9ade2c8c042ab15030d7bbb49fa97ae692a10e4f diff --git a/configure.ac b/configure.ac index f78cf39..1d66b9f 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,7 @@ AM_INIT_AUTOMAKE([-Wall subdir-objects dist-xz]) AM_SILENT_RULES([yes]) AC_PROG_CC +AC_PROG_CXX AC_PROG_LEX AC_PROG_YACC @@ -23,7 +24,18 @@ AM_CONDITIONAL([HAVE_PERL], [$PERL -e 'my $x = 42; exit $x'; test $? = 42]) LT_INIT -PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.4.0]) +DX_LIB_GLIB2 -AC_CONFIG_FILES([Makefile gob2.spec doc/gob2.1]) +dnl Dependencies for test suite +DX_LIB_GLIB2([], [gobject], [HAVE_GOBJECT=true], [HAVE_GOBJECT=false]) +AC_SUBST([HAVE_GOBJECT]) + +DX_LIB_GTK2([], [HAVE_GTK2=true], [HAVE_GTK2=false]) +AC_SUBST([HAVE_GTK2]) + +AC_CONFIG_TESTDIR([.], [t:.]) +DX_PROG_AUTOTEST +AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"]) + +AC_CONFIG_FILES([Makefile gob2.spec doc/gob2.1 atlocal]) AC_OUTPUT diff --git a/src/str_test.c b/src/str_test.c deleted file mode 100644 index 12a1be9..0000000 --- a/src/str_test.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "str.h" - -int -main (void) -{ - g_type_init (); - - int the_answer = 42; - char *stupid_pointer = "ug"; - - // This works fine. - Str *test_good = (Str *) (str_new ("%d", the_answer)); - test_good = test_good; - - // This gets a warning thanks to our function attribute. - Str *test_bad = (Str *) (str_new ("%d", stupid_pointer)); - test_bad = test_bad; - - return 0; -} diff --git a/src/str.gob b/t/str.gob similarity index 100% rename from src/str.gob rename to t/str.gob diff --git a/src/test.gob b/t/test.gob similarity index 100% rename from src/test.gob rename to t/test.gob diff --git a/tests/general.at b/tests/general.at new file mode 100644 index 0000000..355f09e --- /dev/null +++ b/tests/general.at @@ -0,0 +1,68 @@ +dnl Copyright © 2019 Nick Bowler +dnl License GPLv2+: GNU General Public License version 2 or any later version. +dnl This is free software: you are free to change and redistribute it. +dnl There is NO WARRANTY, to the extent permitted by law. + +AT_SETUP([test.gob compilation]) + +AT_CHECK([gob2 "$abs_top_srcdir/t/test.gob"]) +AT_CHECK([$HAVE_GTK2 || exit 77]) +TEST_COMPILE_GOBJECT([$GTK_CFLAGS test-object.c], [0], [], [ignore]) + +AT_CLEANUP + +AT_SETUP([test.gob C++ compilation]) + +AT_CHECK([gob2 --for-cpp "$abs_top_srcdir/t/test.gob"]) +AT_CHECK([$HAVE_GTK2 || exit 77]) +TEST_COMPILEXX_GOBJECT([$GTK_CFLAGS test-object.cc], [0], [], [ignore]) + +AT_CLEANUP + +AT_SETUP([str.gob]) + +AT_DATA([main.c], +[[#include "str.h" + +int main(void) +{ + g_type_init (); + + int the_answer = 42; + char *stupid_pointer = "ug"; + + /* This works fine. */ + Str *test_good = (Str *) (str_new ("%d", the_answer)); + test_good = test_good; + + /* This gets a warning thanks to our function attribute. */ + Str *test_bad = (Str *) (str_new ("%d", stupid_pointer)); + test_bad = test_bad; + + return 0; +} +]]) + +str_gob=$abs_top_srcdir/t/str.gob +AT_CHECK([gob2 "$str_gob"]) +TEST_COMPILE_GOBJECT([str.c], [0], [], [stderr]) +mv stderr str_stderr + +# Check for correct diagnostic messages on the target lines... +AT_CHECK([awk '/want a string/ { print NR }' "$str_gob" >str_lines]) +total=0 +exec 3