test/memzone: fix wrong test
authorAnatoly Burakov <anatoly.burakov@intel.com>
Thu, 21 Dec 2017 18:19:44 +0000 (18:19 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 17 Jan 2018 23:34:37 +0000 (00:34 +0100)
When reserving memzones in autotest, it makes no sense to expect a
failed memzone reserve when we specify both size flags - instead,
we should expect a memzone reserved with one of the two sizes.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
test/test/test_memzone.c

index 01bbc4e..83c94eb 100644 (file)
@@ -260,10 +260,19 @@ test_memzone_reserve_flags(void)
                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) {
+                       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;
+                       }
                }
        }
        /*
@@ -395,10 +404,19 @@ test_memzone_reserve_flags(void)
                        mz = rte_memzone_reserve("flag_zone_16M_HINT", size,
                                SOCKET_ID_ANY,
                                RTE_MEMZONE_16MB|RTE_MEMZONE_16GB);
-                       if (mz != NULL) {
+                       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;