#include "src/mc/sosp/Snapshot.hpp"
#include <cstddef>
-#include <random>
+#include <memory>
#include <sys/mman.h>
+#include <xbt/random.hpp>
/**************** Class BOOST_tests *************************/
using simgrid::mc::Region;
mc_model_checker = nullptr;
}
- static std::default_random_engine rnd_engine;
- static std::unique_ptr<simgrid::mc::RemoteClient> process;
+ static std::unique_ptr<simgrid::mc::RemoteSimulation> process;
};
// static member variables init.
-std::default_random_engine snap_test_helper::rnd_engine;
-std::unique_ptr<simgrid::mc::RemoteClient> snap_test_helper::process = nullptr;
+std::unique_ptr<simgrid::mc::RemoteSimulation> snap_test_helper::process = nullptr;
void snap_test_helper::init_memory(void* mem, size_t size)
{
- char* dest = (char*)mem;
+ auto* dest = static_cast<char*>(mem);
for (size_t i = 0; i < size; ++i) {
- dest[i] = rnd_engine() & 255;
+ dest[i] = simgrid::xbt::random::uniform_int(0, 0xff);
}
}
REQUIRE(xbt_pagesize == getpagesize());
REQUIRE(1 << xbt_pagebits == xbt_pagesize);
- process.reset(new simgrid::mc::RemoteClient(getpid(), -1));
+ process = std::make_unique<simgrid::mc::RemoteSimulation>(getpid());
process->init();
- mc_model_checker = new ::simgrid::mc::ModelChecker(std::move(process));
+ mc_model_checker = new ::simgrid::mc::ModelChecker(std::move(process), -1);
}
snap_test_helper::prologue_return snap_test_helper::prologue(int n)
// Init memory and take snapshots:
init_memory(source, byte_size);
- simgrid::mc::Region* region0 = new simgrid::mc::Region(simgrid::mc::RegionType::Data, source, byte_size);
+ auto* region0 = new simgrid::mc::Region(simgrid::mc::RegionType::Data, source, byte_size);
for (int i = 0; i < n; i += 2) {
init_memory((char*)source + i * xbt_pagesize, xbt_pagesize);
}
- simgrid::mc::Region* region = new simgrid::mc::Region(simgrid::mc::RegionType::Data, source, byte_size);
+ auto* region = new simgrid::mc::Region(simgrid::mc::RegionType::Data, source, byte_size);
void* destination = mmap(nullptr, byte_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
INFO("Could not allocate destination memory");
prologue_return ret = prologue(n);
for (int j = 0; j != 100; ++j) {
- size_t offset = rnd_engine() % ret.size;
- size_t size = rnd_engine() % (ret.size - offset);
+ size_t offset = simgrid::xbt::random::uniform_int(0, ret.size - 1);
+ size_t size = simgrid::xbt::random::uniform_int(0, ret.size - offset - 1);
const void* read = ret.region->read(ret.dstn, (const char*)ret.src + offset, size);
INFO("Mismatch in MC_region_read()");
REQUIRE(not memcmp((char*)ret.src + offset, read, size));
prologue_return ret = prologue(n);
for (int j = 0; j != 100; ++j) {
- size_t offset = rnd_engine() % ret.size;
- size_t size = rnd_engine() % (ret.size - offset);
+ size_t offset = simgrid::xbt::random::uniform_int(0, ret.size - 1);
+ size_t size = simgrid::xbt::random::uniform_int(0, ret.size - offset - 1);
INFO("Mismatch in MC_snapshot_region_memcmp()");
REQUIRE(not MC_snapshot_region_memcmp((char*)ret.src + offset, ret.region, (char*)ret.src + offset, ret.region,