mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
Show values when TEST_EQUAL fails
When TEST_EQUAL fails, show the two numerical values in the test log (only with host_test). The values are printed in hexa and signed decimal. The arguments of TEST_EQUAL must now be integers, not pointers or floats. The current implementation requires them to fit in unsigned long long Signed values no larger than long long will work too. The implementation uses unsigned long long rather than uintmax_t to reduce portability concerns. The snprintf function must support "%llx" and "%lld". For this purpose, add room for two lines of text to the mbedtls_test_info structure. This adds 154 bytes of global data. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -73,15 +73,21 @@
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
/** Evaluate two expressions and fail the test case if they have different
|
||||
* values.
|
||||
/** Evaluate two integer expressions and fail the test case if they have
|
||||
* different values.
|
||||
*
|
||||
* \param expr1 An expression to evaluate.
|
||||
* \param expr2 The expected value of \p expr1. This can be any
|
||||
* expression, but it is typically a constant.
|
||||
* The two expressions should have the same signedness, otherwise the
|
||||
* comparison is not meaningful if the signed value is negative.
|
||||
*
|
||||
* \param expr1 An integral-typed expression to evaluate.
|
||||
* \param expr2 Another integral-typed expression to evaluate.
|
||||
*/
|
||||
#define TEST_EQUAL( expr1, expr2 ) \
|
||||
TEST_ASSERT( ( expr1 ) == ( expr2 ) )
|
||||
#define TEST_EQUAL( expr1, expr2 ) \
|
||||
do { \
|
||||
if( ! mbedtls_test_equal( #expr1 " == " #expr2, __LINE__, __FILE__, \
|
||||
expr1, expr2 ) ) \
|
||||
goto exit; \
|
||||
} while( 0 )
|
||||
|
||||
/** Allocate memory dynamically and fail the test case if this fails.
|
||||
* The allocated memory will be filled with zeros.
|
||||
|
Reference in New Issue
Block a user