From patchwork Tue Feb 20 17:00:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 128927 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4849962ljc; Tue, 20 Feb 2018 09:01:41 -0800 (PST) X-Google-Smtp-Source: AH8x2259HgHyWx84RWAm1o8Cy0sof0fkyhqInhvuCkle+s0+Zo7DYofZ75k9ZvwkZhLb08ReeZrk X-Received: by 10.200.56.249 with SMTP id g54mr397782qtc.245.1519146101040; Tue, 20 Feb 2018 09:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519146101; cv=none; d=google.com; s=arc-20160816; b=01dh7H9y+HFVK1tVfnqCKmwZu7RRLROX6P1QZq/n3goHQYd69RoyRBU2QZzw6DQYAk TRX+STZlxnXQYRa1VzfrqlbYEUsGfDFs2334oko4Hxx2LMTVsHbSt5XLSsiAWCrvu77Q Nzn2cz7P4zNu9Kb/qh5Uj4qWPpZ4CEN9USaherXLY6oebY/QBoo2hOedc1PR7Jq+G7lP qKtSq8ZhfZiYDidsHvqamXPZ9zVty/NGcJ3kEEBcDoMqlKlh1PQHrntADFS9zlspA7cA XjjCbuoN4p9B0Jn5LbeK5KCGJ7jVC9rGq36Yn4ax48w+MwSeR8nWQik3RiLwiGM4cxwo L/5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=UTqjr2a0JAj49feFevIqkhJ7+Nz/r78QlNEpALMOoUM=; b=G6YpdhvnFB+8XVkUWxTAxUzeYkNrkcG47K5hFO0N/6tyotmHzd4dJZqOhCsT5rd35M j2LGG260MrZwor8EkgPu2HBq9WoU4rx8Nil424eFSKt5iBiolfikCONmjHjX+UjilTxt 9Wm+e0WQiRCG1pvNQENptXVY4f0JSE3+AnIdtlgJjxL3V3BJ9SrOAMv3ugl6c4RJNykr Gx+2l4EjXvBSBYv42wXMHmMmJ4SwGgjvqS/Dx+ThiduB5c3Ymf4lW0FTyvy4AGjZDL2i ghVIKBew5rtb5sfNlZsphqy5qv9fbv4855KmqKHi3iVV7sYyX4deuEgAbla/9CFjFIGR aBRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id g38si4936677qtf.135.2018.02.20.09.01.40; Tue, 20 Feb 2018 09:01:41 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id A82EC616FC; Tue, 20 Feb 2018 17:01:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 2C0916074F; Tue, 20 Feb 2018 17:00:30 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 981C9610B9; Tue, 20 Feb 2018 17:00:17 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id EA5B160940 for ; Tue, 20 Feb 2018 17:00:12 +0000 (UTC) Received: from mxback7g.mail.yandex.net (mxback7g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:168]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 1433E56048D4 for ; Tue, 20 Feb 2018 20:00:11 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback7g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Adve7XD6Ua-0BduOqKF; Tue, 20 Feb 2018 20:00:11 +0300 Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id j65fuiFbN5-0AECoEvd; Tue, 20 Feb 2018 20:00:10 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 20 Feb 2018 20:00:08 +0300 Message-Id: <1519146008-3368-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519146008-3368-1-git-send-email-odpbot@yandex.ru> References: <1519146008-3368-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 491 Subject: [lng-odp] [PATCH v1 3/3] validation: timer: fix test failure X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov timer_main test was regularly failing due to worker code receiving timeout events for cancelled timers in invalid state. However after fixing implementation bug, several other asserts started to fail, as they dependent on incorrect behaviour, like non-freshness of cancelled events. Fixes: https://bugs.linaro.org/show_bug.cgi?id=3517 Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 491 (lumag:timer-fix-2) ** https://github.com/Linaro/odp/pull/491 ** Patch: https://github.com/Linaro/odp/pull/491.patch ** Base sha: d5419e8857b2bc61d3be17fe53f171550fee426b ** Merge commit sha: 1623e4e7c0742c5238c1b97abe1e8af93f091443 **/ test/validation/api/timer/timer.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index c3b807aee..183c61e8d 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -275,15 +275,10 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) CU_FAIL("odp_timeout_user_ptr() wrong user ptr"); if (ttp && ttp->tim != tim) CU_FAIL("odp_timeout_timer() wrong timer"); - if (stale) { - if (odp_timeout_fresh(tmo)) - CU_FAIL("Wrong status (fresh) for stale timeout"); - /* Stale timeout => local timer must have invalid tick */ - if (ttp && ttp->tick != TICK_INVALID) - CU_FAIL("Stale timeout for active timer"); - } else { - if (!odp_timeout_fresh(tmo)) - CU_FAIL("Wrong status (stale) for fresh timeout"); + + if (!odp_timeout_fresh(tmo)) + CU_FAIL("Wrong status (stale) for fresh timeout"); + if (!stale) { /* Fresh timeout => local timer must have matching tick */ if (ttp && ttp->tick != tick) { LOG_DBG("Wrong tick: expected %" PRIu64 @@ -291,6 +286,9 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) ttp->tick, tick); CU_FAIL("odp_timeout_tick() wrong tick"); } + if (ttp && ttp->ev != ODP_EVENT_INVALID) + CU_FAIL("Wrong state for fresh timer (event)"); + /* Check that timeout was delivered 'timely' */ if (tick > odp_timer_current_tick(tp)) CU_FAIL("Timeout delivered early"); @@ -404,11 +402,14 @@ static int worker_entrypoint(void *arg TEST_UNUSED) (rand_r(&seed) % 2 == 0)) { /* Timer active, cancel it */ rc = odp_timer_cancel(tt[i].tim, &tt[i].ev); - if (rc != 0) + if (rc != 0) { /* Cancel failed, timer already expired */ ntoolate++; - tt[i].tick = TICK_INVALID; - ncancel++; + LOG_DBG("Failed to cancel timer, probably already expired\n"); + } else { + tt[i].tick = TICK_INVALID; + ncancel++; + } } else { if (tt[i].ev != ODP_EVENT_INVALID) /* Timer inactive => set */ @@ -462,7 +463,7 @@ static int worker_entrypoint(void *arg TEST_UNUSED) thr, ntoolate); LOG_DBG("Thread %u: %" PRIu32 " timeouts received\n", thr, nrcv); LOG_DBG("Thread %u: %" PRIu32 - " stale timeout(s) after odp_timer_free()\n", + " stale timeout(s) after odp_timer_cancel()\n", thr, nstale); /* Delay some more to ensure timeouts for expired timers can be