Skip to content

Commit

Permalink
Simplify the logic in a test
Browse files Browse the repository at this point in the history
Signed-off-by: Gilles Peskine <[email protected]>
  • Loading branch information
gilles-peskine-arm committed Aug 22, 2023
1 parent 168be01 commit 56081de
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions tests/suites/test_suite_ssl.function
Original file line number Diff line number Diff line change
Expand Up @@ -1385,19 +1385,16 @@ void ssl_crypt_record_small(int cipher_type, int hash_id,
ret = mbedtls_ssl_encrypt_buf(&ssl, t_enc, &rec,
mbedtls_test_rnd_std_rand, NULL);

if ((mode == 1 || mode == 2) && seen_success) {
TEST_ASSERT(ret == 0);
} else {
TEST_ASSERT(ret == 0 || ret == MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL);
if (ret == 0) {
seen_success = 1;
}
}

if (ret != 0) {
if (ret == MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL) {
/* It's ok if the output buffer is too small. We do insist
* on at least one mode succeeding; this is tracked by
* seen_success. */
continue;
}

TEST_EQUAL(ret, 0);
seen_success = 1;

#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
if (rec.cid_len != 0) {
/* DTLS 1.2 + CID hides the real content type and
Expand Down

0 comments on commit 56081de

Please sign in to comment.