wiki:pm-test-make

Table of Contents

  1. Working With the GNU Autotools
    1. Introduction
    2. The configure.ac Files
    3. The Makefile.am Files
    4. Running the Autotools
    5. Which Files Should be in the Subversion Repository?
    6. Working On Your Project
  2. Autotools Basics
    1. autoconf
    2. automake
    3. libtool
  3. Basic Structure of the configure.ac File
    1. General Concepts
    2. Beginning of a configure.ac file
    3. The Body of the configure.ac File
    4. The End of the configure.ac File
  4. The Package Base Directory configure.ac File
  5. The Project Directory configure.ac File
    1. Initialization of Tools and Compilers
    2. Check for other COIN-OR Components
    3. Checks for some specific System Libraries
    4. Check for User Libraries
    5. Generation of Links for Data Files
    6. Project Specific Tests
  6. Configuration Header Files
    1. Private and public header files
    2. Header files for non-autotools setups
    3. Bringing them all together
    4. Example
  7. Introduction of Automake Concepts
  8. The Package Base Directory Makefile.am File
  9. The Project Main Directory Makefile.am File
  10. The Source Directories Makefile.am Files
    1. Beginning of the Makefile.am File
    2. Building a Library
    3. Building a Program
    4. Additional Flags
    5. Installation of Header Files
  11. The Test Directory Makefile.am File
    1. Beginning of the File
    2. Compilation of the Unit Test Program
    3. The Test Target
    4. House Cleaning
  12. The pkg-config configuration files of a project
    1. Introduction
    2. The .pc file of an installed COIN-OR project library
    3. The .pc file of an uninstalled COIN-OR project library
    4. The NO pkg-config case
  13. Using the Correct Version of the Autotools
  14. Brief Tutorial on Switching from BuildTools 0.5 to 0.7
    1. What Needs to be Edited
    2. Externals to Dependencies
    3. Changes to Installation Directories
    4. Changes to autotools files
    5. Changes to configuration header files
  15. Hints, tricks, bugs, and suggestions
    1. Using autoreconf

The Test Directory Makefile.am File

In the test subdirectory, which should provide a unit test, the Makefile has a target test which compiles and runs the unit test.

Beginning of the File

# Copyright (C) 2011 International Icecream Machines and others.
# All Rights Reserved.
# This file is distributed under the Eclipse Public License.

## $Id: Makefile.am 788 2011-04-01 11:11:11Z johndoe $

# Author:  John Doe              IIM    2011-04-01

AUTOMAKE_OPTIONS = foreign
  • As usual, we should have some introduction with copyright note, author information, etc.

Compilation of the Unit Test Program

########################################################################
#                      unitTest for CoinUtils                          #
########################################################################

noinst_PROGRAMS = unitTest

unitTest_SOURCES = \
        CoinDenseVectorTest.cpp \
        CoinErrorTest.cpp \
        CoinIndexedVectorTest.cpp \
        CoinMessageHandlerTest.cpp \
        CoinModelTest.cpp \
        CoinMpsIOTest.cpp \
        CoinPackedMatrixTest.cpp \
        CoinPackedVectorTest.cpp \
        CoinShallowPackedVectorTest.cpp \
        unitTest.cpp

# List libraries to link into binary
unitTest_LDADD = ../src/libCoinUtils.la $(COINUTILSLIB_LIBS)

# Dependencies of binaries are mostly the same as given in LDADD, but with -l and -L removed
unitTest_DEPENDENCIES = ../src/libCoinUtils.la $(COINUTILSLIB_DEPENDENCIES)

# Here list all include flags, relative to this "srcdir" directory.
# This "cygpath" stuff is necessary to compile with native compilers on Cygwin.
AM_CPPFLAGS = -I`$(CYGPATH_W) $(srcdir)/../src`

# This line is necessary to allow VPATH compilation with MS compilers on Cygwin.
DEFAULT_INCLUDES = -I. -I`$(CYGPATH_W) $(srcdir)` -I$(top_builddir)/inc
  • The above example is taken from the CoinUtils project. It follows the same scheme as describe for the source directory Makefile.am file for defining the compilation of a program. Since we don't want to install the unitTest program, we use the noinst_ prefix for the PROGRAMS primary.

The Test Target

unittestflags =
if COIN_HAS_SAMPLE
  unittestflags += -mpsDir=`$(CYGPATH_W) $(SAMPLE_DATA)`
endif
if COIN_HAS_NETLIB
  unittestflags += -netlibDir=`$(CYGPATH_W) $(NETLIB_DATA)` -testModel=adlittle.mps
endif

test: unitTest$(EXEEXT)
        ./unitTest$(EXEEXT) $(unittestflags)

.PHONY: test
  • The test target above depends on the unitTest executable. Note the addition of the EXEEXT variable to the executable name; this variable is set to the extension of executables on the specific platform. For example, on UNIX systems it is an empty string, and on Windows it is automatically set to ".exe".

For this particular test, the executable will use files of the Data/Sample and Data/Netlib projects, if available. The paths under which the data of these projects can be found has been setup by the configure script in the project directory and stored in the SAMPLE_DATA and NETLIB_DATA variables.

House Cleaning

########################################################################
#                          Cleaning stuff                              #
########################################################################

# Here we list everything that is not generated by the compiler, e.g.,
# output files of a program

DISTCLEANFILES = yy.mps xx.mps
  • The unit test program might generate output files. It is a nice gesture to the user to make sure that everything is cleaned up, when (s)he does a make distclean. For this reason, you should list all possibly generated output files in the DISTCLEANFILES Automake variable.
Last modified 9 years ago Last modified on May 8, 2011 8:04:17 AM