Make filenames unique to avoid IO errors when executing two tests in parallel threads

This commit is contained in:
Andreas Fabri 2023-10-23 10:43:25 +01:00
parent a0ca27e40a
commit 28b99d55ce
1 changed files with 10 additions and 4 deletions

View File

@ -4,6 +4,7 @@
#include <cassert>
#include <CGAL/enum.h>
#include <CGAL/use.h>
#include <CGAL/Random.h>
#include <CGAL/Vector_2.h> // this is done in order to avoid error
// when the Segment_2_Segment_2_intersection.h file is included from
@ -839,24 +840,29 @@ bool test_algo_generic(InputStream& is)
// file I/O methods
//--------------------------------------------------------------------
{
std::ofstream ofs("ag_testsuite.tmp");
std::string fname = "ag_testsuite_" + std::to_string(CGAL::Random().get_seed()) + ".tmp";
std::cout << "writing to " << fname << std::endl;
std::ofstream ofs(fname);
assert( ofs );
ag.file_output(ofs);
ofs.close();
std::ifstream ifs("ag_testsuite.tmp");
std::ifstream ifs(fname);
assert( ifs );
ag.file_input(ifs);
ifs.close();
assert( ag.is_valid() );
}
{
std::ofstream ofs("ag_testsuite.tmp");
std::string fname = "ag_testsuite_" + std::to_string(CGAL::Random().get_seed()) + ".tmp";
std::cout << "writing to " << fname << std::endl;
std::ofstream ofs(fname);
assert( ofs );
ofs << ag;
ofs.close();
std::ifstream ifs("ag_testsuite.tmp");
std::ifstream ifs(fname);
assert( ifs );
ifs >> ag;
ifs.close();