diff options
| author | Tobias Brunner <tobias@strongswan.org> | 2016-05-18 17:15:12 +0200 |
|---|---|---|
| committer | Tobias Brunner <tobias@strongswan.org> | 2016-06-17 18:48:02 +0200 |
| commit | 5d7f03dcaae3bdb8587a9d4a8f86eb91ce2438b2 (patch) | |
| tree | a90972d3d239f77c8de933736d5f8a26d5507b19 /src/libcharon/tests/utils | |
| parent | dda5aab0f491d4be64fb04166fc4f4dcb68e4880 (diff) | |
| download | strongswan-5d7f03dcaae3bdb8587a9d4a8f86eb91ce2438b2.tar.bz2 strongswan-5d7f03dcaae3bdb8587a9d4a8f86eb91ce2438b2.tar.xz | |
unit-tests: Match in and outbound SPIs in SA asserts
Since we use unique sequential SPIs that should be OK.
Diffstat (limited to 'src/libcharon/tests/utils')
| -rw-r--r-- | src/libcharon/tests/utils/sa_asserts.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/libcharon/tests/utils/sa_asserts.h b/src/libcharon/tests/utils/sa_asserts.h index 80e390ee3..9faa2ff08 100644 --- a/src/libcharon/tests/utils/sa_asserts.h +++ b/src/libcharon/tests/utils/sa_asserts.h @@ -37,14 +37,15 @@ }) /** - * Check if the CHILD_SA with the given inbound SPI is in the expected state. + * Check if the CHILD_SA with the given SPI is in the expected state. */ #define assert_child_sa_state(ike_sa, spi, state) \ ({ \ typeof(ike_sa) _sa = ike_sa; \ typeof(spi) _spi = spi; \ typeof(state) _state = state; \ - child_sa_t *_child = _sa->get_child_sa(_sa, PROTO_ESP, _spi, TRUE); \ + child_sa_t *_child = _sa->get_child_sa(_sa, PROTO_ESP, _spi, TRUE) ?: \ + _sa->get_child_sa(_sa, PROTO_ESP, _spi, FALSE); \ test_assert_msg(_child, "CHILD_SA with SPI %.8x does not exist", \ ntohl(_spi)); \ test_assert_msg(_state == _child->get_state(_child), "%N != %N", \ @@ -52,4 +53,16 @@ child_sa_state_names, _child->get_state(_child)); \ }) +/** + * Assert that the CHILD_SA with the given inbound SPI does not exist. + */ +#define assert_child_sa_not_exists(ike_sa, spi) \ +({ \ + typeof(ike_sa) _sa = ike_sa; \ + typeof(spi) _spi = spi; \ + child_sa_t *_child = _sa->get_child_sa(_sa, PROTO_ESP, _spi, TRUE) ?: \ + _sa->get_child_sa(_sa, PROTO_ESP, _spi, FALSE); \ + test_assert_msg(!_child, "CHILD_SA with SPI %.8x exists", ntohl(_spi)); \ +}) + #endif /** SA_ASSERTS_H_ @}*/ |
