Running boost unit test in cling

has anyone tried using the boost unit test framework (UTF) in cling?
Assuming that you know the boost UTF -
I tried :

  1. using the version where all the code is in the header files (see boost.org/doc/libs/1_42_0/li … riant.html )
  2. also linking into the boost binaries when I run cling .
    cling -std=c++11 -I /opt/local/include etc

and runnning the following code (simple example from boost website)

#define BOOST_TEST_MODULE MyTest
#include <boost/test/included/unit_test.hpp>

int add (int i, int j) { return i + j ; }

BOOST_AUTO_TEST_CASE( my_test ) {
        BOOST_CHECK ( add(2,2) == 6 ) ;
}

This compiles links and runs using clang but the cling interpreter seems to struggle with the macro implementation in 1) and won’t run when loaded using .x or .L in case 2) .

My guess is that it’s looking for main in 2) - but the main function expects three arguments - a function pointer , argc = 1 and argv[0] path to the binary as far as I can tell.
Subsidiary question - Is it possible to pass function pointers around on the command line in cling.

Context:
I’m trying to write a unit test library to demonstrate std lib code for training purposes, the idea being that you fix the tests to learn the various features of algos strings etc etc . I am trying out cling so that a REPL approach can be used as an alternative to the time consuming way of compiling and linking.

NB I’ve found cling very useful in getting up to speed with c++ after a break. Great job!

Hi,
I am not sure, what happens here: could you come up with a standalone reproducer? Also could you show what are the output/errors you are getting?

Yes, cling supports full set of C++ so you should be able to work with function pointers at the prompt. (This is a generic answer to a generic question, if not sufficient please narrow it down)

Vassil

Hi,

What are the error messages / symptoms of the failure?

Cheers, Axel.

Hi steps to generate errors as follows - example code and error output attached

  1. header only version built as follows:
    booststuff.cpp (179 Bytes)
    c++ booststuff.cpp -std=c++11 -I /opt/local/include -o booststuff

output of ./booststuff below:

Running 1 test case…
booststuff.cpp:6: error: in “my_test”: check 2 == 6 has failed

*** 1 failure is detected in the test module “MyTest"

  1. running same code via cling as follows:
    cat booststuff.cpp | cling -std=c++11 -I /opt/local/include 2> include_only_errors
    include_only_errors.txt (2.77 KB)
  2. to check to see whether there was a problem with loading complex macros I built and linked to boost libs as follows:
    booststuff_dyn.cpp (168 Bytes)
    c++ booststuff_dyn.cpp -std=c++11 -I /opt/local/include -o booststuff_dyn -L /opt/local/lib -lboost_unit_test_framework-mt

the compiled binary version generates the same output as above

  1. running as cling as follows:

cat booststuff_dyn.cpp | cling -std=c++11 -I /opt/local/include -L /opt/local/lib -lboost_unit_test_framework-mt 2> dynlinked_errors
dynlinked_errors.txt (2.77 KB)

I’m running a binary downloaded from ecsft.cern.ch/dist/cling/current/ 17th Sep on MacosX 10.10.4 (cling-MacOSX-10.9-13218860da)