6

My unit testing requires running a lot of BOOST_CHECK_CLOSE calls, which are taking a very long time (on one thread as far as I can tell). I would like to be able to do something along these lines:

#pragma omp parallel for num_threads(8)
for (int i=0; i<ARRAY_SIZE; i++) {
    BOOST_CHECK_CLOSE(array1[i], array2[i], tolerance);
}

However, when I try this some very nasty memory corruption out of my control seems to happen. Segfaults most commonly, but sometimes this instead:

*** stack smashing detected ***

Has anyone got some experience of a good way to achieve my intended result which they could share? I'm sure everyone would appreciate having their tests running fast!

daft_wader
  • 61
  • 1
  • 3

2 Answers2

3

It cannot as mentionned here (item 3)

http://www.boost.org/doc/libs/1_57_0/libs/test/doc/html/open-issues.html

See the full discussion here:

Is there a way to run C++ Unit Tests tests in parallel?

Community
  • 1
  • 1
Gabriel
  • 3,564
  • 1
  • 27
  • 49
1

Workaround: replace your boost calls with some local logic, collect all failures and report at the end.

since you are concerned about performance, invoking the BOOST_CHECK machinery in such a tight loop is probably a suboptimal idea anyway.

Martin Ba
  • 37,187
  • 33
  • 183
  • 337