Wednesday 15 August 2012

c++ - How to add test unit to a shared library project using autotools -


I am developing a library that should be counted too much. This uses the GNU autotools build system. Is an exam project which links to this library and runs various test procedures. Each process compares results with pre-calculated values ​​from MATLAB.

I found that the testing process is boring and time-consuming. Every time I need to create create , sudo in the library and in the create test project, then run the program and see what's happening.

What is the standard way to add check target to a library using autotools? It must meet this requirement:

  1. User should be able to check and libraries compiled see results without having to set up self-executable recently , And link to non-installed shared objects.
  2. Run Check should also run the testing program. (Not only compile it) The result of the Check depends on the price of the test unit program. Makeup should be shown if the test unit is unsuccessful.
  3. If the user decides to not , then no executable should be compiled.

    Since you are already using autotools, you already have most of the infrastructure I do not know the directory layout, but let's say that you have: SUBDIRS = soroush test at the top level Makefile.am Alternatively, maybe there is a soroush directory in SUBDIRS = tests . What is the matter is that there is a libtool-managed libsoroush.la before it comes to the test directory.

    prefix Czech _ indicates those objects that, program in this case , unless the make is run Should not be made until then. Then in trials / makefile.M = & gt; check_PROGRAMS = t1 t2 t3

    For each test program you can specify: t1_SOURCES = t1.cc , etc. As a shortcut, if you have a trial within a source file, you can use AM_DEFAULT_SOURCE_EXT = .cc , which will generate the source for you so far: < Previous> AM_CPPFLAGS = -I $ (srcdir) / .. $ (OTHER_CPPFLAGS) # Relative Path for Lib Headers. LDADD = ../soroush/libsoroush.la check_PROGRAMS = t1 t2 t3 AM_DEFAULT_SOURCE_EXT = .cc # or: t1_SOURCES = t1.cc, t1_LDADD = ../soroush/libsoroush.la, etc.

    Check will be created, but not executed, those programs.

      test = $ (check_PROGRAMS)   

    What is really good about this approach is that if libsoroush to be built as a shared library, using the uninstalled library, the library search path, etc. will be kept in mind to handle Liboots.

    Often, the resulting t1 program is just a shell script that sets the environment variable so that real will be binary: .libs / t1 can be implemented. I only mention it because the whole issue of using libtool is that you do not have to worry about how it happened.


    Test response is more complex, depending on what you need. You can go all the way with tapping with parallel test, or just by simple PASS / FAIL intensity until the test is a major bottleneck, or the project is huge, it only tests (or screenplay) to test. is easy

No comments:

Post a Comment