Boost logo

Boost Users :

Subject: [Boost-users] (oops) Boost Test with multiple processes (MPI)
From: James Amundson (amundson_at_[hidden])
Date: 2010-07-01 12:33:17


Sorry, I accidentally hit send too early...

Does anyone have a solution for writing unit tests with Boost Test that
run in multiple processes? I am using MPI, but I think the same problem
would appear in other multi-process situations. I need some way to
collect whether, e.g., BOOST_CHECK, has passed on all processes.

Here's a simple example. I want my "example" test to fail because
should_be_true is false on process 1. What happens is that I get success
on process 0 and failure in process 1. What I want is a way to make the
test fail on all processes.

#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(example)
{
     double should_be_unity;
     const double tolerance = 1.0e-10;

     // do something that sets should_be_unity to 1.0
     // in process 0, and 1.1 in process 1.

     BOOST_CHECK_CLOSE(should_be_unity, 1.0, tolerance);
}

I then run the test with
     mpirun -np 2 ./mytest

Obviously, I could write my own tests and collect the results, but then
I couldn't use the built-in macros like BOOST_CHECK_CLOSE.

Thanks for any advice.

--Jim Amundson


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net