unit-tests: Call methods on IKE_SAs in their context
This commit is contained in:
parent
33e2620b8c
commit
5d97e5c30f
|
@ -39,7 +39,7 @@ START_TEST(test_regular)
|
||||||
&a, &b);
|
&a, &b);
|
||||||
}
|
}
|
||||||
assert_hook_not_called(child_updown);
|
assert_hook_not_called(child_updown);
|
||||||
a->delete_child_sa(a, PROTO_ESP, _i+1, FALSE);
|
call_ikesa(a, delete_child_sa, PROTO_ESP, _i+1, FALSE);
|
||||||
assert_child_sa_state(a, _i+1, CHILD_DELETING);
|
assert_child_sa_state(a, _i+1, CHILD_DELETING);
|
||||||
assert_hook();
|
assert_hook();
|
||||||
|
|
||||||
|
@ -57,8 +57,8 @@ START_TEST(test_regular)
|
||||||
assert_child_sa_count(a, 0);
|
assert_child_sa_count(a, 0);
|
||||||
assert_hook();
|
assert_hook();
|
||||||
|
|
||||||
a->destroy(a);
|
call_ikesa(a, destroy);
|
||||||
b->destroy(b);
|
call_ikesa(b, destroy);
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
@ -74,9 +74,9 @@ START_TEST(test_collision)
|
||||||
&a, &b);
|
&a, &b);
|
||||||
/* both peers delete the CHILD_SA concurrently */
|
/* both peers delete the CHILD_SA concurrently */
|
||||||
assert_hook_not_called(child_updown);
|
assert_hook_not_called(child_updown);
|
||||||
a->delete_child_sa(a, PROTO_ESP, 1, FALSE);
|
call_ikesa(a, delete_child_sa, PROTO_ESP, 1, FALSE);
|
||||||
assert_child_sa_state(a, 1, CHILD_DELETING);
|
assert_child_sa_state(a, 1, CHILD_DELETING);
|
||||||
b->delete_child_sa(b, PROTO_ESP, 2, FALSE);
|
call_ikesa(b, delete_child_sa, PROTO_ESP, 2, FALSE);
|
||||||
assert_child_sa_state(b, 2, CHILD_DELETING);
|
assert_child_sa_state(b, 2, CHILD_DELETING);
|
||||||
assert_hook();
|
assert_hook();
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ START_TEST(test_collision)
|
||||||
assert_child_sa_count(b, 0);
|
assert_child_sa_count(b, 0);
|
||||||
assert_hook();
|
assert_hook();
|
||||||
|
|
||||||
a->destroy(a);
|
call_ikesa(a, destroy);
|
||||||
b->destroy(b);
|
call_ikesa(b, destroy);
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
|
@ -150,8 +150,7 @@ METHOD(exchange_test_helper_t, establish_sa, void,
|
||||||
peer_cfg = create_peer_cfg(TRUE);
|
peer_cfg = create_peer_cfg(TRUE);
|
||||||
sa_i->set_peer_cfg(sa_i, peer_cfg);
|
sa_i->set_peer_cfg(sa_i, peer_cfg);
|
||||||
peer_cfg->destroy(peer_cfg);
|
peer_cfg->destroy(peer_cfg);
|
||||||
charon->bus->set_sa(charon->bus, sa_i);
|
call_ikesa(sa_i, initiate, create_child_cfg(TRUE), 0, NULL, NULL);
|
||||||
sa_i->initiate(sa_i, create_child_cfg(TRUE), 0, NULL, NULL);
|
|
||||||
/* IKE_SA_INIT --> */
|
/* IKE_SA_INIT --> */
|
||||||
id_r->set_initiator_spi(id_r, id_i->get_initiator_spi(id_i));
|
id_r->set_initiator_spi(id_r, id_i->get_initiator_spi(id_i));
|
||||||
process_message(this, sa_r, NULL);
|
process_message(this, sa_r, NULL);
|
||||||
|
|
|
@ -61,6 +61,16 @@ struct exchange_test_helper_t {
|
||||||
message_t *message);
|
message_t *message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Since we don't use the IKE_SA manager to checkout SAs use this to call a
|
||||||
|
* method on the given IKE_SA in its context.
|
||||||
|
*/
|
||||||
|
#define call_ikesa(sa, method, ...) ({ \
|
||||||
|
charon->bus->set_sa(charon->bus, sa); \
|
||||||
|
sa->method(sa, ##__VA_ARGS__); \
|
||||||
|
charon->bus->set_sa(charon->bus, NULL); \
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The one and only instance of the helper object.
|
* The one and only instance of the helper object.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue