aboutsummaryrefslogtreecommitdiffstats
path: root/app/test
diff options
context:
space:
mode:
Diffstat (limited to 'app/test')
-rw-r--r--app/test/test.c14
-rw-r--r--app/test/test_cryptodev.c2
-rw-r--r--app/test/test_memzone.c253
-rw-r--r--app/test/test_pmd_perf.c10
-rw-r--r--app/test/test_reorder.c11
-rw-r--r--app/test/test_ring_perf.c36
-rw-r--r--app/test/test_table.c44
-rw-r--r--app/test/test_table_acl.c2
-rw-r--r--app/test/test_timer_perf.c1
9 files changed, 243 insertions, 130 deletions
diff --git a/app/test/test.c b/app/test/test.c
index cd0e7845..76941af0 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -165,8 +165,20 @@ unit_test_suite_runner(struct unit_test_suite *suite)
}
if (suite->setup)
- if (suite->setup() != 0)
+ if (suite->setup() != 0) {
+ /*
+ * setup failed, so count all enabled tests and mark
+ * them as failed
+ */
+ while (suite->unit_test_cases[total].testcase) {
+ if (!suite->unit_test_cases[total].enabled)
+ skipped++;
+ else
+ failed++;
+ total++;
+ }
goto suite_summary;
+ }
printf(" + ------------------------------------------------------- +\n");
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index b544ab9c..c9e0b66e 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -30,6 +30,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <time.h>
+
#include <rte_common.h>
#include <rte_hexdump.h>
#include <rte_mbuf.h>
diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c
index 72cda007..53be29f0 100644
--- a/app/test/test_memzone.c
+++ b/app/test/test_memzone.c
@@ -33,6 +33,7 @@
#include <stdio.h>
#include <stdint.h>
+#include <string.h>
#include <inttypes.h>
#include <sys/queue.h>
@@ -76,6 +77,8 @@
* - Check flags for specific huge page size reservation
*/
+#define TEST_MEMZONE_NAME(suffix) "MZ_TEST_" suffix
+
/* Test if memory overlaps: return 1 if true, or 0 if false. */
static int
is_memory_overlap(phys_addr_t ptr1, size_t len1, phys_addr_t ptr2, size_t len2)
@@ -92,14 +95,14 @@ test_memzone_invalid_alignment(void)
{
const struct rte_memzone * mz;
- mz = rte_memzone_lookup("invalid_alignment");
+ mz = rte_memzone_lookup(TEST_MEMZONE_NAME("invalid_alignment"));
if (mz != NULL) {
printf("Zone with invalid alignment has been reserved\n");
return -1;
}
- mz = rte_memzone_reserve_aligned("invalid_alignment", 100,
- SOCKET_ID_ANY, 0, 100);
+ mz = rte_memzone_reserve_aligned(TEST_MEMZONE_NAME("invalid_alignment"),
+ 100, SOCKET_ID_ANY, 0, 100);
if (mz != NULL) {
printf("Zone with invalid alignment has been reserved\n");
return -1;
@@ -112,14 +115,16 @@ test_memzone_reserving_zone_size_bigger_than_the_maximum(void)
{
const struct rte_memzone * mz;
- mz = rte_memzone_lookup("zone_size_bigger_than_the_maximum");
+ mz = rte_memzone_lookup(
+ TEST_MEMZONE_NAME("zone_size_bigger_than_the_maximum"));
if (mz != NULL) {
printf("zone_size_bigger_than_the_maximum has been reserved\n");
return -1;
}
- mz = rte_memzone_reserve("zone_size_bigger_than_the_maximum", (size_t)-1,
- SOCKET_ID_ANY, 0);
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("zone_size_bigger_than_the_maximum"),
+ (size_t)-1, SOCKET_ID_ANY, 0);
if (mz != NULL) {
printf("It is impossible to reserve such big a memzone\n");
return -1;
@@ -166,8 +171,8 @@ test_memzone_reserve_flags(void)
* available page size (i.e 1GB ) when 2MB pages are unavailable.
*/
if (hugepage_2MB_avail) {
- mz = rte_memzone_reserve("flag_zone_2M", size, SOCKET_ID_ANY,
- RTE_MEMZONE_2MB);
+ mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_2M"),
+ size, SOCKET_ID_ANY, RTE_MEMZONE_2MB);
if (mz == NULL) {
printf("MEMZONE FLAG 2MB\n");
return -1;
@@ -181,7 +186,8 @@ test_memzone_reserve_flags(void)
return -1;
}
- mz = rte_memzone_reserve("flag_zone_2M_HINT", size, SOCKET_ID_ANY,
+ mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_2M_HINT"),
+ size, SOCKET_ID_ANY,
RTE_MEMZONE_2MB|RTE_MEMZONE_SIZE_HINT_ONLY);
if (mz == NULL) {
printf("MEMZONE FLAG 2MB\n");
@@ -200,7 +206,9 @@ test_memzone_reserve_flags(void)
* HINT flag is indicated
*/
if (!hugepage_1GB_avail) {
- mz = rte_memzone_reserve("flag_zone_1G_HINT", size, SOCKET_ID_ANY,
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("flag_zone_1G_HINT"),
+ size, SOCKET_ID_ANY,
RTE_MEMZONE_1GB|RTE_MEMZONE_SIZE_HINT_ONLY);
if (mz == NULL) {
printf("MEMZONE FLAG 1GB & HINT\n");
@@ -215,8 +223,9 @@ test_memzone_reserve_flags(void)
return -1;
}
- mz = rte_memzone_reserve("flag_zone_1G", size, SOCKET_ID_ANY,
- RTE_MEMZONE_1GB);
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("flag_zone_1G"), size,
+ SOCKET_ID_ANY, RTE_MEMZONE_1GB);
if (mz != NULL) {
printf("MEMZONE FLAG 1GB\n");
return -1;
@@ -226,8 +235,8 @@ test_memzone_reserve_flags(void)
/*As with 2MB tests above for 1GB huge page requests*/
if (hugepage_1GB_avail) {
- mz = rte_memzone_reserve("flag_zone_1G", size, SOCKET_ID_ANY,
- RTE_MEMZONE_1GB);
+ mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_1G"),
+ size, SOCKET_ID_ANY, RTE_MEMZONE_1GB);
if (mz == NULL) {
printf("MEMZONE FLAG 1GB\n");
return -1;
@@ -241,7 +250,8 @@ test_memzone_reserve_flags(void)
return -1;
}
- mz = rte_memzone_reserve("flag_zone_1G_HINT", size, SOCKET_ID_ANY,
+ mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_1G_HINT"),
+ size, SOCKET_ID_ANY,
RTE_MEMZONE_1GB|RTE_MEMZONE_SIZE_HINT_ONLY);
if (mz == NULL) {
printf("MEMZONE FLAG 1GB\n");
@@ -260,7 +270,9 @@ test_memzone_reserve_flags(void)
* HINT flag is indicated
*/
if (!hugepage_2MB_avail) {
- mz = rte_memzone_reserve("flag_zone_2M_HINT", size, SOCKET_ID_ANY,
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("flag_zone_2M_HINT"),
+ size, SOCKET_ID_ANY,
RTE_MEMZONE_2MB|RTE_MEMZONE_SIZE_HINT_ONLY);
if (mz == NULL){
printf("MEMZONE FLAG 2MB & HINT\n");
@@ -274,25 +286,33 @@ test_memzone_reserve_flags(void)
printf("Fail memzone free\n");
return -1;
}
- mz = rte_memzone_reserve("flag_zone_2M", size, SOCKET_ID_ANY,
- RTE_MEMZONE_2MB);
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("flag_zone_2M"), size,
+ SOCKET_ID_ANY, RTE_MEMZONE_2MB);
if (mz != NULL) {
printf("MEMZONE FLAG 2MB\n");
return -1;
}
- if (rte_memzone_free(mz)) {
- printf("Fail memzone free\n");
- return -1;
- }
}
if (hugepage_2MB_avail && hugepage_1GB_avail) {
- mz = rte_memzone_reserve("flag_zone_2M_HINT", size, SOCKET_ID_ANY,
- RTE_MEMZONE_2MB|RTE_MEMZONE_1GB);
- if (mz != NULL) {
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("flag_zone_2M_HINT"),
+ size, SOCKET_ID_ANY,
+ RTE_MEMZONE_2MB|RTE_MEMZONE_1GB);
+ if (mz == NULL) {
printf("BOTH SIZES SET\n");
return -1;
}
+ if (mz->hugepage_sz != RTE_PGSIZE_1G &&
+ mz->hugepage_sz != RTE_PGSIZE_2M) {
+ printf("Wrong size when both sizes set\n");
+ return -1;
+ }
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
}
}
/*
@@ -303,8 +323,8 @@ test_memzone_reserve_flags(void)
* page size (i.e 16GB ) when 16MB pages are unavailable.
*/
if (hugepage_16MB_avail) {
- mz = rte_memzone_reserve("flag_zone_16M", size, SOCKET_ID_ANY,
- RTE_MEMZONE_16MB);
+ mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_16M"),
+ size, SOCKET_ID_ANY, RTE_MEMZONE_16MB);
if (mz == NULL) {
printf("MEMZONE FLAG 16MB\n");
return -1;
@@ -318,8 +338,10 @@ test_memzone_reserve_flags(void)
return -1;
}
- mz = rte_memzone_reserve("flag_zone_16M_HINT", size,
- SOCKET_ID_ANY, RTE_MEMZONE_16MB|RTE_MEMZONE_SIZE_HINT_ONLY);
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("flag_zone_16M_HINT"), size,
+ SOCKET_ID_ANY,
+ RTE_MEMZONE_16MB|RTE_MEMZONE_SIZE_HINT_ONLY);
if (mz == NULL) {
printf("MEMZONE FLAG 2MB\n");
return -1;
@@ -337,9 +359,11 @@ test_memzone_reserve_flags(void)
* unless HINT flag is indicated
*/
if (!hugepage_16GB_avail) {
- mz = rte_memzone_reserve("flag_zone_16G_HINT", size,
- SOCKET_ID_ANY,
- RTE_MEMZONE_16GB|RTE_MEMZONE_SIZE_HINT_ONLY);
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("flag_zone_16G_HINT"),
+ size, SOCKET_ID_ANY,
+ RTE_MEMZONE_16GB |
+ RTE_MEMZONE_SIZE_HINT_ONLY);
if (mz == NULL) {
printf("MEMZONE FLAG 16GB & HINT\n");
return -1;
@@ -353,8 +377,10 @@ test_memzone_reserve_flags(void)
return -1;
}
- mz = rte_memzone_reserve("flag_zone_16G", size,
- SOCKET_ID_ANY, RTE_MEMZONE_16GB);
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("flag_zone_16G"),
+ size,
+ SOCKET_ID_ANY, RTE_MEMZONE_16GB);
if (mz != NULL) {
printf("MEMZONE FLAG 16GB\n");
return -1;
@@ -363,8 +389,8 @@ test_memzone_reserve_flags(void)
}
/*As with 16MB tests above for 16GB huge page requests*/
if (hugepage_16GB_avail) {
- mz = rte_memzone_reserve("flag_zone_16G", size, SOCKET_ID_ANY,
- RTE_MEMZONE_16GB);
+ mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_16G"),
+ size, SOCKET_ID_ANY, RTE_MEMZONE_16GB);
if (mz == NULL) {
printf("MEMZONE FLAG 16GB\n");
return -1;
@@ -378,8 +404,10 @@ test_memzone_reserve_flags(void)
return -1;
}
- mz = rte_memzone_reserve("flag_zone_16G_HINT", size,
- SOCKET_ID_ANY, RTE_MEMZONE_16GB|RTE_MEMZONE_SIZE_HINT_ONLY);
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("flag_zone_16G_HINT"), size,
+ SOCKET_ID_ANY,
+ RTE_MEMZONE_16GB|RTE_MEMZONE_SIZE_HINT_ONLY);
if (mz == NULL) {
printf("MEMZONE FLAG 16GB\n");
return -1;
@@ -397,9 +425,11 @@ test_memzone_reserve_flags(void)
* unless HINT flag is indicated
*/
if (!hugepage_16MB_avail) {
- mz = rte_memzone_reserve("flag_zone_16M_HINT", size,
- SOCKET_ID_ANY,
- RTE_MEMZONE_16MB|RTE_MEMZONE_SIZE_HINT_ONLY);
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("flag_zone_16M_HINT"),
+ size, SOCKET_ID_ANY,
+ RTE_MEMZONE_16MB |
+ RTE_MEMZONE_SIZE_HINT_ONLY);
if (mz == NULL) {
printf("MEMZONE FLAG 16MB & HINT\n");
return -1;
@@ -412,8 +442,9 @@ test_memzone_reserve_flags(void)
printf("Fail memzone free\n");
return -1;
}
- mz = rte_memzone_reserve("flag_zone_16M", size,
- SOCKET_ID_ANY, RTE_MEMZONE_16MB);
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("flag_zone_16M"),
+ size, SOCKET_ID_ANY, RTE_MEMZONE_16MB);
if (mz != NULL) {
printf("MEMZONE FLAG 16MB\n");
return -1;
@@ -421,13 +452,23 @@ test_memzone_reserve_flags(void)
}
if (hugepage_16MB_avail && hugepage_16GB_avail) {
- mz = rte_memzone_reserve("flag_zone_16M_HINT", size,
- SOCKET_ID_ANY,
- RTE_MEMZONE_16MB|RTE_MEMZONE_16GB);
- if (mz != NULL) {
+ mz = rte_memzone_reserve(
+ TEST_MEMZONE_NAME("flag_zone_16M_HINT"),
+ size, SOCKET_ID_ANY,
+ RTE_MEMZONE_16MB|RTE_MEMZONE_16GB);
+ if (mz == NULL) {
printf("BOTH SIZES SET\n");
return -1;
}
+ if (mz->hugepage_sz != RTE_PGSIZE_16G &&
+ mz->hugepage_sz != RTE_PGSIZE_16M) {
+ printf("Wrong size when both sizes set\n");
+ return -1;
+ }
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
}
}
return 0;
@@ -470,7 +511,8 @@ test_memzone_reserve_max(void)
return 0;
}
- mz = rte_memzone_reserve("max_zone", 0, SOCKET_ID_ANY, 0);
+ mz = rte_memzone_reserve(TEST_MEMZONE_NAME("max_zone"), 0,
+ SOCKET_ID_ANY, 0);
if (mz == NULL){
printf("Failed to reserve a big chunk of memory - %s\n",
rte_strerror(rte_errno));
@@ -512,8 +554,8 @@ test_memzone_reserve_max_aligned(void)
return 0;
}
- mz = rte_memzone_reserve_aligned("max_zone_aligned", 0,
- SOCKET_ID_ANY, 0, align);
+ mz = rte_memzone_reserve_aligned(TEST_MEMZONE_NAME("max_zone_aligned"),
+ 0, SOCKET_ID_ANY, 0, align);
if (mz == NULL){
printf("Failed to reserve a big chunk of memory - %s\n",
rte_strerror(rte_errno));
@@ -550,24 +592,29 @@ test_memzone_aligned(void)
const struct rte_memzone *memzone_aligned_1024;
/* memzone that should automatically be adjusted to align on 64 bytes */
- memzone_aligned_32 = rte_memzone_reserve_aligned("aligned_32", 100,
- SOCKET_ID_ANY, 0, 32);
+ memzone_aligned_32 = rte_memzone_reserve_aligned(
+ TEST_MEMZONE_NAME("aligned_32"), 100, SOCKET_ID_ANY, 0,
+ 32);
/* memzone that is supposed to be aligned on a 128 byte boundary */
- memzone_aligned_128 = rte_memzone_reserve_aligned("aligned_128", 100,
- SOCKET_ID_ANY, 0, 128);
+ memzone_aligned_128 = rte_memzone_reserve_aligned(
+ TEST_MEMZONE_NAME("aligned_128"), 100, SOCKET_ID_ANY, 0,
+ 128);
/* memzone that is supposed to be aligned on a 256 byte boundary */
- memzone_aligned_256 = rte_memzone_reserve_aligned("aligned_256", 100,
- SOCKET_ID_ANY, 0, 256);
+ memzone_aligned_256 = rte_memzone_reserve_aligned(
+ TEST_MEMZONE_NAME("aligned_256"), 100, SOCKET_ID_ANY, 0,
+ 256);
/* memzone that is supposed to be aligned on a 512 byte boundary */
- memzone_aligned_512 = rte_memzone_reserve_aligned("aligned_512", 100,
- SOCKET_ID_ANY, 0, 512);
+ memzone_aligned_512 = rte_memzone_reserve_aligned(
+ TEST_MEMZONE_NAME("aligned_512"), 100, SOCKET_ID_ANY, 0,
+ 512);
/* memzone that is supposed to be aligned on a 1024 byte boundary */
- memzone_aligned_1024 = rte_memzone_reserve_aligned("aligned_1024", 100,
- SOCKET_ID_ANY, 0, 1024);
+ memzone_aligned_1024 = rte_memzone_reserve_aligned(
+ TEST_MEMZONE_NAME("aligned_1024"), 100, SOCKET_ID_ANY,
+ 0, 1024);
printf("check alignments and lengths\n");
if (memzone_aligned_32 == NULL) {
@@ -736,37 +783,46 @@ static int
test_memzone_bounded(void)
{
const struct rte_memzone *memzone_err;
- const char *name;
int rc;
/* should fail as boundary is not power of two */
- name = "bounded_error_31";
- if ((memzone_err = rte_memzone_reserve_bounded(name,
- 100, SOCKET_ID_ANY, 0, 32, UINT32_MAX)) != NULL) {
+ memzone_err = rte_memzone_reserve_bounded(
+ TEST_MEMZONE_NAME("bounded_error_31"), 100,
+ SOCKET_ID_ANY, 0, 32, UINT32_MAX);
+ if (memzone_err != NULL) {
printf("%s(%s)created a memzone with invalid boundary "
"conditions\n", __func__, memzone_err->name);
return -1;
}
/* should fail as len is greater then boundary */
- name = "bounded_error_32";
- if ((memzone_err = rte_memzone_reserve_bounded(name,
- 100, SOCKET_ID_ANY, 0, 32, 32)) != NULL) {
+ memzone_err = rte_memzone_reserve_bounded(
+ TEST_MEMZONE_NAME("bounded_error_32"), 100,
+ SOCKET_ID_ANY, 0, 32, 32);
+ if (memzone_err != NULL) {
printf("%s(%s)created a memzone with invalid boundary "
"conditions\n", __func__, memzone_err->name);
return -1;
}
- if ((rc = check_memzone_bounded("bounded_128", 100, 128, 128)) != 0)
+ rc = check_memzone_bounded(TEST_MEMZONE_NAME("bounded_128"), 100, 128,
+ 128);
+ if (rc != 0)
return rc;
- if ((rc = check_memzone_bounded("bounded_256", 100, 256, 128)) != 0)
+ rc = check_memzone_bounded(TEST_MEMZONE_NAME("bounded_256"), 100, 256,
+ 128);
+ if (rc != 0)
return rc;
- if ((rc = check_memzone_bounded("bounded_1K", 100, 64, 1024)) != 0)
+ rc = check_memzone_bounded(TEST_MEMZONE_NAME("bounded_1K"), 100, 64,
+ 1024);
+ if (rc != 0)
return rc;
- if ((rc = check_memzone_bounded("bounded_1K_MAX", 0, 64, 1024)) != 0)
+ rc = check_memzone_bounded(TEST_MEMZONE_NAME("bounded_1K_MAX"), 0, 64,
+ 1024);
+ if (rc != 0)
return rc;
return 0;
@@ -775,29 +831,32 @@ test_memzone_bounded(void)
static int
test_memzone_free(void)
{
- const struct rte_memzone *mz[RTE_MAX_MEMZONE];
+ const struct rte_memzone *mz[RTE_MAX_MEMZONE + 1];
int i;
char name[20];
- mz[0] = rte_memzone_reserve("tempzone0", 2000, SOCKET_ID_ANY, 0);
- mz[1] = rte_memzone_reserve("tempzone1", 4000, SOCKET_ID_ANY, 0);
+ mz[0] = rte_memzone_reserve(TEST_MEMZONE_NAME("tempzone0"), 2000,
+ SOCKET_ID_ANY, 0);
+ mz[1] = rte_memzone_reserve(TEST_MEMZONE_NAME("tempzone1"), 4000,
+ SOCKET_ID_ANY, 0);
if (mz[0] > mz[1])
return -1;
- if (!rte_memzone_lookup("tempzone0"))
+ if (!rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone0")))
return -1;
- if (!rte_memzone_lookup("tempzone1"))
+ if (!rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone1")))
return -1;
if (rte_memzone_free(mz[0])) {
printf("Fail memzone free - tempzone0\n");
return -1;
}
- if (rte_memzone_lookup("tempzone0")) {
+ if (rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone0"))) {
printf("Found previously free memzone - tempzone0\n");
return -1;
}
- mz[2] = rte_memzone_reserve("tempzone2", 2000, SOCKET_ID_ANY, 0);
+ mz[2] = rte_memzone_reserve(TEST_MEMZONE_NAME("tempzone2"), 2000,
+ SOCKET_ID_ANY, 0);
if (mz[2] > mz[1]) {
printf("tempzone2 should have gotten the free entry from tempzone0\n");
@@ -807,7 +866,7 @@ test_memzone_free(void)
printf("Fail memzone free - tempzone2\n");
return -1;
}
- if (rte_memzone_lookup("tempzone2")) {
+ if (rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone2"))) {
printf("Found previously free memzone - tempzone2\n");
return -1;
}
@@ -815,14 +874,15 @@ test_memzone_free(void)
printf("Fail memzone free - tempzone1\n");
return -1;
}
- if (rte_memzone_lookup("tempzone1")) {
+ if (rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone1"))) {
printf("Found previously free memzone - tempzone1\n");
return -1;
}
i = 0;
do {
- snprintf(name, sizeof(name), "tempzone%u", i);
+ snprintf(name, sizeof(name), TEST_MEMZONE_NAME("tempzone%u"),
+ i);
mz[i] = rte_memzone_reserve(name, 1, SOCKET_ID_ANY, 0);
} while (mz[i++] != NULL);
@@ -830,7 +890,8 @@ test_memzone_free(void)
printf("Fail memzone free - tempzone0\n");
return -1;
}
- mz[0] = rte_memzone_reserve("tempzone0new", 0, SOCKET_ID_ANY, 0);
+ mz[0] = rte_memzone_reserve(TEST_MEMZONE_NAME("tempzone0new"), 0,
+ SOCKET_ID_ANY, 0);
if (mz[0] == NULL) {
printf("Fail to create memzone - tempzone0new - when MAX memzones were "
@@ -857,16 +918,16 @@ test_memzone_basic(void)
const struct rte_memzone *memzone4;
const struct rte_memzone *mz;
- memzone1 = rte_memzone_reserve("testzone1", 100,
+ memzone1 = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone1"), 100,
SOCKET_ID_ANY, 0);
- memzone2 = rte_memzone_reserve("testzone2", 1000,
+ memzone2 = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone2"), 1000,
0, 0);
- memzone3 = rte_memzone_reserve("testzone3", 1000,
+ memzone3 = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone3"), 1000,
1, 0);
- memzone4 = rte_memzone_reserve("testzone4", 1024,
+ memzone4 = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone4"), 1024,
SOCKET_ID_ANY, 0);
/* memzone3 may be NULL if we don't have NUMA */
@@ -918,12 +979,12 @@ test_memzone_basic(void)
return -1;
printf("test zone lookup\n");
- mz = rte_memzone_lookup("testzone1");
+ mz = rte_memzone_lookup(TEST_MEMZONE_NAME("testzone1"));
if (mz != memzone1)
return -1;
printf("test duplcate zone name\n");
- mz = rte_memzone_reserve("testzone1", 100,
+ mz = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone1"), 100,
SOCKET_ID_ANY, 0);
if (mz != NULL)
return -1;
@@ -948,16 +1009,22 @@ test_memzone_basic(void)
return 0;
}
-static int memzone_calk_called;
-static void memzone_walk_clb(const struct rte_memzone *mz __rte_unused,
+static int test_memzones_left;
+static int memzone_walk_cnt;
+static void memzone_walk_clb(const struct rte_memzone *mz,
void *arg __rte_unused)
{
- memzone_calk_called = 1;
+ memzone_walk_cnt++;
+ if (!strncmp(TEST_MEMZONE_NAME(""), mz->name, RTE_MEMZONE_NAMESIZE))
+ test_memzones_left++;
}
static int
test_memzone(void)
{
+ /* take note of how many memzones were allocated before running */
+ int memzone_cnt = rte_eal_get_configuration()->mem_config->memzone_cnt;
+
printf("test basic memzone API\n");
if (test_memzone_basic() < 0)
return -1;
@@ -995,8 +1062,10 @@ test_memzone(void)
return -1;
printf("check memzone cleanup\n");
+ memzone_walk_cnt = 0;
+ test_memzones_left = 0;
rte_memzone_walk(memzone_walk_clb, NULL);
- if (memzone_calk_called) {
+ if (memzone_walk_cnt != memzone_cnt || test_memzones_left > 0) {
printf("there are some memzones left after test\n");
rte_memzone_dump(stdout);
return -1;
diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index afab180f..e0db34dc 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -321,10 +321,10 @@ alloc_lcore(uint16_t socketid)
return (uint16_t)-1;
}
-volatile uint64_t stop;
-uint64_t count;
-uint64_t drop;
-uint64_t idle;
+static volatile uint64_t stop;
+static uint64_t count;
+static uint64_t drop;
+static uint64_t idle;
static void
reset_count(void)
@@ -557,7 +557,7 @@ main_loop(__rte_unused void *args)
return 0;
}
-rte_atomic64_t start;
+static rte_atomic64_t start;
static inline int
poll_burst(void *args)
diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c
index e8a0a2f2..26dab0c2 100644
--- a/app/test/test_reorder.c
+++ b/app/test/test_reorder.c
@@ -362,9 +362,20 @@ test_setup(void)
return 0;
}
+static void
+test_teardown(void)
+{
+ rte_reorder_free(test_params->b);
+ test_params->b = NULL;
+ rte_mempool_free(test_params->p);
+ test_params->p = NULL;
+}
+
+
static struct unit_test_suite reorder_test_suite = {
.setup = test_setup,
+ .teardown = test_teardown,
.suite_name = "Reorder Unit Test Suite",
.unit_test_cases = {
TEST_CASE(test_reorder_create),
diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
index 320c20cd..b4e4daec 100644
--- a/app/test/test_ring_perf.c
+++ b/app/test/test_ring_perf.c
@@ -60,9 +60,6 @@
*/
static const volatile unsigned bulk_sizes[] = { 8, 32 };
-/* The ring structure used for tests */
-static struct rte_ring *r;
-
struct lcore_pair {
unsigned c1, c2;
};
@@ -143,7 +140,7 @@ get_two_sockets(struct lcore_pair *lcp)
/* Get cycle counts for dequeuing from an empty ring. Should be 2 or 3 cycles */
static void
-test_empty_dequeue(void)
+test_empty_dequeue(struct rte_ring *r)
{
const unsigned iter_shift = 26;
const unsigned iterations = 1<<iter_shift;
@@ -171,6 +168,7 @@ test_empty_dequeue(void)
* and return two. Input = burst size, output = cycle average for sp/sc & mp/mc
*/
struct thread_params {
+ struct rte_ring *r;
unsigned size; /* input value, the burst size */
double spsc, mpmc; /* output value, the single or multi timings */
};
@@ -185,6 +183,7 @@ enqueue_bulk(void *p)
const unsigned iter_shift = 23;
const unsigned iterations = 1<<iter_shift;
struct thread_params *params = p;
+ struct rte_ring *r = params->r;
const unsigned size = params->size;
unsigned i;
void *burst[MAX_BURST] = {0};
@@ -220,6 +219,7 @@ dequeue_bulk(void *p)
const unsigned iter_shift = 23;
const unsigned iterations = 1<<iter_shift;
struct thread_params *params = p;
+ struct rte_ring *r = params->r;
const unsigned size = params->size;
unsigned i;
void *burst[MAX_BURST] = {0};
@@ -250,7 +250,7 @@ dequeue_bulk(void *p)
* used to measure ring perf between hyperthreads, cores and sockets.
*/
static void
-run_on_core_pair(struct lcore_pair *cores,
+run_on_core_pair(struct lcore_pair *cores, struct rte_ring *r,
lcore_function_t f1, lcore_function_t f2)
{
struct thread_params param1 = {0}, param2 = {0};
@@ -258,6 +258,7 @@ run_on_core_pair(struct lcore_pair *cores,
for (i = 0; i < sizeof(bulk_sizes)/sizeof(bulk_sizes[0]); i++) {
lcore_count = 0;
param1.size = param2.size = bulk_sizes[i];
+ param1.r = param2.r = r;
if (cores->c1 == rte_get_master_lcore()) {
rte_eal_remote_launch(f2, &param2, cores->c2);
f1(&param1);
@@ -280,7 +281,7 @@ run_on_core_pair(struct lcore_pair *cores,
* takes on a single lcore. Result is for comparison with the bulk enq+deq.
*/
static void
-test_single_enqueue_dequeue(void)
+test_single_enqueue_dequeue(struct rte_ring *r)
{
const unsigned iter_shift = 24;
const unsigned iterations = 1<<iter_shift;
@@ -313,7 +314,7 @@ test_single_enqueue_dequeue(void)
* as for the bulk function called on a single lcore.
*/
static void
-test_burst_enqueue_dequeue(void)
+test_burst_enqueue_dequeue(struct rte_ring *r)
{
const unsigned iter_shift = 23;
const unsigned iterations = 1<<iter_shift;
@@ -347,7 +348,7 @@ test_burst_enqueue_dequeue(void)
/* Times enqueue and dequeue on a single lcore */
static void
-test_bulk_enqueue_dequeue(void)
+test_bulk_enqueue_dequeue(struct rte_ring *r)
{
const unsigned iter_shift = 23;
const unsigned iterations = 1<<iter_shift;
@@ -385,32 +386,35 @@ static int
test_ring_perf(void)
{
struct lcore_pair cores;
+ struct rte_ring *r = NULL;
+
r = rte_ring_create(RING_NAME, RING_SIZE, rte_socket_id(), 0);
- if (r == NULL && (r = rte_ring_lookup(RING_NAME)) == NULL)
+ if (r == NULL)
return -1;
printf("### Testing single element and burst enq/deq ###\n");
- test_single_enqueue_dequeue();
- test_burst_enqueue_dequeue();
+ test_single_enqueue_dequeue(r);
+ test_burst_enqueue_dequeue(r);
printf("\n### Testing empty dequeue ###\n");
- test_empty_dequeue();
+ test_empty_dequeue(r);
printf("\n### Testing using a single lcore ###\n");
- test_bulk_enqueue_dequeue();
+ test_bulk_enqueue_dequeue(r);
if (get_two_hyperthreads(&cores) == 0) {
printf("\n### Testing using two hyperthreads ###\n");
- run_on_core_pair(&cores, enqueue_bulk, dequeue_bulk);
+ run_on_core_pair(&cores, r, enqueue_bulk, dequeue_bulk);
}
if (get_two_cores(&cores) == 0) {
printf("\n### Testing using two physical cores ###\n");
- run_on_core_pair(&cores, enqueue_bulk, dequeue_bulk);
+ run_on_core_pair(&cores, r, enqueue_bulk, dequeue_bulk);
}
if (get_two_sockets(&cores) == 0) {
printf("\n### Testing using two NUMA nodes ###\n");
- run_on_core_pair(&cores, enqueue_bulk, dequeue_bulk);
+ run_on_core_pair(&cores, r, enqueue_bulk, dequeue_bulk);
}
+ rte_ring_free(r);
return 0;
}
diff --git a/app/test/test_table.c b/app/test/test_table.c
index 1faa0a6d..31eac117 100644
--- a/app/test/test_table.c
+++ b/app/test/test_table.c
@@ -83,6 +83,14 @@ uint64_t pipeline_test_hash(void *key,
}
static void
+app_free_resources(void) {
+ int i;
+ for (i = 0; i < N_PORTS; i++)
+ rte_ring_free(rings_rx[i]);
+ rte_mempool_free(pool);
+}
+
+static void
app_init_mbuf_pools(void)
{
/* Init the buffer pool */
@@ -141,18 +149,20 @@ app_init_rings(void)
static int
test_table(void)
{
- int status, failures;
+ int status, ret;
unsigned i;
- failures = 0;
+ ret = TEST_SUCCESS;
app_init_rings();
app_init_mbuf_pools();
printf("\n\n\n\n************Pipeline tests************\n");
- if (test_table_pipeline() < 0)
- return -1;
+ if (test_table_pipeline() < 0) {
+ ret = TEST_FAILED;
+ goto end;
+ }
printf("\n\n\n\n************Port tests************\n");
for (i = 0; i < n_port_tests; i++) {
@@ -160,8 +170,8 @@ test_table(void)
if (status < 0) {
printf("\nPort test number %d failed (%d).\n", i,
status);
- failures++;
- return -1;
+ ret = TEST_FAILED;
+ goto end;
}
}
@@ -171,8 +181,8 @@ test_table(void)
if (status < 0) {
printf("\nTable test number %d failed (%d).\n", i,
status);
- failures++;
- return -1;
+ ret = TEST_FAILED;
+ goto end;
}
}
@@ -182,21 +192,23 @@ test_table(void)
if (status < 0) {
printf("\nCombined table test number %d failed with "
"reason number %d.\n", i, status);
- failures++;
- return -1;
+ ret = TEST_FAILED;
+ goto end;
}
}
- if (failures)
- return -1;
-
#ifdef RTE_LIBRTE_ACL
printf("\n\n\n\n************ACL tests************\n");
- if (test_table_acl() < 0)
- return -1;
+ if (test_table_acl() < 0) {
+ ret = TEST_FAILED;
+ goto end;
+ }
#endif
- return 0;
+end:
+ app_free_resources();
+
+ return ret;
}
REGISTER_TEST_COMMAND(table_autotest, test_table);
diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index b3bfda4c..a5d44c5b 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -532,6 +532,8 @@ setup_acl_pipeline(void)
struct rte_pipeline_table_entry *table_entries[5];
int key_found[5];
+ memset(table_entries, 0, sizeof(table_entries));
+
for (n = 0; n < 5; n++) {
memset(&keys[n], 0, sizeof(struct rte_table_acl_rule_delete_params));
key_array[n] = &keys[n];
diff --git a/app/test/test_timer_perf.c b/app/test/test_timer_perf.c
index fa77efbd..f6bbdf33 100644
--- a/app/test/test_timer_perf.c
+++ b/app/test/test_timer_perf.c
@@ -155,6 +155,7 @@ test_timer_perf(void)
printf("Time per rte_timer_manage with zero callbacks: %"PRIu64" cycles\n",
(end_tsc - start_tsc + iterations/2) / iterations);
+ rte_free(tms);
return 0;
}