#include <cstdlib>
#include <cstring>
+#include <random>
#include <sys/mman.h>
mc_model_checker = nullptr;
}
+ static std::default_random_engine rnd_engine;
static bool sparse_checkpoint;
static std::unique_ptr<simgrid::mc::RemoteClient> process;
};
// static member variables init.
+std::default_random_engine snap_test_helper::rnd_engine;
bool snap_test_helper::sparse_checkpoint = 0;
std::unique_ptr<simgrid::mc::RemoteClient> snap_test_helper::process = nullptr;
{
char* dest = (char*)mem;
for (size_t i = 0; i < size; ++i) {
- dest[i] = rand() & 255;
+ dest[i] = rnd_engine() & 255;
}
}
prologue_return ret = prologue(n);
for (int j = 0; j != 100; ++j) {
- size_t offset = rand() % ret.size;
- size_t size = rand() % (ret.size - offset);
+ size_t offset = rnd_engine() % ret.size;
+ size_t size = rnd_engine() % (ret.size - offset);
const void* read = MC_region_read(&(ret.region), 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 = rand() % ret.size;
- size_t size = rand() % (ret.size - offset);
+ size_t offset = rnd_engine() % ret.size;
+ size_t size = rnd_engine() % (ret.size - offset);
INFO("Mismatch in MC_snapshot_region_memcmp()");
REQUIRE(not MC_snapshot_region_memcmp((char*)ret.src + offset, &(ret.region), (char*)ret.src + offset,
#include "simgrid/Exception.hpp"
#include <cstdio>
#include <cstring>
+#include <random>
#include "catch.hpp"
SECTION("Crash test")
{
- srand((unsigned int)time(nullptr));
+ std::random_device rd;
+ std::default_random_engine rnd_engine(rd());
for (int i = 0; i < 10; i++) {
INFO("CRASH test number " << i + 1 << " (" << 10 - i - 1 << " to go)");
do {
for (int k = 0; k < SIZEOFKEY - 1; k++) {
- key[k] = rand() % ('z' - 'a') + 'a';
+ key[k] = rnd_engine() % ('z' - 'a') + 'a';
}
key[SIZEOFKEY - 1] = '\0';
data = (char*)xbt_dict_get_or_null(head, key);
#include <cassert>
#include <cstdlib>
#include <cstring>
+#include <random>
#include "src/mc/mc_private.hpp"
#include "src/mc/Variable.hpp"
#include "src/mc/remote/RemoteClient.hpp"
+static std::default_random_engine rnd_engine;
+
static simgrid::mc::RemoteClient* process;
static
Dwarf_Op ops[60];
- uintptr_t a = rand();
- uintptr_t b = rand();
+ uintptr_t a = rnd_engine();
+ uintptr_t b = rnd_engine();
simgrid::dwarf::ExpressionStack stack;
basic_test(state);
for(int i=0; i!=100; ++i) {
- uintptr_t a = rand();
- uintptr_t b = rand();
+ uintptr_t a = rnd_engine();
+ uintptr_t b = rnd_engine();
assert(eval_binary_operation(state, DW_OP_plus, a, b) == (a + b));
}
for(int i=0; i!=100; ++i) {
- uintptr_t a = rand();
- uintptr_t b = rand();
+ uintptr_t a = rnd_engine();
+ uintptr_t b = rnd_engine();
assert(eval_binary_operation(state, DW_OP_or, a, b) == (a | b));
}
for(int i=0; i!=100; ++i) {
- uintptr_t a = rand();
- uintptr_t b = rand();
+ uintptr_t a = rnd_engine();
+ uintptr_t b = rnd_engine();
assert(eval_binary_operation(state, DW_OP_and, a, b) == (a & b));
}
for(int i=0; i!=100; ++i) {
- uintptr_t a = rand();
- uintptr_t b = rand();
+ uintptr_t a = rnd_engine();
+ uintptr_t b = rnd_engine();
assert(eval_binary_operation(state, DW_OP_xor, a, b) == (a ^ b));
}