From patchwork Wed Feb 14 18:00:13 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: 128372 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp877149ljc; Wed, 14 Feb 2018 10:01:59 -0800 (PST) X-Google-Smtp-Source: AH8x224CmdoLtYpP8RMqBKozuDy4HqCilygjjrDk8/YDMjaMkpGTStD7kG3Jbi39jT6kRzihmZJz X-Received: by 10.55.88.7 with SMTP id m7mr8765683qkb.142.1518631319587; Wed, 14 Feb 2018 10:01:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518631319; cv=none; d=google.com; s=arc-20160816; b=A3wHi3JBCy/GsrgysWsH/BR5E6IjQyQx6gqU8KElurLx2GgXYVJrbrXKjwzvT3xrc3 qV+wN8fBT6TcPB9WkCKJGrcwG9fOW19o5p4FBbZRHtmLbVtW8o4WgwqL18k7mVgBWuO+ Ho1h8ZfzAFNGf2enkuFZaJLgHOuGSnc/qPfYLEaQ5auniUa/yjeqdxU1nZy9lIEN2BUZ HqxNc1RlTnUPVQMRuWdieqRD5/DEq85LkC2LQEyThc1XczGDrv30bYHSbaysR1upQVsH VSQeRV+g8f9uJ65L0CLmeLK4HLIXACJiDdX0ggL/z6I5L+aLj6rOdxV7As8p2lSSoBTl 8iIQ== 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=gTrxXHmIu7kD8xy7P8rkUCdVmGy8YWiaexG3xdWYnQ0=; b=zdw4rQn4OPOZ4TM8QV4b+xRqJu8FmLRoY7Z2sabQwFCM28e6E9IMq7Uq8tK74lPTFv lKVJ+6M9Ov0ICBPQ4fNdZ1Zmgrh8FkXu3d6FTGVF08tOJgqdvWtsNYwuiIj2QuOJdTrZ zHifRhfzwPE4th6AuiKw6FKVDtdyzIcwqgWOMOQP/rZltQEDVWJYDaavQXTXA0SNnPh9 Z1wderNXTi5VcXzMsA6eKLANDSnW1jWmIOlAGlpTTX0TCfajGfbkLsfNCpqWrH05+Lt/ CuYLQg9/gAHwtFOV83h6QEPZj7HSPGCfnvwlSu3ENhlluqs1jPwlXonyJHTI3dxGzry/ z9YA== 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 k41si2316770qta.252.2018.02.14.10.01.59; Wed, 14 Feb 2018 10:01:59 -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 34AC161797; Wed, 14 Feb 2018 18:01:59 +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 7C2AA617BC; Wed, 14 Feb 2018 18: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 94CF5616E5; Wed, 14 Feb 2018 18:00:21 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 8EB6961784 for ; Wed, 14 Feb 2018 18:00:16 +0000 (UTC) Received: from mxback11g.mail.yandex.net (mxback11g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:90]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 40DBF56036F3 for ; Wed, 14 Feb 2018 21:00:15 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback11g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id P0kikDs9IC-0EJ4Negk; Wed, 14 Feb 2018 21:00:15 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id oghPril69q-0EbafFsB; Wed, 14 Feb 2018 21:00:14 +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: Wed, 14 Feb 2018 21:00:13 +0300 Message-Id: <1518631213-21228-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518631213-21228-1-git-send-email-odpbot@yandex.ru> References: <1518631213-21228-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 479 Subject: [lng-odp] [PATCH v2 1/1] 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. I'm fixing worker code to handle these events correctly, however this might signify a loophole in API definition or in linux-generic implementation. Should application be able to copy with timers that are cancelled after expiration (but before event reception)? Should implementation mark such timers as non-fresh? Signed-off-by: Dmitry Eremin-Solenikov Fixes: https://bugs.linaro.org/show_bug.cgi?id=3517 Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 479 (lumag:timer-fix) ** https://github.com/Linaro/odp/pull/479 ** Patch: https://github.com/Linaro/odp/pull/479.patch ** Base sha: 41b3fa2cd994a7ef68290a07dcde5564e4640847 ** Merge commit sha: d02fe9568e6e46919379706028fddba66ebe6865 **/ test/validation/api/timer/timer.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index 7ea508aa0..da2dc05ca 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -282,15 +282,28 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_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"); - /* Fresh timeout => local timer must have matching tick */ - if (ttp && ttp->tick != tick) { - LOG_DBG("Wrong tick: expected %" PRIu64 - " actual %" PRIu64 "\n", - ttp->tick, tick); - CU_FAIL("odp_timeout_tick() wrong tick"); + if (ttp && ttp->tick == TICK_INVALID) { + /* Timer was cancelled when it has already expired */ + + if (odp_timeout_fresh(tmo)) + CU_FAIL("Wrong status (fresh) " + "for cancelled timeout"); + } else { + if (!odp_timeout_fresh(tmo)) + CU_FAIL("Wrong status (stale) " + "for fresh timeout"); + + /* Fresh timeout => local timer must have matching tick + */ + if (ttp && ttp->tick != tick) { + LOG_DBG("Wrong tick: expected %" PRIu64 + " actual %" PRIu64 "\n", + 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"); @@ -401,9 +414,11 @@ 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++; + LOG_DBG("Failed to cancel timer, probably already expired\n"); + } tt[i].tick = TICK_INVALID; ncancel++; } else {