diff options
author | Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org> | 2018-02-15 03:04:03 +0300 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2018-02-20 22:19:55 +0300 |
commit | fd22012f6f8e621fb22d5f4d6c15347f9535a902 (patch) | |
tree | 8971abc249ef11ab3d08e75b7b1c125e60317af7 /test | |
parent | c2837dee41364443bc95aa97611e3d721ef16813 (diff) |
validation: crypto: simplify test infrastructure
Merge separate file with just main() function into main test file. Merge
crypto.c file containing several small functions into test file.
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Reviewed-by: Petri Savolainen <petri.savolainen@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/validation/api/crypto/Makefile.am | 5 | ||||
-rw-r--r-- | test/validation/api/crypto/crypto.c | 135 | ||||
-rw-r--r-- | test/validation/api/crypto/crypto.h | 59 | ||||
-rw-r--r-- | test/validation/api/crypto/crypto_main.c | 14 | ||||
-rw-r--r-- | test/validation/api/crypto/odp_crypto_test_inp.c | 197 | ||||
-rw-r--r-- | test/validation/api/crypto/odp_crypto_test_inp.h | 26 |
6 files changed, 163 insertions, 273 deletions
diff --git a/test/validation/api/crypto/Makefile.am b/test/validation/api/crypto/Makefile.am index 238ce1892..cc4d49d60 100644 --- a/test/validation/api/crypto/Makefile.am +++ b/test/validation/api/crypto/Makefile.am @@ -1,10 +1,7 @@ include ../Makefile.inc test_PROGRAMS = crypto_main -crypto_main_SOURCES = crypto_main.c \ - crypto.c \ - crypto.h \ +crypto_main_SOURCES = \ odp_crypto_test_inp.c \ - odp_crypto_test_inp.h \ test_vectors.h \ test_vectors_len.h diff --git a/test/validation/api/crypto/crypto.c b/test/validation/api/crypto/crypto.c deleted file mode 100644 index 7298d544b..000000000 --- a/test/validation/api/crypto/crypto.c +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright (c) 2014, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "config.h" - -#include <odp_api.h> -#include <odp_cunit_common.h> -#include "odp_crypto_test_inp.h" -#include "crypto.h" - -#define PKT_POOL_NUM 64 -#define PKT_POOL_LEN (1 * 1024) - -odp_suiteinfo_t crypto_suites[] = { - {ODP_CRYPTO_SYNC_INP, crypto_suite_sync_init, - crypto_suite_term, crypto_suite}, - {ODP_CRYPTO_ASYNC_INP, crypto_suite_async_init, - crypto_suite_term, crypto_suite}, - {ODP_CRYPTO_PACKET_SYNC_INP, crypto_suite_packet_sync_init, - crypto_suite_term, crypto_suite}, - {ODP_CRYPTO_PACKET_ASYNC_INP, crypto_suite_packet_async_init, - crypto_suite_term, crypto_suite}, - ODP_SUITE_INFO_NULL, -}; - -int crypto_init(odp_instance_t *inst) -{ - odp_pool_param_t params; - odp_pool_t pool; - odp_queue_t out_queue; - odp_pool_capability_t pool_capa; - - if (0 != odp_init_global(inst, NULL, NULL)) { - fprintf(stderr, "error: odp_init_global() failed.\n"); - return -1; - } - - if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) { - fprintf(stderr, "error: odp_init_local() failed.\n"); - return -1; - } - - if (odp_pool_capability(&pool_capa) < 0) { - fprintf(stderr, "error: odp_pool_capability() failed.\n"); - return -1; - } - - odp_pool_param_init(¶ms); - params.pkt.seg_len = PKT_POOL_LEN; - params.pkt.len = PKT_POOL_LEN; - params.pkt.num = PKT_POOL_NUM; - params.type = ODP_POOL_PACKET; - - if (pool_capa.pkt.max_seg_len && - PKT_POOL_LEN > pool_capa.pkt.max_seg_len) { - fprintf(stderr, "Warning: small packet segment length\n"); - params.pkt.seg_len = pool_capa.pkt.max_seg_len; - } - - if (pool_capa.pkt.max_len && - PKT_POOL_LEN > pool_capa.pkt.max_len) { - fprintf(stderr, "Pool max packet length too small\n"); - return -1; - } - - pool = odp_pool_create("packet_pool", ¶ms); - - if (ODP_POOL_INVALID == pool) { - fprintf(stderr, "Packet pool creation failed.\n"); - return -1; - } - out_queue = odp_queue_create("crypto-out", NULL); - if (ODP_QUEUE_INVALID == out_queue) { - fprintf(stderr, "Crypto outq creation failed.\n"); - return -1; - } - - return 0; -} - -int crypto_term(odp_instance_t inst) -{ - odp_pool_t pool; - odp_queue_t out_queue; - - out_queue = odp_queue_lookup("crypto-out"); - if (ODP_QUEUE_INVALID != out_queue) { - if (odp_queue_destroy(out_queue)) - fprintf(stderr, "Crypto outq destroy failed.\n"); - } else { - fprintf(stderr, "Crypto outq not found.\n"); - } - - pool = odp_pool_lookup("packet_pool"); - if (ODP_POOL_INVALID != pool) { - if (odp_pool_destroy(pool)) - fprintf(stderr, "Packet pool destroy failed.\n"); - } else { - fprintf(stderr, "Packet pool not found.\n"); - } - - if (0 != odp_term_local()) { - fprintf(stderr, "error: odp_term_local() failed.\n"); - return -1; - } - - if (0 != odp_term_global(inst)) { - fprintf(stderr, "error: odp_term_global() failed.\n"); - return -1; - } - - return 0; -} - -int crypto_main(int argc, char *argv[]) -{ - int ret; - - /* parse common options: */ - if (odp_cunit_parse_options(argc, argv)) - return -1; - - odp_cunit_register_global_init(crypto_init); - odp_cunit_register_global_term(crypto_term); - - ret = odp_cunit_register(crypto_suites); - - if (ret == 0) - ret = odp_cunit_run(); - - return ret; -} diff --git a/test/validation/api/crypto/crypto.h b/test/validation/api/crypto/crypto.h deleted file mode 100644 index 078a1909f..000000000 --- a/test/validation/api/crypto/crypto.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _ODP_TEST_CRYPTO_H_ -#define _ODP_TEST_CRYPTO_H_ - -#include "odp_cunit_common.h" - -/* test functions: */ -void crypto_test_enc_alg_null(void); -void crypto_test_dec_alg_null(void); -void crypto_test_enc_alg_3des_cbc(void); -void crypto_test_enc_alg_3des_cbc_ovr_iv(void); -void crypto_test_dec_alg_3des_cbc(void); -void crypto_test_dec_alg_3des_cbc_ovr_iv(void); -void crypto_test_enc_alg_aes_cbc(void); -void crypto_test_enc_alg_aes_cbc_ovr_iv(void); -void crypto_test_dec_alg_aes_cbc(void); -void crypto_test_dec_alg_aes_cbc_ovr_iv(void); -void crypto_test_enc_alg_aes_ctr(void); -void crypto_test_enc_alg_aes_ctr_ovr_iv(void); -void crypto_test_dec_alg_aes_ctr(void); -void crypto_test_dec_alg_aes_ctr_ovr_iv(void); -void crypto_test_enc_alg_aes_gcm(void); -void crypto_test_enc_alg_aes_gcm_ovr_iv(void); -void crypto_test_dec_alg_aes_gcm(void); -void crypto_test_dec_alg_aes_gcm_ovr_iv(void); -void crypto_test_gen_alg_hmac_md5(void); -void crypto_test_check_alg_hmac_md5(void); -void crypto_test_gen_alg_hmac_sha1(void); -void crypto_test_check_alg_hmac_sha1(void); -void crypto_test_gen_alg_hmac_sha256(void); -void crypto_test_check_alg_hmac_sha256(void); -void crypto_test_gen_alg_hmac_sha512(void); -void crypto_test_check_alg_hmac_sha512(void); -void crypto_test_gen_alg_aes_gmac(void); -void crypto_test_check_alg_aes_gmac(void); - -/* test arrays: */ -extern odp_testinfo_t crypto_suite[]; - -/* test array init/term functions: */ -int crypto_suite_sync_init(void); -int crypto_suite_async_init(void); - -/* test registry: */ -extern odp_suiteinfo_t crypto_suites[]; - -/* executable init/term functions: */ -int crypto_init(odp_instance_t *inst); -int crypto_term(odp_instance_t inst); - -/* main test program: */ -int crypto_main(int argc, char *argv[]); - -#endif diff --git a/test/validation/api/crypto/crypto_main.c b/test/validation/api/crypto/crypto_main.c deleted file mode 100644 index 2d5c6c7e2..000000000 --- a/test/validation/api/crypto/crypto_main.c +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "config.h" - -#include "crypto.h" - -int main(int argc, char *argv[]) -{ - return crypto_main(argc, argv); -} diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index df1c7b6f5..ec477535f 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -10,11 +10,12 @@ #include <CUnit/Basic.h> #include <odp_cunit_common.h> #include "test_vectors.h" -#include "odp_crypto_test_inp.h" -#include "crypto.h" #define MAX_ALG_CAPA 32 +#define PKT_POOL_NUM 64 +#define PKT_POOL_LEN (1 * 1024) + struct suite_context_s { odp_bool_t packet; odp_crypto_op_mode_t op_mode; @@ -686,7 +687,7 @@ static int check_alg_null(void) } #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) -void crypto_test_enc_alg_null(void) +static void crypto_test_enc_alg_null(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_NULL, @@ -696,7 +697,7 @@ void crypto_test_enc_alg_null(void) false); } -void crypto_test_dec_alg_null(void) +static void crypto_test_dec_alg_null(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_NULL, @@ -715,7 +716,7 @@ static int check_alg_3des_cbc(void) * operation for 3DES_CBC algorithm. IV for the operation is the session IV. * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer.*/ -void crypto_test_enc_alg_3des_cbc(void) +static void crypto_test_enc_alg_3des_cbc(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_3DES_CBC, @@ -728,7 +729,7 @@ void crypto_test_enc_alg_3des_cbc(void) /* This test verifies the correctness of encode (plaintext -> ciphertext) * operation for 3DES_CBC algorithm. IV for the operation is the operation IV. * */ -void crypto_test_enc_alg_3des_cbc_ovr_iv(void) +static void crypto_test_enc_alg_3des_cbc_ovr_iv(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_3DES_CBC, @@ -743,7 +744,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_dec_alg_3des_cbc(void) +static void crypto_test_dec_alg_3des_cbc(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_3DES_CBC, @@ -758,7 +759,7 @@ void crypto_test_dec_alg_3des_cbc(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_dec_alg_3des_cbc_ovr_iv(void) +static void crypto_test_dec_alg_3des_cbc_ovr_iv(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_3DES_CBC, @@ -777,7 +778,7 @@ static int check_alg_aes_gcm(void) * operation for AES128_GCM algorithm. IV for the operation is the session IV. * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer.*/ -void crypto_test_enc_alg_aes_gcm(void) +static void crypto_test_enc_alg_aes_gcm(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_AES_GCM, @@ -791,7 +792,7 @@ void crypto_test_enc_alg_aes_gcm(void) * operation for AES128_GCM algorithm. IV for the operation is the session IV. * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer.*/ -void crypto_test_enc_alg_aes_gcm_ovr_iv(void) +static void crypto_test_enc_alg_aes_gcm_ovr_iv(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_AES_GCM, @@ -806,7 +807,7 @@ void crypto_test_enc_alg_aes_gcm_ovr_iv(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_dec_alg_aes_gcm(void) +static void crypto_test_dec_alg_aes_gcm(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_AES_GCM, @@ -821,7 +822,7 @@ void crypto_test_dec_alg_aes_gcm(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_dec_alg_aes_gcm_ovr_iv(void) +static void crypto_test_dec_alg_aes_gcm_ovr_iv(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_AES_GCM, @@ -840,7 +841,7 @@ static int check_alg_aes_cbc(void) * operation for AES128_CBC algorithm. IV for the operation is the session IV. * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer.*/ -void crypto_test_enc_alg_aes_cbc(void) +static void crypto_test_enc_alg_aes_cbc(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_AES_CBC, @@ -853,7 +854,7 @@ void crypto_test_enc_alg_aes_cbc(void) /* This test verifies the correctness of encode (plaintext -> ciphertext) * operation for AES128_CBC algorithm. IV for the operation is the operation IV. * */ -void crypto_test_enc_alg_aes_cbc_ovr_iv(void) +static void crypto_test_enc_alg_aes_cbc_ovr_iv(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_AES_CBC, @@ -868,7 +869,7 @@ void crypto_test_enc_alg_aes_cbc_ovr_iv(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_dec_alg_aes_cbc(void) +static void crypto_test_dec_alg_aes_cbc(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_AES_CBC, @@ -883,7 +884,7 @@ void crypto_test_dec_alg_aes_cbc(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_dec_alg_aes_cbc_ovr_iv(void) +static void crypto_test_dec_alg_aes_cbc_ovr_iv(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_AES_CBC, @@ -902,7 +903,7 @@ static int check_alg_aes_ctr(void) * operation for AES128_CTR algorithm. IV for the operation is the session IV. * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer.*/ -void crypto_test_enc_alg_aes_ctr(void) +static void crypto_test_enc_alg_aes_ctr(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_AES_CTR, @@ -915,7 +916,7 @@ void crypto_test_enc_alg_aes_ctr(void) /* This test verifies the correctness of encode (plaintext -> ciphertext) * operation for AES128_CTR algorithm. IV for the operation is the operation IV. * */ -void crypto_test_enc_alg_aes_ctr_ovr_iv(void) +static void crypto_test_enc_alg_aes_ctr_ovr_iv(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_AES_CTR, @@ -930,7 +931,7 @@ void crypto_test_enc_alg_aes_ctr_ovr_iv(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_dec_alg_aes_ctr(void) +static void crypto_test_dec_alg_aes_ctr(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_AES_CTR, @@ -945,7 +946,7 @@ void crypto_test_dec_alg_aes_ctr(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_dec_alg_aes_ctr_ovr_iv(void) +static void crypto_test_dec_alg_aes_ctr_ovr_iv(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_AES_CTR, @@ -967,7 +968,7 @@ static int check_alg_hmac_md5(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_gen_alg_hmac_md5(void) +static void crypto_test_gen_alg_hmac_md5(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_NULL, @@ -977,7 +978,7 @@ void crypto_test_gen_alg_hmac_md5(void) false); } -void crypto_test_check_alg_hmac_md5(void) +static void crypto_test_check_alg_hmac_md5(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_NULL, @@ -999,7 +1000,7 @@ static int check_alg_hmac_sha1(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_gen_alg_hmac_sha1(void) +static void crypto_test_gen_alg_hmac_sha1(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_NULL, @@ -1009,7 +1010,7 @@ void crypto_test_gen_alg_hmac_sha1(void) false); } -void crypto_test_check_alg_hmac_sha1(void) +static void crypto_test_check_alg_hmac_sha1(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_NULL, @@ -1031,7 +1032,7 @@ static int check_alg_hmac_sha256(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_gen_alg_hmac_sha256(void) +static void crypto_test_gen_alg_hmac_sha256(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_NULL, @@ -1041,7 +1042,7 @@ void crypto_test_gen_alg_hmac_sha256(void) false); } -void crypto_test_check_alg_hmac_sha256(void) +static void crypto_test_check_alg_hmac_sha256(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_NULL, @@ -1063,7 +1064,7 @@ static int check_alg_hmac_sha512(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_gen_alg_hmac_sha512(void) +static void crypto_test_gen_alg_hmac_sha512(void) { check_alg(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_NULL, @@ -1073,7 +1074,7 @@ void crypto_test_gen_alg_hmac_sha512(void) false); } -void crypto_test_check_alg_hmac_sha512(void) +static void crypto_test_check_alg_hmac_sha512(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_NULL, @@ -1088,7 +1089,7 @@ static int check_alg_aes_gmac(void) return check_alg_support(ODP_CIPHER_ALG_NULL, ODP_AUTH_ALG_AES_GMAC); } -void crypto_test_gen_alg_aes_gmac(void) +static void crypto_test_gen_alg_aes_gmac(void) { unsigned int test_vec_num = (sizeof(aes_gmac_reference) / sizeof(aes_gmac_reference[0])); @@ -1103,7 +1104,7 @@ void crypto_test_gen_alg_aes_gmac(void) false); } -void crypto_test_check_alg_aes_gmac(void) +static void crypto_test_check_alg_aes_gmac(void) { check_alg(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_NULL, @@ -1113,7 +1114,7 @@ void crypto_test_check_alg_aes_gmac(void) false); } -int crypto_suite_sync_init(void) +static int crypto_suite_sync_init(void) { suite_context.pool = odp_pool_lookup("packet_pool"); if (suite_context.pool == ODP_POOL_INVALID) @@ -1124,7 +1125,7 @@ int crypto_suite_sync_init(void) return 0; } -int crypto_suite_async_init(void) +static int crypto_suite_async_init(void) { suite_context.pool = odp_pool_lookup("packet_pool"); if (suite_context.pool == ODP_POOL_INVALID) @@ -1137,7 +1138,7 @@ int crypto_suite_async_init(void) return 0; } -int crypto_suite_packet_sync_init(void) +static int crypto_suite_packet_sync_init(void) { suite_context.packet = true; suite_context.op_mode = ODP_CRYPTO_SYNC; @@ -1150,7 +1151,7 @@ int crypto_suite_packet_sync_init(void) return 0; } -int crypto_suite_packet_async_init(void) +static int crypto_suite_packet_async_init(void) { suite_context.packet = true; suite_context.op_mode = ODP_CRYPTO_ASYNC; @@ -1225,7 +1226,7 @@ odp_testinfo_t crypto_suite[] = { ODP_TEST_INFO_NULL, }; -int crypto_suite_term(void) +static int crypto_suite_term(void) { int i; int first = 1; @@ -1242,3 +1243,129 @@ int crypto_suite_term(void) } return 0; } + +/* Suite names */ +#define ODP_CRYPTO_SYNC_INP "odp_crypto_sync_inp" +#define ODP_CRYPTO_ASYNC_INP "odp_crypto_async_inp" +#define ODP_CRYPTO_PACKET_SYNC_INP "odp_crypto_packet_sync_inp" +#define ODP_CRYPTO_PACKET_ASYNC_INP "odp_crypto_packet_async_inp" + +odp_suiteinfo_t crypto_suites[] = { + {ODP_CRYPTO_SYNC_INP, crypto_suite_sync_init, + crypto_suite_term, crypto_suite}, + {ODP_CRYPTO_ASYNC_INP, crypto_suite_async_init, + crypto_suite_term, crypto_suite}, + {ODP_CRYPTO_PACKET_SYNC_INP, crypto_suite_packet_sync_init, + crypto_suite_term, crypto_suite}, + {ODP_CRYPTO_PACKET_ASYNC_INP, crypto_suite_packet_async_init, + crypto_suite_term, crypto_suite}, + ODP_SUITE_INFO_NULL, +}; + +static int crypto_init(odp_instance_t *inst) +{ + odp_pool_param_t params; + odp_pool_t pool; + odp_queue_t out_queue; + odp_pool_capability_t pool_capa; + + if (0 != odp_init_global(inst, NULL, NULL)) { + fprintf(stderr, "error: odp_init_global() failed.\n"); + return -1; + } + + if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) { + fprintf(stderr, "error: odp_init_local() failed.\n"); + return -1; + } + + if (odp_pool_capability(&pool_capa) < 0) { + fprintf(stderr, "error: odp_pool_capability() failed.\n"); + return -1; + } + + odp_pool_param_init(¶ms); + params.pkt.seg_len = PKT_POOL_LEN; + params.pkt.len = PKT_POOL_LEN; + params.pkt.num = PKT_POOL_NUM; + params.type = ODP_POOL_PACKET; + + if (pool_capa.pkt.max_seg_len && + PKT_POOL_LEN > pool_capa.pkt.max_seg_len) { + fprintf(stderr, "Warning: small packet segment length\n"); + params.pkt.seg_len = pool_capa.pkt.max_seg_len; + } + + if (pool_capa.pkt.max_len && + PKT_POOL_LEN > pool_capa.pkt.max_len) { + fprintf(stderr, "Pool max packet length too small\n"); + return -1; + } + + pool = odp_pool_create("packet_pool", ¶ms); + + if (ODP_POOL_INVALID == pool) { + fprintf(stderr, "Packet pool creation failed.\n"); + return -1; + } + out_queue = odp_queue_create("crypto-out", NULL); + if (ODP_QUEUE_INVALID == out_queue) { + fprintf(stderr, "Crypto outq creation failed.\n"); + return -1; + } + + return 0; +} + +static int crypto_term(odp_instance_t inst) +{ + odp_pool_t pool; + odp_queue_t out_queue; + + out_queue = odp_queue_lookup("crypto-out"); + if (ODP_QUEUE_INVALID != out_queue) { + if (odp_queue_destroy(out_queue)) + fprintf(stderr, "Crypto outq destroy failed.\n"); + } else { + fprintf(stderr, "Crypto outq not found.\n"); + } + + pool = odp_pool_lookup("packet_pool"); + if (ODP_POOL_INVALID != pool) { + if (odp_pool_destroy(pool)) + fprintf(stderr, "Packet pool destroy failed.\n"); + } else { + fprintf(stderr, "Packet pool not found.\n"); + } + + if (0 != odp_term_local()) { + fprintf(stderr, "error: odp_term_local() failed.\n"); + return -1; + } + + if (0 != odp_term_global(inst)) { + fprintf(stderr, "error: odp_term_global() failed.\n"); + return -1; + } + + return 0; +} + +int main(int argc, char *argv[]) +{ + int ret; + + /* parse common options: */ + if (odp_cunit_parse_options(argc, argv)) + return -1; + + odp_cunit_register_global_init(crypto_init); + odp_cunit_register_global_term(crypto_term); + + ret = odp_cunit_register(crypto_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; +} diff --git a/test/validation/api/crypto/odp_crypto_test_inp.h b/test/validation/api/crypto/odp_crypto_test_inp.h deleted file mode 100644 index c50b84933..000000000 --- a/test/validation/api/crypto/odp_crypto_test_inp.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (c) 2014, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ -#ifndef ODP_CRYPTO_TEST_ASYNC_INP_ -#define ODP_CRYPTO_TEST_ASYNC_INP_ - -#include <odp_cunit_common.h> - -/* Suite names */ -#define ODP_CRYPTO_SYNC_INP "odp_crypto_sync_inp" -#define ODP_CRYPTO_ASYNC_INP "odp_crypto_async_inp" -#define ODP_CRYPTO_PACKET_SYNC_INP "odp_crypto_packet_sync_inp" -#define ODP_CRYPTO_PACKET_ASYNC_INP "odp_crypto_packet_async_inp" - -/* Suite test array */ -extern odp_testinfo_t crypto_suite[]; - -int crypto_suite_sync_init(void); -int crypto_suite_async_init(void); -int crypto_suite_packet_sync_init(void); -int crypto_suite_packet_async_init(void); -int crypto_suite_term(void); - -#endif |