From patchwork Fri Nov 8 10:21:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kanas X-Patchwork-Id: 62757 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6DBE7A04B3; Fri, 8 Nov 2019 11:23:36 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 136281C0C0; Fri, 8 Nov 2019 11:21:55 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 4DF711C123 for ; Fri, 8 Nov 2019 11:21:51 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xA8AGXia007337; Fri, 8 Nov 2019 02:21:50 -0800 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-transfer-encoding : content-type; s=pfpt0818; bh=N04pQ0v9N8tf0SYeg7UREAOSX7H3DOmkRnfFqgnIFB8=; b=nWbi8YPaBdOHXFX1KzmnUjTfSRcZCIe5QZMUIW390z6vSU3rzUuq8dVzG8X3pR8p02iX Z1LfVLrwiwuqOQSIThzmGFahBSf8GvgCIRAI2aaDaDqeSWw6R0e3fhAjYHtmEUcG6j2e A0A/YWRLJgQbPm0OI+w4vEUs7g/S5Ec7OK+e0BQmV+/YDOF1rh7GVsyiZ5kc92W3J4KE OWi91zdYrOqNT9lNGIx8lpU73izZpxUYw/T/Mq4yK3IVxbiDEVElkJ+4AqxjLsy7YRY8 FZ55Bz3ETmemLIVHDzNm8O+c+NS/+j2Cly6xhtZRnxAtXK6lMFzXHtEcCTEt60fzrkvb mg== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2w4fq6whw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 08 Nov 2019 02:21:50 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 8 Nov 2019 02:21:48 -0800 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; Fri, 8 Nov 2019 02:21:48 -0800 Received: from kk-box-0.marvell.com (unknown [10.95.130.41]) by maili.marvell.com (Postfix) with ESMTP id A51293F703F; Fri, 8 Nov 2019 02:21:47 -0800 (PST) From: To: , , CC: Krzysztof Kanas Date: Fri, 8 Nov 2019 11:21:33 +0100 Message-ID: <20191108102135.7249-2-kkanas@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191108102135.7249-1-kkanas@marvell.com> References: <20191108102135.7249-1-kkanas@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-08_02:2019-11-07,2019-11-08 signatures=0 Subject: [dpdk-dev] [PATCH v3 1/3] test: fix timeout in flags 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: Krzysztof Kanas Test eal_flags_autotest times out on 64 ARM due to excessive calls to 'access' system call. While at it fix process_dup logic so it tests correct file path for opened fd's. Fixes: af75078fece3 ("first public release") Cc: intel.com Signed-off-by: Krzysztof Kanas --- app/test/process.h | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/app/test/process.h b/app/test/process.h index 128ce41219a1..298ba288087a 100644 --- a/app/test/process.h +++ b/app/test/process.h @@ -11,6 +11,7 @@ #include /* NULL */ #include /* strerror */ #include /* readlink */ +#include #include #include /* strlcpy */ @@ -40,8 +41,12 @@ process_dup(const char *const argv[], int numargs, const char *env_value) { int num; char *argv_cpy[numargs + 1]; - int i, fd, status; + int i, fd, fdir, status; + struct dirent *dirent; + const char *procdir = "/proc/self/fd/"; char path[32]; + char *endptr; + DIR *dir; #ifdef RTE_LIBRTE_PDUMP pthread_t thread; #endif @@ -58,11 +63,39 @@ process_dup(const char *const argv[], int numargs, const char *env_value) /* close all open file descriptors, check /proc/self/fd to only * call close on open fds. Exclude fds 0, 1 and 2*/ - for (fd = getdtablesize(); fd > 2; fd-- ) { - snprintf(path, sizeof(path), "/proc/" exe "/fd/%d", fd); - if (access(path, F_OK) == 0) - close(fd); + dir = opendir(procdir); + if (dir == NULL) { + rte_panic("Error opening %s: %s\n", procdir, + strerror(errno)); } + + fdir = dirfd(dir); + if (fdir < 0) { + status = errno; + closedir(dir); + rte_panic("Error %d obtaining fd for dir %s: %s\n", + fdir, procdir, strerror(status)); + } + + while ((dirent = readdir(dir)) != NULL) { + if (!strcmp(".", dirent->d_name) || + !strcmp("..", dirent->d_name)) + continue; + + errno = 0; + fd = strtol(dirent->d_name, &endptr, 10); + if (errno != 0 || endptr[0] != '\0') { + printf("Error converint name fd %d %s:\n", + fd, dirent->d_name); + continue; + } + if (fd == fdir || fd <= 2) + continue; + + close(fd); + } + closedir(dir); + printf("Running binary with argv[]:"); for (i = 0; i < num; i++) printf("'%s' ", argv_cpy[i]);