From: Tobias Brunner Date: Wed, 18 May 2016 15:15:12 +0000 (+0200) Subject: unit-tests: Match in and outbound SPIs in SA asserts X-Git-Tag: 5.5.0dr1~4^2~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d7f03dcaae3bdb8587a9d4a8f86eb91ce2438b2;p=thirdparty%2Fstrongswan.git unit-tests: Match in and outbound SPIs in SA asserts Since we use unique sequential SPIs that should be OK. --- diff --git a/src/libcharon/tests/utils/sa_asserts.h b/src/libcharon/tests/utils/sa_asserts.h index 80e390ee39..9faa2ff080 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_ @}*/