From patchwork Sat Jul 29 15:22:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9870199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BEB5260353 for ; Sun, 30 Jul 2017 04:32:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF62228621 for ; Sun, 30 Jul 2017 04:32:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A416F28634; Sun, 30 Jul 2017 04:32:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9952628621 for ; Sun, 30 Jul 2017 04:32:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 767036FB6F; Sun, 30 Jul 2017 04:30:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x241.google.com (mail-qt0-x241.google.com [IPv6:2607:f8b0:400d:c0d::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5E9EF8825E for ; Sat, 29 Jul 2017 16:28:39 +0000 (UTC) Received: by mail-qt0-x241.google.com with SMTP id u19so12492155qtc.0 for ; Sat, 29 Jul 2017 09:28:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=arf9preh4xcWDxXSItIJnOEW+p4efWHPow0OziVehfg=; b=CQY7GU90aAveKblFWBc7/XvZcN8SdWOe9X3F+5e1YAMxkY/G1UB1iSCVK5o0tlTv4U sg61Li/Br3SovA/YkWvJNF5J9THanMrFl6R3YARW3RbLAmU8k0NTgZrjGMVpARenezfc vB3zHNqSs0j38FX4U/BAAt9noLhVFsKmxSgiYRvquAA5WEPDuEA8y0Mnisr9/tHSzSsi AoXZ46FGM1zhgzCyTkxOAzKGJJo5PA1HJquLKkS22P5EJanRoBUXye44bPFK1zvbrHPo 1ArzLv2wFOrMiN2d6XUm7v0Qez4ArQybhUe7imiRa1dIfD06AYyGAhsZzs1iEQchx14m PaJA== X-Gm-Message-State: AIVw111qCCTQz0q+wTQJkjjC08uUgdnwYxp+Iy9QF7biYxYa8v8+tofX 3gD5ppk89ZVLCQ1gNDs= X-Received: by 10.200.37.21 with SMTP id 21mr15746138qtm.85.1501341746545; Sat, 29 Jul 2017 08:22:26 -0700 (PDT) Received: from localhost.localdomain ([187.35.198.81]) by smtp.gmail.com with ESMTPSA id c204sm8737392qkb.32.2017.07.29.08.22.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Jul 2017 08:22:26 -0700 (PDT) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] selftests: sync: add test that closes the fd before fence signal Date: Sat, 29 Jul 2017 12:22:17 -0300 Message-Id: <20170729152217.8362-3-gustavo@padovan.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170729152217.8362-1-gustavo@padovan.org> References: <20170729152217.8362-1-gustavo@padovan.org> Cc: Gustavo Padovan , Shuah Khan , linux-kselftest@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gustavo Padovan We found this bug in the sw_sync so adding a test case to prevent it to happen in the future. Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Signed-off-by: Gustavo Padovan Reviewed-by: Chris Wilson --- To be applied after the TAP13 convertion patches. --- tools/testing/selftests/sync/sync_fence.c | 23 +++++++++++++++++++++++ tools/testing/selftests/sync/sync_test.c | 1 + tools/testing/selftests/sync/synctest.h | 1 + 3 files changed, 25 insertions(+) diff --git a/tools/testing/selftests/sync/sync_fence.c b/tools/testing/selftests/sync/sync_fence.c index 13f1752..70cfa61 100644 --- a/tools/testing/selftests/sync/sync_fence.c +++ b/tools/testing/selftests/sync/sync_fence.c @@ -29,6 +29,29 @@ #include "sw_sync.h" #include "synctest.h" +int test_close_fence_fd_before_inc(void) +{ + int fence, valid, ret; + int timeline = sw_sync_timeline_create(); + + valid = sw_sync_timeline_is_valid(timeline); + ASSERT(valid, "Failure allocating timeline\n"); + + fence = sw_sync_fence_create(timeline, "allocFence", 1); + valid = sw_sync_fence_is_valid(fence); + ASSERT(valid, "Failure allocating fence\n"); + + sw_sync_fence_destroy(fence); + + /* Advance timeline from 0 -> 1 */ + ret = sw_sync_timeline_inc(timeline, 1); + ASSERT(ret == 0, "Failure advancing timeline\n"); + + sw_sync_timeline_destroy(timeline); + + return 0; +} + int test_fence_one_timeline_wait(void) { int fence, valid, ret; diff --git a/tools/testing/selftests/sync/sync_test.c b/tools/testing/selftests/sync/sync_test.c index 7f79382..2f73ace 100644 --- a/tools/testing/selftests/sync/sync_test.c +++ b/tools/testing/selftests/sync/sync_test.c @@ -95,6 +95,7 @@ int main(void) RUN_TEST(test_alloc_fence); RUN_TEST(test_alloc_fence_negative); + RUN_TEST(test_close_fence_fd_before_inc); RUN_TEST(test_fence_one_timeline_wait); RUN_TEST(test_fence_one_timeline_merge); RUN_TEST(test_fence_merge_same_fence); diff --git a/tools/testing/selftests/sync/synctest.h b/tools/testing/selftests/sync/synctest.h index 90a8e53..86a9532 100644 --- a/tools/testing/selftests/sync/synctest.h +++ b/tools/testing/selftests/sync/synctest.h @@ -46,6 +46,7 @@ int test_alloc_fence(void); int test_alloc_fence_negative(void); /* Fence tests with one timeline */ +int test_close_fence_fd_before_inc(void); int test_fence_one_timeline_wait(void); int test_fence_one_timeline_merge(void);