From patchwork Fri Nov 3 13:57:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10040279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 14BC860384 for ; Fri, 3 Nov 2017 14:03:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 022F329656 for ; Fri, 3 Nov 2017 14:03:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA17829659; Fri, 3 Nov 2017 14:03:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EDAF129656 for ; Fri, 3 Nov 2017 14:03:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 055B120355602; Fri, 3 Nov 2017 06:59:48 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 14275203555FA for ; Fri, 3 Nov 2017 06:59:45 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 03 Nov 2017 07:03:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,339,1505804400"; d="scan'208";a="917264063" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by FMSMGA003.fm.intel.com with ESMTP; 03 Nov 2017 07:03:40 -0700 Subject: [PATCH] ndctl, test: fix smart event alerting unit test From: Dan Williams To: linux-nvdimm@lists.01.org Date: Fri, 03 Nov 2017 06:57:15 -0700 Message-ID: <150971743587.27961.15140037224342017626.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Osawa Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP The 'libndctl' test was neglecting to add the health_eventfd to the select() fdset when testing for notification timeouts. We also need to clear the signalled status by reading the buffer. Reported-by: Daniel Osawa Signed-off-by: Dan Williams --- test/libndctl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/libndctl.c b/test/libndctl.c index 50fce70183a8..770171919b6c 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -2210,6 +2210,7 @@ static int check_smart_threshold(struct ndctl_bus *bus, struct ndctl_dimm *dimm, }; struct ndctl_cmd *cmd = ndctl_dimm_cmd_new_smart_threshold(dimm); struct timeval tm; + char buf[4096]; fd_set fds; int rc, fd; @@ -2221,6 +2222,8 @@ static int check_smart_threshold(struct ndctl_bus *bus, struct ndctl_dimm *dimm, fd = ndctl_dimm_get_health_eventfd(dimm); FD_ZERO(&fds); + FD_SET(fd, &fds); + rc = pread(fd, buf, sizeof(buf), 0); tm.tv_sec = 0; tm.tv_usec = 500; rc = select(fd + 1, NULL, NULL, &fds, &tm); @@ -2245,6 +2248,7 @@ static int check_smart_threshold(struct ndctl_bus *bus, struct ndctl_dimm *dimm, rc = select(fd + 1, NULL, NULL, &fds, &tm); if (rc != 1 || !FD_ISSET(fd, &fds)) exit(EXIT_FAILURE); + rc = pread(fd, buf, sizeof(buf), 0); exit(EXIT_SUCCESS); } }