mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-30 11:54:16 +01:00
MPS Reader Tests: Request more data than what's available
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
parent
7973b2dcac
commit
7d86b74cef
@ -21,3 +21,6 @@ mbedtls_mps_reader_no_pausing_multiple_steps_multiple_rounds:0
|
||||
|
||||
MPS Reader: Multiple steps, multiple rounds, pausing enabled but unused
|
||||
mbedtls_mps_reader_no_pausing_multiple_steps_multiple_rounds:1
|
||||
|
||||
MPS Reader: Pausing needed but disabled
|
||||
mbedtls_mps_reader_pausing_needed_disabled:
|
||||
|
@ -204,3 +204,35 @@ void mbedtls_mps_reader_no_pausing_multiple_steps_multiple_rounds( int with_acc
|
||||
mbedtls_reader_free( &rd );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:TEST_SUITE_MPS_READER */
|
||||
void mbedtls_mps_reader_pausing_needed_disabled()
|
||||
{
|
||||
/* This test exercises the behaviour of the MPS reader when a read requests
|
||||
* of the consumer exceeds what has been provided by the producer, and when
|
||||
* no accumulator is available in the reader.
|
||||
*
|
||||
* In this case, we expect the reader to fail.
|
||||
*/
|
||||
|
||||
unsigned char buf[100];
|
||||
unsigned char *tmp;
|
||||
mbedtls_reader rd;
|
||||
for( int i=0; (unsigned) i < sizeof( buf ); i++ )
|
||||
buf[i] = (unsigned char) i;
|
||||
|
||||
/* Preparation (lower layer) */
|
||||
mbedtls_reader_init( &rd, NULL, 0 );
|
||||
TEST_ASSERT( mbedtls_reader_feed( &rd, buf, sizeof( buf ) ) == 0 );
|
||||
/* Consumption (upper layer) */
|
||||
TEST_ASSERT( mbedtls_reader_get( &rd, 50, &tmp, NULL ) == 0 );
|
||||
ASSERT_COMPARE( tmp, 50, buf, 50 );
|
||||
TEST_ASSERT( mbedtls_reader_commit( &rd ) == 0 );
|
||||
TEST_ASSERT( mbedtls_reader_get( &rd, 100, &tmp, NULL ) ==
|
||||
MBEDTLS_ERR_MPS_READER_OUT_OF_DATA );
|
||||
/* Wrapup (lower layer) */
|
||||
TEST_ASSERT( mbedtls_reader_reclaim( &rd, NULL ) ==
|
||||
MBEDTLS_ERR_MPS_READER_NEED_ACCUMULATOR );
|
||||
mbedtls_reader_free( &rd );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
Loading…
Reference in New Issue
Block a user