Skip to content

Commit

Permalink
validation: crypto: reduce duplicate testing in different op modes
Browse files Browse the repository at this point in the history
Run time consuming algorithm combination tests only once, in async-sched,
async-plain or sync mode (in that preference order) instead of in all
the three modes, unless FULL_TEST is requested. We assume that the actual
crypto implementation being tested is the same in all the three modes so
test coverage should not suffer much.

Signed-off-by: Janne Peltonen <janne.peltonen@nokia.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
  • Loading branch information
JannePeltonen authored and MatiasElo committed Oct 19, 2023
1 parent 4858759 commit 6b7a3a5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/validation/api/crypto/odp_crypto_test_inp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,11 @@ static void test_combo_variants(odp_cipher_alg_t cipher, odp_auth_alg_t auth)

static void test_all_combinations(void)
{
if (suite_context.partial_test) {
printf("skipped ");
return;
}

printf("\n");
for (size_t n = 0; n < ARRAY_SIZE(cipher_algs); n++)
for (size_t i = 0; i < ARRAY_SIZE(auth_algs); i++)
Expand Down Expand Up @@ -1987,6 +1992,24 @@ static odp_event_t plain_compl_queue_deq(void)
return odp_queue_deq(suite_context.queue);
}

static int partial_test_only(odp_crypto_op_mode_t op_mode, odp_queue_type_t q_type)
{
odp_crypto_capability_t capa;

if (full_test || odp_crypto_capability(&capa))
return 0;

if (!capa.async_mode)
return 0;

if (op_mode == ODP_CRYPTO_SYNC)
return 1;
else if (q_type == ODP_QUEUE_TYPE_PLAIN && capa.queue_type_sched)
return 1;

return 0;
}

static int crypto_suite_packet_sync_init(void)
{
suite_context.op_mode = ODP_CRYPTO_SYNC;
Expand All @@ -1996,6 +2019,8 @@ static int crypto_suite_packet_sync_init(void)
return -1;

suite_context.queue = ODP_QUEUE_INVALID;
suite_context.partial_test = partial_test_only(suite_context.op_mode,
ODP_QUEUE_TYPE_PLAIN);
return 0;
}

Expand All @@ -2017,6 +2042,8 @@ static int crypto_suite_packet_async_plain_init(void)
suite_context.queue = out_queue;
suite_context.q_type = ODP_QUEUE_TYPE_PLAIN;
suite_context.compl_queue_deq = plain_compl_queue_deq;
suite_context.partial_test = partial_test_only(suite_context.op_mode,
suite_context.q_type);

return 0;
}
Expand All @@ -2039,6 +2066,8 @@ static int crypto_suite_packet_async_sched_init(void)
suite_context.queue = out_queue;
suite_context.q_type = ODP_QUEUE_TYPE_SCHED;
suite_context.compl_queue_deq = sched_compl_queue_deq;
suite_context.partial_test = partial_test_only(suite_context.op_mode,
suite_context.q_type);

return 0;
}
Expand Down
1 change: 1 addition & 0 deletions test/validation/api/crypto/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct suite_context_s {
odp_queue_t queue;
odp_queue_type_t q_type;
odp_event_t (*compl_queue_deq)(void);
int partial_test;
};

extern struct suite_context_s suite_context;
Expand Down

0 comments on commit 6b7a3a5

Please sign in to comment.