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 37DFEA00E6 for ; Thu, 11 Jul 2019 07:15:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A61482E81; Thu, 11 Jul 2019 07:15:50 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 313642C60 for ; Thu, 11 Jul 2019 07:15:49 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6B5FKNF009816; Wed, 10 Jul 2019 22:15:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=MHoO6Chvy2qkAJdel83tKk0NgLpLQRKljlp8OIx69oY=; b=HUa3HgyJXA4YpUr0ihIkq6MmvKz7cvMucESO5SYTxIAasU5ty8AD6ZzndlhPMbFjreo9 ozWJ+7pNVvtcxX77E0KdXnpsjUq0g6rPtvpU1/JBgL/krsJs4TFGnoH1FFfdS4INb9qb j0tmxYbIxLV0sirR7g1s29mLb3ZOfqvimS8pAUPUv/IG/WK9Mx1GQ88q1XiMdrtaTXL6 sq7RUxRxonU2X6sysJBB0UPTUcqLnF8etQ8lmfIYKN2O6UWCoHIXxN5rgLAk1OxZSsBh sia5HWCccvKWpyZs0NemyHoeJ/qYgfv++oj+03rPhSJQNdPYgkVSsYbzHmpmuX1MxqFz oA== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2tnv950grs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 10 Jul 2019 22:15:47 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 10 Jul 2019 22:15:46 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 10 Jul 2019 22:15:46 -0700 Received: from hyd1vattunuru-dt.caveonetworks.com (unknown [10.29.52.72]) by maili.marvell.com (Postfix) with ESMTP id 5CAD43F703F; Wed, 10 Jul 2019 22:15:44 -0700 (PDT) From: To: CC: , , , Vamsi Attunuru Date: Thu, 11 Jul 2019 10:45:32 +0530 Message-ID: <20190711051532.21054-1-vattunuru@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20190410072532.17182-1-vattunuru@marvell.com> References: <20190410072532.17182-1-vattunuru@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-11_01:, , signatures=0 Subject: [dpdk-dev] [PATCH v2 1/1] app/test: fix --socket-mem option in eal flag autotest 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" From: Vamsi Attunuru eal flag autotest fails when multiple mem size flags are passed to --socket-mem option irrespective of RTE_MAX_NUMA_NODES. Patch fixes --socket-mem option by setting enough numbers of numa node mem flags based on RTE_MAX_NUMA_NODES config. Fixes: 45f1b6e8680a ("app: add new tests on eal flags") Signed-off-by: Vamsi Attunuru --- V2 changes: * Add routine to populate --socket-mem option and use it to form valid and invalid test commands. app/test/test_eal_flags.c | 118 ++++++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 50 deletions(-) diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c index 672ca0a..c8e5c46 100644 --- a/app/test/test_eal_flags.c +++ b/app/test/test_eal_flags.c @@ -1250,12 +1250,45 @@ test_file_prefix(void) return 0; } +static void +populate_socket_mem_param(int num_sockets, const char *mem_size, char *buf) +{ + char tmp[SOCKET_MEM_STRLEN]; + int i; + + snprintf(buf, SOCKET_MEM_STRLEN, "--socket-mem="); + + for (i = 0; i < num_sockets ; i++) { + snprintf(tmp, sizeof(tmp), "%s%s", buf, mem_size); + strlcpy(buf, tmp, sizeof(tmp)); + + if (num_sockets + 1 - i > 1) { + snprintf(tmp, sizeof(tmp), "%s,", buf); + strlcpy(buf, tmp, sizeof(tmp)); + } + } +} + /* * Tests for correct handling of -m and --socket-mem flags */ static int test_memory_flags(void) { + char buf[SOCKET_MEM_STRLEN]; /* to avoid copying string onto itself */ + +#ifdef RTE_EXEC_ENV_FREEBSD + int num_sockets = 1; +#else + int num_sockets = RTE_MIN(get_number_of_sockets(), + RTE_MAX_NUMA_NODES); +#endif + + if (num_sockets <= 0) { + printf("Error - cannot get number of sockets!\n"); + return -1; + } + #ifdef RTE_EXEC_ENV_FREEBSD /* BSD target doesn't support prefixes at this point */ const char * prefix = ""; @@ -1277,85 +1310,70 @@ test_memory_flags(void) "--file-prefix=" memtest, "-m", DEFAULT_MEM_SIZE}; /* valid (zero) --socket-mem flag */ + char arg2_socket_mem[SOCKET_MEM_STRLEN]; + populate_socket_mem_param(num_sockets - 1, "0", buf); + snprintf(arg2_socket_mem, sizeof(arg2_socket_mem), "%s%s", buf, "0"); const char *argv2[] = {prgname, - "--file-prefix=" memtest, "--socket-mem=0,0,0,0"}; + "--file-prefix=" memtest, arg2_socket_mem}; /* invalid (incomplete) --socket-mem flag */ + char arg3_socket_mem[SOCKET_MEM_STRLEN]; + populate_socket_mem_param(num_sockets - 1, "2", buf); + snprintf(arg3_socket_mem, sizeof(arg3_socket_mem), "%s%s", buf, "2,"); const char *argv3[] = {prgname, - "--file-prefix=" memtest, "--socket-mem=2,2,"}; + "--file-prefix=" memtest, arg3_socket_mem}; /* invalid (mixed with invalid data) --socket-mem flag */ + char arg4_socket_mem[SOCKET_MEM_STRLEN]; + populate_socket_mem_param(num_sockets - 1, "2", buf); + snprintf(arg4_socket_mem, sizeof(arg4_socket_mem), "%s%s", buf, "Fred"); const char *argv4[] = {prgname, - "--file-prefix=" memtest, "--socket-mem=2,2,Fred"}; + "--file-prefix=" memtest, arg4_socket_mem}; /* invalid (with numeric value as last character) --socket-mem flag */ + char arg5_socket_mem[SOCKET_MEM_STRLEN]; + populate_socket_mem_param(num_sockets - 1, "2", buf); + snprintf(arg5_socket_mem, sizeof(arg5_socket_mem), + "%s%s", buf, "Fred0"); const char *argv5[] = {prgname, - "--file-prefix=" memtest, "--socket-mem=2,2,Fred0"}; + "--file-prefix=" memtest, arg5_socket_mem}; /* invalid (with empty socket) --socket-mem flag */ + char arg6_socket_mem[SOCKET_MEM_STRLEN]; + populate_socket_mem_param(num_sockets - 1, "2", buf); + snprintf(arg6_socket_mem, sizeof(arg6_socket_mem), "%s%s", buf, ",,"); const char *argv6[] = {prgname, - "--file-prefix=" memtest, "--socket-mem=2,,2"}; + "--file-prefix=" memtest, arg6_socket_mem}; /* invalid (null) --socket-mem flag */ const char *argv7[] = {prgname, "--file-prefix=" memtest, "--socket-mem="}; /* valid --socket-mem specified together with -m flag */ + char arg8_socket_mem[SOCKET_MEM_STRLEN]; + populate_socket_mem_param(num_sockets - 1, "2", buf); + snprintf(arg8_socket_mem, sizeof(arg8_socket_mem), "%s%s", buf, "2"); const char *argv8[] = {prgname, - "--file-prefix=" memtest, "-m", DEFAULT_MEM_SIZE, "--socket-mem=2,2"}; + "--file-prefix=" memtest, "-m", + DEFAULT_MEM_SIZE, arg8_socket_mem}; /* construct an invalid socket mask with 2 megs on each socket plus * extra 2 megs on socket that doesn't exist on current system */ char invalid_socket_mem[SOCKET_MEM_STRLEN]; - char buf[SOCKET_MEM_STRLEN]; /* to avoid copying string onto itself */ - -#ifdef RTE_EXEC_ENV_FREEBSD - int i, num_sockets = 1; -#else - int i, num_sockets = RTE_MIN(get_number_of_sockets(), - RTE_MAX_NUMA_NODES); -#endif - - if (num_sockets <= 0) { - printf("Error - cannot get number of sockets!\n"); - return -1; - } - - snprintf(invalid_socket_mem, sizeof(invalid_socket_mem), "--socket-mem="); - - /* add one extra socket */ - for (i = 0; i < num_sockets + 1; i++) { - snprintf(buf, sizeof(buf), "%s%s", invalid_socket_mem, DEFAULT_MEM_SIZE); - strlcpy(invalid_socket_mem, buf, sizeof(invalid_socket_mem)); - - if (num_sockets + 1 - i > 1) { - snprintf(buf, sizeof(buf), "%s,", invalid_socket_mem); - strlcpy(invalid_socket_mem, buf, - sizeof(invalid_socket_mem)); - } - } - - /* construct a valid socket mask with 2 megs on each existing socket */ - char valid_socket_mem[SOCKET_MEM_STRLEN]; - - snprintf(valid_socket_mem, sizeof(valid_socket_mem), "--socket-mem="); - - /* add one extra socket */ - for (i = 0; i < num_sockets; i++) { - snprintf(buf, sizeof(buf), "%s%s", valid_socket_mem, DEFAULT_MEM_SIZE); - strlcpy(valid_socket_mem, buf, sizeof(valid_socket_mem)); - - if (num_sockets - i > 1) { - snprintf(buf, sizeof(buf), "%s,", valid_socket_mem); - strlcpy(valid_socket_mem, buf, - sizeof(valid_socket_mem)); - } - } + populate_socket_mem_param(num_sockets, DEFAULT_MEM_SIZE, buf); + snprintf(invalid_socket_mem, sizeof(invalid_socket_mem), + "%s%s", buf, DEFAULT_MEM_SIZE); /* invalid --socket-mem flag (with extra socket) */ const char *argv9[] = {prgname, "--file-prefix=" memtest, invalid_socket_mem}; + /* construct a valid socket mask with 2 megs on each existing socket */ + char valid_socket_mem[SOCKET_MEM_STRLEN]; + populate_socket_mem_param(num_sockets - 1, DEFAULT_MEM_SIZE, buf); + snprintf(valid_socket_mem, sizeof(valid_socket_mem), + "%s%s", buf, DEFAULT_MEM_SIZE); + /* valid --socket-mem flag */ const char *argv10[] = {prgname, "--file-prefix=" memtest, valid_socket_mem}; -- 2.8.4