diff mbox

ndctl, test: fix smart event alerting unit test

Message ID 150971743587.27961.15140037224342017626.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit caeac9cb3d74
Headers show

Commit Message

Dan Williams Nov. 3, 2017, 1:57 p.m. UTC
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 mbox

Patch

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);
 		}
 	}