app/test: add cryptodev unit and performance tests

unit tests are run by using cryptodev_qat_autotest or
cryptodev_aesni_autotest from the test apps interactive console.

performance tests are run by using the cryptodev_qat_perftest or
cryptodev_aesni_mb_perftest command from the test apps interactive
console.

If you which to run the tests on a QAT device there must be one
bound to igb_uio kernel driver.

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
Signed-off-by: John Griffin <john.griffin@intel.com>
Signed-off-by: Des O Dea <des.j.o.dea@intel.com>
Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
This commit is contained in:
Declan Doherty 2015-11-25 13:25:16 +00:00 committed by Thomas Monjalon
parent 924e84f873
commit 202d375c60
10 changed files with 4217 additions and 48 deletions

View File

@ -219,6 +219,7 @@ F: scripts/test-null.sh
Crypto API
M: Declan Doherty <declan.doherty@intel.com>
F: lib/librte_cryptodev/
F: app/test/test_cryptodev*
Drivers

View File

@ -149,6 +149,10 @@ endif
SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring.c
SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring_perf.c
SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_perf.c
SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
SRCS-$(CONFIG_RTE_LIBRTE_KVARGS) += test_kvargs.c
CFLAGS += -O3

View File

@ -159,51 +159,81 @@ main(int argc, char **argv)
int
unit_test_suite_runner(struct unit_test_suite *suite)
{
int retval, i = 0;
int test_success;
unsigned total = 0, executed = 0, skipped = 0, succeeded = 0, failed = 0;
if (suite->suite_name)
printf("Test Suite : %s\n", suite->suite_name);
printf(" + ------------------------------------------------------- +\n");
printf(" + Test Suite : %s\n", suite->suite_name);
if (suite->setup)
if (suite->setup() != 0)
return -1;
goto suite_summary;
while (suite->unit_test_cases[i].testcase) {
/* Run test case setup */
if (suite->unit_test_cases[i].setup) {
retval = suite->unit_test_cases[i].setup();
if (retval != 0)
return retval;
printf(" + ------------------------------------------------------- +\n");
while (suite->unit_test_cases[total].testcase) {
if (!suite->unit_test_cases[total].enabled) {
skipped++;
total++;
continue;
} else {
executed++;
}
/* Run test case */
if (suite->unit_test_cases[i].testcase() == 0) {
printf("TestCase %2d: %s\n", i,
suite->unit_test_cases[i].success_msg ?
suite->unit_test_cases[i].success_msg :
/* run test case setup */
if (suite->unit_test_cases[total].setup)
test_success = suite->unit_test_cases[total].setup();
else
test_success = TEST_SUCCESS;
if (test_success == TEST_SUCCESS) {
/* run the test case */
test_success = suite->unit_test_cases[total].testcase();
if (test_success == TEST_SUCCESS)
succeeded++;
else
failed++;
} else {
failed++;
}
/* run the test case teardown */
if (suite->unit_test_cases[total].teardown)
suite->unit_test_cases[total].teardown();
if (test_success == TEST_SUCCESS)
printf(" + TestCase [%2d] : %s\n", total,
suite->unit_test_cases[total].success_msg ?
suite->unit_test_cases[total].success_msg :
"passed");
}
else {
printf("TestCase %2d: %s\n", i, suite->unit_test_cases[i].fail_msg ?
suite->unit_test_cases[i].fail_msg :
else
printf(" + TestCase [%2d] : %s\n", total,
suite->unit_test_cases[total].fail_msg ?
suite->unit_test_cases[total].fail_msg :
"failed");
return -1;
}
/* Run test case teardown */
if (suite->unit_test_cases[i].teardown) {
retval = suite->unit_test_cases[i].teardown();
if (retval != 0)
return retval;
}
i++;
total++;
}
/* Run test suite teardown */
if (suite->teardown)
if (suite->teardown() != 0)
return -1;
suite->teardown();
goto suite_summary;
suite_summary:
printf(" + ------------------------------------------------------- +\n");
printf(" + Test Suite Summary \n");
printf(" + Tests Total : %2d\n", total);
printf(" + Tests Skipped : %2d\n", skipped);
printf(" + Tests Executed : %2d\n", executed);
printf(" + Tests Passed : %2d\n", succeeded);
printf(" + Tests Failed : %2d\n", failed);
printf(" + ------------------------------------------------------- +\n");
if (failed)
return -1;
return 0;
}

View File

@ -33,7 +33,7 @@
#ifndef _TEST_H_
#define _TEST_H_
#include <stddef.h>
#include <sys/queue.h>
#define TEST_SUCCESS (0)
@ -64,6 +64,17 @@
} \
} while (0)
#define TEST_ASSERT_BUFFERS_ARE_EQUAL(a, b, len, msg, ...) do { \
if (memcmp(a, b, len)) { \
printf("TestCase %s() line %d failed: " \
msg "\n", __func__, __LINE__, ##__VA_ARGS__); \
TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \
return TEST_FAILED; \
} \
} while (0)
#define TEST_ASSERT_NOT_EQUAL(a, b, msg, ...) do { \
if (!(a != b)) { \
printf("TestCase %s() line %d failed: " \
@ -113,27 +124,36 @@
struct unit_test_case {
int (*setup)(void);
int (*teardown)(void);
void (*teardown)(void);
int (*testcase)(void);
const char *success_msg;
const char *fail_msg;
unsigned enabled;
};
#define TEST_CASE(fn) { NULL, NULL, fn, #fn " succeeded", #fn " failed"}
#define TEST_CASE(fn) { NULL, NULL, fn, #fn " succeeded", #fn " failed", 1 }
#define TEST_CASE_NAMED(name, fn) { NULL, NULL, fn, name " succeeded", \
name " failed"}
name " failed", 1 }
#define TEST_CASE_ST(setup, teardown, testcase) \
{ setup, teardown, testcase, #testcase " succeeded", \
#testcase " failed "}
#testcase " failed ", 1 }
#define TEST_CASES_END() { NULL, NULL, NULL, NULL, NULL }
#define TEST_CASE_DISABLED(fn) { NULL, NULL, fn, #fn " succeeded", \
#fn " failed", 0 }
#define TEST_CASE_ST_DISABLED(setup, teardown, testcase) \
{ setup, teardown, testcase, #testcase " succeeded", \
#testcase " failed ", 0 }
#define TEST_CASES_END() { NULL, NULL, NULL, NULL, NULL, 0 }
struct unit_test_suite {
const char *suite_name;
int (*setup)(void);
int (*teardown)(void);
void (*teardown)(void);
struct unit_test_case unit_test_cases[];
};

1986
app/test/test_cryptodev.c Normal file

File diff suppressed because it is too large Load Diff

68
app/test/test_cryptodev.h Normal file
View File

@ -0,0 +1,68 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2015 Intel Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TEST_CRYPTODEV_H_
#define TEST_CRYPTODEV_H_
#define HEX_DUMP 0
#define FALSE 0
#define TRUE 1
#define MAX_NUM_OPS_INFLIGHT (4096)
#define MIN_NUM_OPS_INFLIGHT (128)
#define DEFAULT_NUM_OPS_INFLIGHT (128)
#define MAX_NUM_QPS_PER_QAT_DEVICE (2)
#define DEFAULT_NUM_QPS_PER_QAT_DEVICE (2)
#define DEFAULT_BURST_SIZE (64)
#define DEFAULT_NUM_XFORMS (2)
#define NUM_MBUFS (8191)
#define MBUF_CACHE_SIZE (250)
#define MBUF_SIZE (2048 + DIGEST_BYTE_LENGTH_SHA512 + \
sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
#define BYTE_LENGTH(x) (x/8)
/* HASH DIGEST LENGTHS */
#define DIGEST_BYTE_LENGTH_MD5 (BYTE_LENGTH(128))
#define DIGEST_BYTE_LENGTH_SHA1 (BYTE_LENGTH(160))
#define DIGEST_BYTE_LENGTH_SHA224 (BYTE_LENGTH(224))
#define DIGEST_BYTE_LENGTH_SHA256 (BYTE_LENGTH(256))
#define DIGEST_BYTE_LENGTH_SHA384 (BYTE_LENGTH(384))
#define DIGEST_BYTE_LENGTH_SHA512 (BYTE_LENGTH(512))
#define DIGEST_BYTE_LENGTH_AES_XCBC (BYTE_LENGTH(96))
#define AES_XCBC_MAC_KEY_SZ (16)
#define TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 (12)
#define TRUNCATED_DIGEST_BYTE_LENGTH_SHA256 (16)
#define TRUNCATED_DIGEST_BYTE_LENGTH_SHA512 (32)
#endif /* TEST_CRYPTODEV_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -4020,7 +4020,7 @@ test_close_bonded_device(void)
return 0;
}
static int
static void
testsuite_teardown(void)
{
if (test_params->pkt_eth_hdr != NULL) {
@ -4029,7 +4029,7 @@ testsuite_teardown(void)
}
/* Clean up and remove slaves from bonded device */
return remove_slaves_and_stop_bonded_device();
remove_slaves_and_stop_bonded_device();
}
static void
@ -4993,7 +4993,7 @@ static struct unit_test_suite link_bonding_test_suite = {
TEST_CASE(test_reconfigure_bonded_device),
TEST_CASE(test_close_bonded_device),
{ NULL, NULL, NULL, NULL, NULL } /**< NULL terminate unit test array */
TEST_CASES_END() /**< NULL terminate unit test array */
}
};

View File

@ -453,7 +453,7 @@ test_setup(void)
return 0;
}
static int
static void
testsuite_teardown(void)
{
struct slave_conf *port;
@ -467,8 +467,6 @@ testsuite_teardown(void)
FOR_EACH_PORT(i, port)
rte_eth_dev_stop(port->port_id);
return 0;
}
/*
@ -1390,7 +1388,8 @@ static struct unit_test_suite link_bonding_mode4_test_suite = {
TEST_CASE_NAMED("test_mode4_tx_burst", test_mode4_tx_burst_wrapper),
TEST_CASE_NAMED("test_mode4_marker", test_mode4_marker_wrapper),
TEST_CASE_NAMED("test_mode4_expired", test_mode4_expired_wrapper),
{ NULL, NULL, NULL, NULL, NULL } /**< NULL terminate unit test array */
TEST_CASES_END() /**< NULL terminate unit test array */
}
};

View File

@ -586,7 +586,7 @@ test_setup(void)
return TEST_SUCCESS;
}
static int
static void
testsuite_teardown(void)
{
struct slave_conf *port;
@ -600,8 +600,6 @@ testsuite_teardown(void)
FOR_EACH_PORT(i, port)
rte_eth_dev_stop(port->port_id);
return 0;
}
static int
@ -661,7 +659,8 @@ static struct unit_test_suite link_bonding_rssconf_test_suite = {
TEST_CASE_NAMED("test_setup", test_setup_wrapper),
TEST_CASE_NAMED("test_rss", test_rss_wrapper),
TEST_CASE_NAMED("test_rss_lazy", test_rss_lazy_wrapper),
{ NULL, NULL, NULL, NULL, NULL } /**< NULL terminate unit test array */
TEST_CASES_END()
}
};