From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 936B4A32A4 for ; Fri, 25 Oct 2019 15:58:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B97DF1C2DB; Fri, 25 Oct 2019 15:57:16 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id 0079D1C28F for ; Fri, 25 Oct 2019 15:57:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572011824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rj0wf0y/hjR0vXOWAbuGlyg769z/8RHbgarM48YsXZw=; b=LnB6ZAhZYRFBKa5FFChJwwsmZugeHoddG37kkbW+r3dx6YUr0RSBb6ahjrI2jNgZ581ib8 nfa6O8nHckWvHM2nDXF0+hwJZ3Ou+va4V64WP/TuOQv7w4/V4vYvsLCZ9GQHdSrPdG3zsA R6LyZ+0uwf2rokKXlLVWGmeoqXKSKpM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-47-u7PWs1GXMEC0cXUlMrYZVA-1; Fri, 25 Oct 2019 09:56:59 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9819D801E5C; Fri, 25 Oct 2019 13:56:58 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-204-129.brq.redhat.com [10.40.204.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0496810013D9; Fri, 25 Oct 2019 13:56:56 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stephen@networkplumber.org, anatoly.burakov@intel.com, thomas@monjalon.net, ktraynor@redhat.com Date: Fri, 25 Oct 2019 15:56:07 +0200 Message-Id: <1572011772-23271-9-git-send-email-david.marchand@redhat.com> In-Reply-To: <1572011772-23271-1-git-send-email-david.marchand@redhat.com> References: <1571736761-32134-1-git-send-email-david.marchand@redhat.com> <1572011772-23271-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: u7PWs1GXMEC0cXUlMrYZVA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH v3 08/12] test/mem: remove dependency on EAL internals X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Rather than dereference the mem_config internal structure, we can rely on the rte_memzone_walk API and count memzones. Signed-off-by: David Marchand Acked-by: Thomas Monjalon --- app/test/test_memzone.c | 50 ++++++++++++++++++++++++++++++---------------= ---- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c index 7edfd06..4d87444 100644 --- a/app/test/test_memzone.c +++ b/app/test/test_memzone.c @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include #include #include "../../lib/librte_eal/common/malloc_elem.h" -#include "../../lib/librte_eal/common/eal_memcfg.h" =20 #include "test.h" =20 @@ -927,6 +927,16 @@ test_memzone_free(void) =09return 0; } =20 +static int test_memzones_left; +static int memzone_walk_cnt; +static void memzone_walk_clb(const struct rte_memzone *mz, +=09=09=09 void *arg __rte_unused) +{ +=09memzone_walk_cnt++; +=09if (!strncmp(TEST_MEMZONE_NAME(""), mz->name, RTE_MEMZONE_NAMESIZE)) +=09=09test_memzones_left++; +} + static int test_memzone_basic(void) { @@ -936,8 +946,12 @@ test_memzone_basic(void) =09const struct rte_memzone *memzone4; =09const struct rte_memzone *mz; =09int memzone_cnt_after, memzone_cnt_expected; -=09int memzone_cnt_before =3D -=09=09=09rte_eal_get_configuration()->mem_config->memzones.count; +=09int memzone_cnt_before; + +=09memzone_walk_cnt =3D 0; +=09test_memzones_left =3D 0; +=09rte_memzone_walk(memzone_walk_clb, NULL); +=09memzone_cnt_before =3D memzone_walk_cnt; =20 =09memzone1 =3D rte_memzone_reserve(TEST_MEMZONE_NAME("testzone1"), 100, =09=09=09=09SOCKET_ID_ANY, 0); @@ -960,8 +974,10 @@ test_memzone_basic(void) =09=09=09(memzone1 !=3D NULL) + (memzone2 !=3D NULL) + =09=09=09(memzone3 !=3D NULL) + (memzone4 !=3D NULL); =20 -=09memzone_cnt_after =3D -=09=09=09rte_eal_get_configuration()->mem_config->memzones.count; +=09memzone_walk_cnt =3D 0; +=09test_memzones_left =3D 0; +=09rte_memzone_walk(memzone_walk_clb, NULL); +=09memzone_cnt_after =3D memzone_walk_cnt; =20 =09if (memzone_cnt_after !=3D memzone_cnt_expected) =09=09return -1; @@ -1039,30 +1055,26 @@ test_memzone_basic(void) =09=09return -1; =09} =20 -=09memzone_cnt_after =3D -=09=09=09rte_eal_get_configuration()->mem_config->memzones.count; +=09memzone_walk_cnt =3D 0; +=09test_memzones_left =3D 0; +=09rte_memzone_walk(memzone_walk_clb, NULL); +=09memzone_cnt_after =3D memzone_walk_cnt; =09if (memzone_cnt_after !=3D memzone_cnt_before) =09=09return -1; =20 =09return 0; } =20 -static int test_memzones_left; -static int memzone_walk_cnt; -static void memzone_walk_clb(const struct rte_memzone *mz, -=09=09=09 void *arg __rte_unused) -{ -=09memzone_walk_cnt++; -=09if (!strncmp(TEST_MEMZONE_NAME(""), mz->name, RTE_MEMZONE_NAMESIZE)) -=09=09test_memzones_left++; -} - static int test_memzone(void) { =09/* take note of how many memzones were allocated before running */ -=09int memzone_cnt =3D -=09=09=09rte_eal_get_configuration()->mem_config->memzones.count; +=09int memzone_cnt; + +=09memzone_walk_cnt =3D 0; +=09test_memzones_left =3D 0; +=09rte_memzone_walk(memzone_walk_clb, NULL); +=09memzone_cnt =3D memzone_walk_cnt; =20 =09printf("test basic memzone API\n"); =09if (test_memzone_basic() < 0) --=20 1.8.3.1