Don't run the LV commands at all if fuzzing non-linkview

This commit is contained in:
Thomas Goyne 2016-03-28 13:48:38 -07:00
parent 5eb18ed487
commit 510c049855
2 changed files with 10 additions and 0 deletions

View File

@ -67,6 +67,7 @@ static void run_commit(RealmState& state)
static void run_lv_insert(RealmState& state, size_t pos, size_t target)
{
if (!state.lv) return;
if (target < state.table.size() && pos <= state.lv->size()) {
log("lv insert %zu %zu\n", pos, target);
state.lv->insert(pos, target);
@ -75,6 +76,7 @@ static void run_lv_insert(RealmState& state, size_t pos, size_t target)
static void run_lv_set(RealmState& state, size_t pos, size_t target)
{
if (!state.lv) return;
if (target < state.table.size() && pos < state.lv->size()) {
log("lv set %zu %zu\n", pos, target);
// We can't reliably detect self-assignment for verification, so don't do it
@ -85,6 +87,7 @@ static void run_lv_set(RealmState& state, size_t pos, size_t target)
static void run_lv_move(RealmState& state, size_t from, size_t to)
{
if (!state.lv) return;
if (from < state.lv->size() && to < state.lv->size()) {
log("lv move %zu %zu\n", from, to);
// FIXME: only do the move if it has an effect to avoid getting a
@ -100,6 +103,7 @@ static void run_lv_move(RealmState& state, size_t from, size_t to)
static void run_lv_swap(RealmState& state, size_t ndx1, size_t ndx2)
{
if (!state.lv) return;
if (ndx1 < state.lv->size() && ndx2 < state.lv->size()) {
log("lv swap %zu %zu\n", ndx1, ndx2);
if (state.lv->get(ndx1).get_index() != state.lv->get(ndx2).get_index()) {
@ -114,6 +118,7 @@ static void run_lv_swap(RealmState& state, size_t ndx1, size_t ndx2)
static void run_lv_remove(RealmState& state, size_t pos)
{
if (!state.lv) return;
if (pos < state.lv->size()) {
log("lv remove %zu\n", pos);
state.lv->remove(pos);
@ -122,6 +127,7 @@ static void run_lv_remove(RealmState& state, size_t pos)
static void run_lv_remove_target(RealmState& state, size_t pos)
{
if (!state.lv) return;
if (pos < state.lv->size()) {
log("lv target remove %zu\n", pos);
state.lv->remove_target_row(pos);

View File

@ -162,7 +162,11 @@ static void test(Realm::Config const& config, SharedRealm& r, SharedRealm& r2, s
*r2,
state.coordinator,
*r2->read_group()->get_table("class_object"),
#if FUZZ_LINKVIEW
r2->read_group()->get_table("class_linklist")->get_linklist(0, 0),
#else
{},
#endif
state.uid,
{}
};