diff options
author | Yauheni Kaliuta <yauheni.kaliuta@redhat.com> | 2019-01-04 23:41:33 +0200 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@intel.com> | 2019-01-04 14:39:39 -0800 |
commit | b7cd0fdab0c172c155af9fc6d0e6e95e28b89364 (patch) | |
tree | db4b5b0f109b2795cda2fe02f14c5502601e8bcd | |
parent | ad411f7684c50c18e55e9d7885cfc998113beb79 (diff) | |
download | kmod-b7cd0fdab0c172c155af9fc6d0e6e95e28b89364.tar.gz kmod-b7cd0fdab0c172c155af9fc6d0e6e95e28b89364.tar.bz2 kmod-b7cd0fdab0c172c155af9fc6d0e6e95e28b89364.zip |
testsuite: track number of descriptors instead of their state
use the number of tracked descriptors to determine the end of the
loop.
This is a preparation for more abstract descriptor comparation
implementation where checking of the descriptor state may be more
expensive than just checking of the local variables.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
-rw-r--r-- | testsuite/testsuite.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c index 1f0caaf..81b54ad 100644 --- a/testsuite/testsuite.c +++ b/testsuite/testsuite.c @@ -450,6 +450,7 @@ static bool test_run_parent_check_outputs(const struct test *t, bool fd_activityout = false, fd_activityerr = false; unsigned long long end_usec, start_usec; _cleanup_free_ struct buffer *buf_out = NULL, *buf_err = NULL; + int n_fd = 0; fd_ep = epoll_create1(EPOLL_CLOEXEC); if (fd_ep < 0) { @@ -474,6 +475,7 @@ static bool test_run_parent_check_outputs(const struct test *t, goto out; } buf_out = calloc(2, sizeof(*buf_out)); + n_fd++; } else fdout = -1; @@ -495,6 +497,7 @@ static bool test_run_parent_check_outputs(const struct test *t, goto out; } buf_err = calloc(2, sizeof(*buf_err)); + n_fd++; } else fderr = -1; @@ -506,11 +509,12 @@ static bool test_run_parent_check_outputs(const struct test *t, ERR("could not add monitor fd to epoll: %m\n"); goto out; } + n_fd++; start_usec = now_usec(); end_usec = start_usec + TEST_TIMEOUT_USEC; - for (err = 0; fdmonitor >= 0 || fdout >= 0 || fderr >= 0;) { + for (err = 0; n_fd > 0;) { int fdcount, i, timeout; struct epoll_event ev[4]; unsigned long long curr_usec = now_usec(); @@ -571,6 +575,7 @@ static bool test_run_parent_check_outputs(const struct test *t, ERR("could not remove fd %d from epoll: %m\n", fd); } *(int *)ev[i].data.ptr = -1; + n_fd--; } } } |