The tur_deep_sleep() test serves to test the behavior of the tur checker
when checkers time out and cannot be cancelled.

Up to now the checker timed out on every TUR_SLEEP_INTERVALth
invocation. That made it impossible to test the MAX_TIMEOUTS logic, which
requires multiple consecutive timeouts. To fix it, invert the logic, so
that the checker just succeeds on every TUR_SLEEP_INTERVALth call.

Also, decrease loglevel of the messages from tur_deep_sleep().

Signed-off-by: Martin Wilck <[email protected]>
---
 libmultipath/checkers/tur.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c
index 0a312c7..6791172 100644
--- a/libmultipath/checkers/tur.c
+++ b/libmultipath/checkers/tur.c
@@ -214,15 +214,15 @@ static void tur_deep_sleep(const struct tur_data *tdata)
        int oldstate;
 
        if (tdata->devt != makedev(TUR_TEST_MAJOR, TUR_TEST_MINOR) ||
-           ++sleep_cnt % TUR_SLEEP_INTERVAL != 0)
+           ++sleep_cnt % TUR_SLEEP_INTERVAL == 0)
                return;
 
-       condlog(1, "tur thread going to sleep for %ld seconds", ts.tv_sec);
+       condlog(3, "tur thread going to sleep for %ld seconds", ts.tv_sec);
        if (pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate) != 0)
                condlog(0, "pthread_setcancelstate: %m");
        if (nanosleep(&ts, NULL) != 0)
                condlog(0, "nanosleep: %m");
-       condlog(1, "tur zombie thread woke up");
+       condlog(3, "tur zombie thread woke up");
        if (pthread_setcancelstate(oldstate, NULL) != 0)
                condlog(0, "pthread_setcancelstate (2): %m");
        pthread_testcancel();
-- 
2.53.0


Reply via email to