From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 478D1423E6; Sun, 15 Jan 2023 21:12:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 68E7A42D1E; Sun, 15 Jan 2023 21:11:44 +0100 (CET) Received: from CY4PR02CU007-vft-obe.outbound.protection.outlook.com (mail-westcentralusazon11011009.outbound.protection.outlook.com [40.93.199.9]) by mails.dpdk.org (Postfix) with ESMTP id 5938B40E03; Fri, 13 Jan 2023 14:13:08 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UycpSHwH52FI5L/SqUWN9/L4Ki9pqXMe2yVTfJK9XLoVEPvUMvc975q1bVwOtv8IM2aZ6f53ODlNYFfi7hNT2hWSGmmPs37m1drKTZsOvs1U8jFlrsMFjwUTqe7qd5W+ZqFHaIcHVeQezD9/VXmOc+VJSiJ9qqT+sKntApF+38uEgKYzLWSofvUUiTViLU3E9BamLzfYOlfrdtZOooCxqs4njiS+hIRvpXGuuZb6Chy2UyD7xqOUd45MUsj6vsbN4QHjAJTdovv6R2BYHodtobSL3J5GSiEfvkoyrLhG7cC0Ln40CH67GlKRX8pE+ltIO00lMdVj5FxSQ3WGMnh52g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wf6WtbkVnIWZK1eBdrycabfQnX5/qlVOsDfxaWGYTec=; b=glPuoveGmy5+UD2LD3d4S5nM0KjFVYHLdi3MY/GjDMwTptIk/SOUx7oYDnXHQLq+CJFNm/VJ83KFZKKZqyAD/ldnP7VqW+Taxcf3h9CXLGT9VFPg/75sQPXBUld8QMJyFtgj7RXcUJBe7z6Hqw7jBEpCfuOoIr40gD1sKQqFrExNZzRk9lRu4VieEUE/rjeA4/alS+qqgpVAr3SJ67xJz3JoR5gFC3JpqyZhUXXTciJII47UNxEYs+8bEP89UaVWU3xCGi0OgqDd+aEYOwUJleH3TT5eGeY6oFuRF36vVF+wZ2yEcBhDCR47CQxG3YpbQ42SoqrLE4jF7THYjvfliw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wf6WtbkVnIWZK1eBdrycabfQnX5/qlVOsDfxaWGYTec=; b=DmBHB23DkqLAvlKPPklIoCevXnXYT4MbGTCvfVqgkeBJ+P9s46+zxxJ3BMobyHbfJH6hxq5Eh1YWQOiitAeKgKgcump6JS0TNrAo7rYNcf96OCVTMR5PmcsAsS0us2vatEubicabgJmwlg0jmobj/YufudfRR+htX7HSnTBJFJU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vmware.com; Received: from DM6PR05MB5577.namprd05.prod.outlook.com (2603:10b6:5:c::16) by CY4PR05MB3431.namprd05.prod.outlook.com (2603:10b6:910:59::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Fri, 13 Jan 2023 13:13:06 +0000 Received: from DM6PR05MB5577.namprd05.prod.outlook.com ([fe80::4cbc:cca6:3a16:5023]) by DM6PR05MB5577.namprd05.prod.outlook.com ([fe80::4cbc:cca6:3a16:5023%4]) with mapi id 15.20.5986.018; Fri, 13 Jan 2023 13:13:06 +0000 From: Vipin P R To: anatoly.burakov@intel.com Cc: dev@dpdk.org, Vipin P R , stable@dpdk.org Subject: [PATCH] Memory Allocation: Adding a new UT for fb_array Date: Fri, 13 Jan 2023 13:12:47 +0000 Message-Id: <1673615567-20873-2-git-send-email-vipinp@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1673615567-20873-1-git-send-email-vipinp@vmware.com> References: <1673615567-20873-1-git-send-email-vipinp@vmware.com> Content-Type: text/plain X-ClientProxiedBy: SJ0PR13CA0036.namprd13.prod.outlook.com (2603:10b6:a03:2c2::11) To DM6PR05MB5577.namprd05.prod.outlook.com (2603:10b6:5:c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR05MB5577:EE_|CY4PR05MB3431:EE_ X-MS-Office365-Filtering-Correlation-Id: 04f9a086-a0e4-4125-a80f-08daf567e8ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6tc0Y8JrMdPGKFQxZHEGAGRo8R+z3+IckN6YDWBJl4aJL0YqOYOGr68FH/pe2WYxnCCgm/Y+n0WeLk3AlFc+bLj4yqD0ZLIv+tvN3pEpoGHJ2iyQxDTWSEkBa81gQx/M8Mb+Lj90k5p7QPKZxqTLiwOjnUG/Y0UVSQ0lKIFD3mU6pEdhixxQpPGHjSgCB5bcRMGPEyZVqI/xE4Cw0BkkToejYGSStwDnGETMnj0iksNL46D4qvZ1vMskCIfXphLaNNp80H4ikoMLWq7qb0vduE33gyWpH5sWfCnUj3PAmlAUTA2pxIw/NsZXoqoHeGA+/gfClz9UseE3ut7PbXUo/Sw+stPTEIg+3tZ+eqsp9A6XimC3YVinTftD1TnPTCZApVQsFSWX7fZPyqprLPZL/qOda4Un0/47IwPhNaS0He5ZIedptolY1MRoKPrsRK+CUJZgCX5tY9u3Lf6nrlmCV0x7hkFbdV9r5oC43yoWtnSYzbQe4Nq2RKuZceHzXNf9q0rgzH79BTYjvT/0G1TDjUpa+UQAJ6w+IVK6VT7ZM0ECKFmTBjqdw7CuPGmxgzkWRsZlheyIemhSyY1/pIkvgE0eudwaXH4GOxZq740HNm3aFpyt01qsWgufTAoxqQGluGSHTkvyMfVJib7YHKFED/CRQTXr5et8XTr65IwcgLf1S+9B0yWR7ni/tR04Vq/m X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR05MB5577.namprd05.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(136003)(346002)(366004)(376002)(39860400002)(451199015)(6506007)(36756003)(6666004)(2906002)(5660300002)(4326008)(6916009)(8936002)(8676002)(38350700002)(6512007)(38100700002)(478600001)(41300700001)(6486002)(26005)(66946007)(52116002)(186003)(66476007)(66556008)(2616005)(86362001)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JwxnaA4hWS0IoMSd2AaDW3vqdTaP8jlPjao8qBCN2LFEckS9OQtIzmikb0e1?= =?us-ascii?Q?VdQYS2viuoZ0aM0qaEMuYsHGJbLIF6Sb2/6SAw00RSzpfLFcU5qwb66gexUD?= =?us-ascii?Q?CyIvRSI4jI/pVYTk6+9fk8NYbbzMiOKyv2z/UqyNez+ymh7rcSqDqV5yGDyj?= =?us-ascii?Q?tdKrdX3W1ovYKZhcrAFZwgKf93k5xRrMTWVNeoo28wNjPZcyAiF9oFGjdKOj?= =?us-ascii?Q?96OnSmkjocH/qc9Y87M78h4Hqsyl8IjugbFiAOeZDqZ7jJQy6a1znQmwPd58?= =?us-ascii?Q?VRPgZgLchfSvb2SsDmRGo9SDPvylMdDFe1cEnbB36zrtaLzYq0kAOCC0bTz2?= =?us-ascii?Q?2JjuhNc930rNuLLcxgIzimjfQaPc9iT6trYiTOsiE0X0nGKfFxpuRqOcnVNk?= =?us-ascii?Q?OyspdnaZBE8QdTdD/wtOEhgV19CObxd6rczUaN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pvWw0zhZuYfAWgcLT1TKvrZvKfoV5YScDbU2LYzOjmCrov?= =?us-ascii?Q?TQo/GTRvM1VTG24Q2yvETiy8IL1iUrmry6EOaL7IdzwLjqNp42xWMjYUMKdu?= =?us-ascii?Q?J8kb9vVrOVp517Kx1BftzEhRvOVV5Q+3FUaRuZJm4xt4o+MI82FmxiXBKGoX?= =?us-ascii?Q?4jTUtrQWUxVM+HlQUCdYLO4xQmn5Uth6Qvh7aKD1McMiU96Omt98v9qb3AUM?= =?us-ascii?Q?we/XdFyBoDASDLEfZbIm1a8y6JkclxyJl0Xc5gnw?= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04f9a086-a0e4-4125-a80f-08daf567e8ad X-MS-Exchange-CrossTenant-AuthSource: DM6PR05MB5577.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2023 13:13:06.2040 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VpaA9hyv1sj+jz47BR94EzdLgMJu5kCikXMd9y0N37FPdfSmVGzGQqFHYEQawpEse8PU5pw73QZgGDwkaXQb1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR05MB3431 X-Mailman-Approved-At: Sun, 15 Jan 2023 21:11:39 +0100 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org add test case coverage to cover the ms_idx jump Cc: stable@dpdk.org Signed-off-by: Vipin P R Acked-by: Kumara Parameshwaran --- Depends-on: 0001-Memory-Allocation-Fixes-ms_idx-jump-lookahead-during.patch Depends-on: 0002-Memory-Allocation-Fixes-ms_idx-jump-lookbehind-durin.patch --- app/test/test_fbarray.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/app/test/test_fbarray.c b/app/test/test_fbarray.c index a691bf4..275449c 100644 --- a/app/test/test_fbarray.c +++ b/app/test/test_fbarray.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "test.h" @@ -402,6 +403,53 @@ static int check_used_one(void) return 0; } +/* the following test case verifies that the jump in ms_idx for an fb-array is correct. */ +static int test_jump(void) +{ + struct rte_fbarray test_array; + int input[] = {1, 1070, 1, 2, 1, 2, 4, 12, 2, 2, 1, 2, 1}; + int ms_idx, prev_ms_idx, delta; + int len; + ms_idx = prev_ms_idx = 0; + + int ret = rte_fbarray_init(&test_array, "test", 32768, sizeof(struct rte_memseg)); + if (ret == 0) { + RTE_LOG(DEBUG, EAL, "FB array init success\n"); + int k = 0; + for(int i=0; i < sizeof(input)/sizeof(int); i++) { + if (i == 0) { + len = input[i]; + } else { + len = input[i] + 1; + } + prev_ms_idx = ms_idx; + ms_idx = rte_fbarray_find_next_n_free(&test_array, k, len); + + if (i != 0) { + ms_idx++; + } + + for (int j=0; j < input[i]; j++) { + RTE_LOG(DEBUG, EAL, "ms_idx:%d\n", ms_idx); + rte_fbarray_set_used(&test_array, ms_idx); + ms_idx++; + } + + if (prev_ms_idx) { + /* The value of ms_idx should be monotonically increasing + * given the above input sequence in test_array. + * */ + delta = ms_idx - prev_ms_idx; + if (!(delta > 0)) { + RTE_LOG(ERR, EAL, "ms_idx jumping behind. ms_idx: %d prev_ms_idx: %d\n", ms_idx - 1, prev_ms_idx - 1); + TEST_ASSERT(0, "Incorrect ms_idx jump"); + } + } + } + } + return 0; +} + static int test_basic(void) { const int idx = 0; @@ -717,6 +765,7 @@ static struct unit_test_suite fbarray_test_suite = { .unit_test_cases = { TEST_CASE(test_invalid), TEST_CASE(test_basic), + TEST_CASE(test_jump), TEST_CASE_ST(first_msk_test_setup, reset_array, test_find), TEST_CASE_ST(cross_msk_test_setup, reset_array, test_find), TEST_CASE_ST(multi_msk_test_setup, reset_array, test_find), -- 2.7.4