diff options
author | Pauli <paul.dale@oracle.com> | 2017-04-13 08:51:28 +1000 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-04-13 08:33:12 -0400 |
commit | d063add7cbdaf82e6208ef01414432320260e974 (patch) | |
tree | 794ad8006e58650653d962c8ae692efdd36e4a78 /test/README | |
parent | a24c1e224338ccd3d2b831bd2e3ba52a1eb31f01 (diff) |
Guarantee single argument evaluation for test macros.
Add test case that checks some of them.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3208)
Diffstat (limited to 'test/README')
-rw-r--r-- | test/README | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/README b/test/README index cf7e4d4948..7831c860f5 100644 --- a/test/README +++ b/test/README @@ -134,4 +134,16 @@ conditions. These macros produce an error message in a standard format if the condition is not met (and nothing if the condition is met). Additional information can be presented with the TEST_info macro that takes a printf format string and arguments. TEST_error is useful for complicated conditions, -it also takes a printf format string and argument. +it also takes a printf format string and argument. In all cases the TEST_xxx +macros are guaranteed to evaluate their arguments exactly once. This means +that expressions with side effects are allowed as parameters. Thus, + + if (!TEST_ptr(ptr = OPENSSL_malloc(..))) + +works fine and can be used in place of: + + ptr = OPENSSL_malloc(..); + if (!TEST_ptr(ptr)) + +The former produces a more meaningful message on failure than the latter. + |