All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Cc: Daniel Osawa <daniel.k.osawa@intel.com>
Subject: [PATCH] ndctl, test: fix smart event alerting unit test
Date: Fri, 03 Nov 2017 06:57:15 -0700	[thread overview]
Message-ID: <150971743587.27961.15140037224342017626.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)

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 <daniel.k.osawa@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 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);
 		}
 	}

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

                 reply	other threads:[~2017-11-03 13:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=150971743587.27961.15140037224342017626.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=daniel.k.osawa@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.