Sum version, tests disabled

This commit is contained in:
Václav Valíček 2020-06-14 22:49:42 +02:00
parent bbce30caa0
commit fc8a947691
11 changed files with 40 additions and 138 deletions

22
.gitignore vendored
View File

@ -1,3 +1,4 @@
# original
.deps .deps
.dirstamp .dirstamp
Makefile Makefile
@ -16,10 +17,8 @@ missing
src/Makefile src/Makefile
src/Makefile.in src/Makefile.in
src/*.o src/*.o
src/myexecutable
stamp-h1 stamp-h1
*~ *~
myexecutable
test-driver test-driver
test-suite.log test-suite.log
tests/*.o tests/*.o
@ -34,4 +33,23 @@ full-package-name-VERSION/
*-coverage/ *-coverage/
*.gcda *.gcda
*.gcno *.gcno
# Added
libtool libtool
.libs
*.lo
*.la
main_executable
# M4???
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
# build-aux
build-aux/config.guess
build-aux/config.sub
build-aux/ltmain.sh

View File

@ -1,6 +0,0 @@
Example: http://git.savannah.gnu.org/cgit/make.git/tree/AUTHORS
GNU Coding Standards 6.3: Recording Contributors
http://www.gnu.org/prep/maintain/html_node/Recording-Contributors.html
First version of all files by Ruben Laguna <ruben.laguna at gmail.com>

View File

@ -10,10 +10,7 @@ libtest_la_LDFLAGS = -version-info 0:0:0
bin_PROGRAMS = main_executable bin_PROGRAMS = main_executable
#include .c and .h in SOURCES so that both appear in dist #include .c and .h in SOURCES so that both appear in dist
main_executable_SOURCES = \ main_executable_SOURCES = src/main.c
src/add.c \
src/add.h \
src/main.c
main_executable_CFLAGS = $(AM_CFLAGS) $(CODE_COVERAGE_CFLAGS) #--std=c11 # CFLAGS applicable to myexecutable_SOURCES main_executable_CFLAGS = $(AM_CFLAGS) $(CODE_COVERAGE_CFLAGS) #--std=c11 # CFLAGS applicable to myexecutable_SOURCES
main_executable_LDADD = libtest.la main_executable_LDADD = libtest.la
main_executable_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) main_executable_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
@ -31,13 +28,13 @@ main_executable_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
CODE_COVERAGE_IGNORE_PATTERN = tests/* CODE_COVERAGE_IGNORE_PATTERN = tests/*
CODE_COVERAGE_IGNORE_PATTERN += stdio2.h CODE_COVERAGE_IGNORE_PATTERN += stdio2.h
TESTS = add.ctaptest #TESTS = add.ctaptest
check_PROGRAMS = add.ctaptest #check_PROGRAMS = add.ctaptest
add_ctaptest_SOURCES = tests/add.c src/add.c src/add.h #add_ctaptest_SOURCES = tests/add.c src/add.c src/add.h
add_ctaptest_CPPFLAGS = $(AM_CPPFLAGS) # so that tests find the header files #add_ctaptest_CPPFLAGS = $(AM_CPPFLAGS) # so that tests find the header files
add_ctaptest_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) #add_ctaptest_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
add_ctaptest_CFLAGS = $(CODE_COVERAGE_CFLAGS) #add_ctaptest_CFLAGS = $(CODE_COVERAGE_CFLAGS)
# See http://www.gnu.org/software/automake/manual/html_node/Use-TAP-with-the-Automake-test-harness.html # See http://www.gnu.org/software/automake/manual/html_node/Use-TAP-with-the-Automake-test-harness.html

19
NEWS
View File

@ -1,19 +0,0 @@
Read GNU Coding Standards 6.7
http://www.gnu.org/prep/standards/html_node/NEWS-File.html#NEWS-File
Example: http://git.savannah.gnu.org/cgit/make.git/tree/NEWS
YourProject NEWS
History of user-visible changes
25 Jan 2015
See the end of this file for copyrights and conditions.
Version 1.0.0
* New features: XXXX
Description of the feature

76
README
View File

@ -1,76 +0,0 @@
# autotools-template
Template for an autotools (autoconf, automake) project
Introduction
============
Setting up an `Autotools` build system can be daunting. So I decided to
create a template with the basics to use as the basis for my projects.
It may be surprising to the novice that there is no `./configure` but
`./configure` is a generated file that it's shipped with the
distribution of your software (the tarball that you get `make dist`).
As such the `./configure` doesn't belong in the source control
repository. Running `autoreconf -f` will generate `./configure` and a
bunch of other files.
To build from scrath you need to perform:
autoreconf -i # Only needed if configure.ac or Makefile.am changes
./configure # generates Makefiles and config.h
make # build
make check # run the tests
I'm not an autotools expert by any means. So take my advice with a grain
of salt.
There are two input files:
* `configure.ac`: The `./configure` script will be generated from
from it. Here is were you check for libraries,
headers, etc.
* `Makefile.am`: This file will be transformed into `Makefile.in` that
`./configure` will use to generate the `Makefile`.
Regarding tests, the basic aproach is to have multiple is to run some
programs with the test and just check the exit code for those. This is
simple and functional but you only get a PASS / FAIL per executable. To
be able to get the individual tests results (asusming that there are
several , potentially hundreds, of test on a single executable) you need
to use the TAP.
The TAP aproach is that the executables that you use for test will
output the test result on standard out so that `make check` will parse
it, collect the results, and present them in a nice way.
I opted to go for the TAP approach although it requires a more complex
setup.
What to do after cloning the repository
=======================================
configure.ac
------------
Edit configure.ac to change the FULL-PACKAGE-NAME, VERSION and
BUG-REPORT-ADDRESS fields to match your project.
Makefile.am
-----------
Edit src/Makefile.am to say which "products" (executables, binaries)
will be generated and what are the source files for each one.
bin_PROGRAMS = executable1 executable2
executable1_SOURCES = sourcefile1.c sourcefile2.c
executable1_CFLAGS =
executable2_SOURCES = sourcefile3.c sourcefile4.c
executable2_CFLAGS =
Reference material
==================
Autotools: A Practitioner's Guide to GNU Autoconf, Automake, and Libtool by John Calcote
Autotools Mythbuster https://autotools.io/index.html

View File

@ -33,7 +33,6 @@ if test "x${enable_myerror}" == "xyes"; then
Results won't be real! Results won't be real!
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
]) ])
fi fi
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])

View File

@ -1,5 +0,0 @@
#include "add.h"
int add(int a, int b) {
return a + b;
}

View File

@ -1,6 +0,0 @@
#ifndef ADD_H
#define ADD_H
int add(int a,int b);
#endif /* ADD_H */

View File

@ -1,19 +1,13 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> #include <config.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
#include "test.h" #include "test.h"
#include <assert.h>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
printf ("Hello world\n"); printf ("Hello world\n");
printf ("PACKAGE " PACKAGE "\n"); printf("14 + 5 = %d\n", mysum(14, 5));
printf ("PACKAGE_BUGREPORT " PACKAGE_BUGREPORT "\n");
printf ("PACKAGE_NAME "PACKAGE_NAME "\n");
printf ("PACKAGE_STRING " PACKAGE_STRING "\n");
printf ("PACKAGE_TARNAME " PACKAGE_TARNAME "\n");
assert( 1 > 0);
return 0; return 0;
} }

View File

@ -1,6 +1,12 @@
#include <stdio.h> #include <stdio.h>
#include "test.h" #include "test.h"
void myfunc()
{ int mysum(int a, int b){
printf("myfunc() called\n"); #ifdef MYERROR
return 42;
#endif
return a + b;
} }

View File

@ -2,8 +2,8 @@
#define TEST_H #define TEST_H
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> #include <config.h>
#endif #endif
void myfunc(); int mysum(int a, int b);
#endif /* TEST_H */ #endif /* TEST_H */