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 DFBA4A329E for ; Wed, 23 Oct 2019 20:56:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ABE631D415; Wed, 23 Oct 2019 20:55:16 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id CB3381D40C for ; Wed, 23 Oct 2019 20:55:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571856911; 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=1wPcidAhtRIC13CYsfRReaLfwRDSJAbR5jTManN0dLk=; b=Im8zqGVNK5NwO1xI7zZbFa3UsFIKgdy3Ex9htynotVcEnrlEJ5jpe8SePT/To2X4dVJ2FP 8z7GH0DNDas6fvAUULYUHmwg0Hyb2c5hXZ0OK+S/Qy+9gvHWG35NCuKLYQ0VFYtGnzzNI2 etgPB2hnT2pSaX1mltNafCqBnyVSWN0= 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-262-rFCcsthOObimLXYK8zsIuQ-1; Wed, 23 Oct 2019 14:55:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C6EA80183E; Wed, 23 Oct 2019 18:55:06 +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 B917E60872; Wed, 23 Oct 2019 18:55:04 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stephen@networkplumber.org, anatoly.burakov@intel.com, thomas@monjalon.net Date: Wed, 23 Oct 2019 20:54:21 +0200 Message-Id: <1571856864-8779-10-git-send-email-david.marchand@redhat.com> In-Reply-To: <1571856864-8779-1-git-send-email-david.marchand@redhat.com> References: <1571736761-32134-1-git-send-email-david.marchand@redhat.com> <1571856864-8779-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: rFCcsthOObimLXYK8zsIuQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH v2 09/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 --- 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