From patchwork Mon Sep 11 09:51:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13379937 X-Patchwork-Delegate: brendanhiggins@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FAA5CA0EC3 for ; Mon, 11 Sep 2023 21:27:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236193AbjIKVTN (ORCPT ); Mon, 11 Sep 2023 17:19:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236125AbjIKJvV (ORCPT ); Mon, 11 Sep 2023 05:51:21 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8200BE44; Mon, 11 Sep 2023 02:51:15 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD2B1C433C7; Mon, 11 Sep 2023 09:51:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694425875; bh=e5uSUKmEcH/fCVQMCvFK+XpQngjeYTq9GMcSnKC6dpI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=I0tNrtdGK/MB3ernvQQwRMXmwe4o+w+W+pUhcSL4yFjKkbtYAAb53uVtMZx4CdFgk qH+V+gZc/MSLzzNqLUVNXXDpfIkMjrlPKio3Pr2QSmrwGKD9YLSsoF7gutagFJB3C9 SaeCift22DVwJCX6/J7gRYQlZCXSNkru9qkUQ8qK+1TDUX/aHc89BS+R7aOerRMAQv uSOBgPv9lr3AX95ferkcM5A/k/r9GqwcCRvHkD8yp/HRkwvJG2I/1mGG6pVJdHpEWb zgq1KXQ7F3thYH7BzjJ06cfwkYYl461H0JTE8s5073t1YmZEQJMW3SdM689MRkT3MT Hu7ZYhDyd9ulw== From: Maxime Ripard Date: Mon, 11 Sep 2023 11:51:05 +0200 Subject: [PATCH 1/2] kunit: Warn if tests are slow MIME-Version: 1.0 Message-Id: <20230911-kms-slow-tests-v1-1-d3800a69a1a1@kernel.org> References: <20230911-kms-slow-tests-v1-0-d3800a69a1a1@kernel.org> In-Reply-To: <20230911-kms-slow-tests-v1-0-d3800a69a1a1@kernel.org> To: Brendan Higgins , David Gow , David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Maxime Ripard X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1555; i=mripard@kernel.org; h=from:subject:message-id; bh=e5uSUKmEcH/fCVQMCvFK+XpQngjeYTq9GMcSnKC6dpI=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCn/HvNWFd7+9C1yqeJ91sr22QYRCxXvi23c9/aDuQ7fT a4rhdNDO0pZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjARthSG/7WRsv5aXEqv5Ipb FaY67dP33TjrSGztxs8Wgk/nTo97do3hD9fxWaw5h3XbpF5xF3Mbrvme6L9BrEk6Np//l070zgl aHAA= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Kunit recently gained support to setup attributes, the first one being the speed of a given test, then allowing to filter out slow tests. A slow test is defined in the documentation as taking more than one second. There's an another speed attribute called "super slow" but whose definition is less clear. Add support to the test runner to check the test execution time, and report tests that should be marked as slow but aren't. Signed-off-by: Maxime Ripard --- lib/kunit/test.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/kunit/test.c b/lib/kunit/test.c index 49698a168437..a3b924501f3d 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -379,6 +379,9 @@ static void kunit_run_case_internal(struct kunit *test, struct kunit_suite *suite, struct kunit_case *test_case) { + struct timespec64 start, end; + struct timespec64 duration; + if (suite->init) { int ret; @@ -390,7 +393,20 @@ static void kunit_run_case_internal(struct kunit *test, } } + ktime_get_ts64(&start); + test_case->run_case(test); + + ktime_get_ts64(&end); + + duration = timespec64_sub(end, start); + + if (duration.tv_sec >= 1 && + (test_case->attr.speed == KUNIT_SPEED_UNSET || + test_case->attr.speed >= KUNIT_SPEED_NORMAL)) + kunit_warn(test, + "Test should be marked slow (runtime: %lld.%09lds)", + duration.tv_sec, duration.tv_nsec); } static void kunit_case_internal_cleanup(struct kunit *test) From patchwork Mon Sep 11 09:51:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13379939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A618CA0ECB for ; Mon, 11 Sep 2023 21:27:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345049AbjIKVTT (ORCPT ); Mon, 11 Sep 2023 17:19:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236126AbjIKJvW (ORCPT ); Mon, 11 Sep 2023 05:51:22 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91150E44; Mon, 11 Sep 2023 02:51:18 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B657AC433CC; Mon, 11 Sep 2023 09:51:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694425878; bh=n39qjqZdna7s4aCBSr+Q6tsGFUv34ZNjq8iqqrLVaKg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZeoL1/kUHKOlVAzAFsVO97NPTxM/vmkW9yVfZFiR7o1ir8KqlTcCKnnGOvOxGMFA0 1tcvRhd6AKrG1u0bppmbD9BDjzcPOunJoNxUTiz4Q2V7TBEjMbIUwr83faKGyMXaLP RWCayMzbaJakOFimPqacGJy2Ps06jwL00JapzLZv+FQp7ZVAIdAUSuby0PutrABk0F iIOW4oCXAx+nUV8YpDAvH4G6xX1m8EOLmU8J8gjzhwsE5dmpbaIfDgiaZhQawRObNh rI3rj8bGYwR/5+ICGViQHgSbv9/78FuSSPPotKUFxVpBvNa4K7L1kY2z/yFf+X1asy MZHABQZ8oeX+A== From: Maxime Ripard Date: Mon, 11 Sep 2023 11:51:06 +0200 Subject: [PATCH 2/2] drm/tests: Flag slow tests as such MIME-Version: 1.0 Message-Id: <20230911-kms-slow-tests-v1-2-d3800a69a1a1@kernel.org> References: <20230911-kms-slow-tests-v1-0-d3800a69a1a1@kernel.org> In-Reply-To: <20230911-kms-slow-tests-v1-0-d3800a69a1a1@kernel.org> To: Brendan Higgins , David Gow , David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Maxime Ripard X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2575; i=mripard@kernel.org; h=from:subject:message-id; bh=n39qjqZdna7s4aCBSr+Q6tsGFUv34ZNjq8iqqrLVaKg=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCn/HvP+StiTeqav+O31b0s/Zr3nt3v7ospZ+nn9k8cXz v6TvxZ1uKOUhUGMi0FWTJElRth8SdypWa872fjmwcxhZQIZwsDFKQATcQpm+F+yMnequ1KKWpCB Y4tZ8Jnt2qoahce5T3wV/6Z/g/nwQ25GhoPChiud5wusvn6/eyu7H/+C9SdnvD4jsK+ielv13/s 2T/kA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Kunit recently gained a speed attribute that allows to filter out slow tests. A slow test is defined in the documentation as a test taking more than a second to execute. Let's flag the few tests that are doing so on my machine when running: ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/tests \ --cross_compile aarch64-linux-gnu- --arch arm64 Suggested-by: David Gow Signed-off-by: Maxime Ripard --- drivers/gpu/drm/tests/drm_buddy_test.c | 2 +- drivers/gpu/drm/tests/drm_mm_test.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c index 09ee6f6af896..6f79cde2df55 100644 --- a/drivers/gpu/drm/tests/drm_buddy_test.c +++ b/drivers/gpu/drm/tests/drm_buddy_test.c @@ -742,7 +742,7 @@ static struct kunit_case drm_buddy_tests[] = { KUNIT_CASE(drm_test_buddy_alloc_range), KUNIT_CASE(drm_test_buddy_alloc_optimistic), KUNIT_CASE(drm_test_buddy_alloc_pessimistic), - KUNIT_CASE(drm_test_buddy_alloc_smoke), + KUNIT_CASE_SLOW(drm_test_buddy_alloc_smoke), KUNIT_CASE(drm_test_buddy_alloc_pathological), {} }; diff --git a/drivers/gpu/drm/tests/drm_mm_test.c b/drivers/gpu/drm/tests/drm_mm_test.c index 186b28dc7038..c1e662c2a76c 100644 --- a/drivers/gpu/drm/tests/drm_mm_test.c +++ b/drivers/gpu/drm/tests/drm_mm_test.c @@ -2228,23 +2228,23 @@ module_param(max_prime, uint, 0400); static struct kunit_case drm_mm_tests[] = { KUNIT_CASE(drm_test_mm_init), KUNIT_CASE(drm_test_mm_debug), - KUNIT_CASE(drm_test_mm_reserve), - KUNIT_CASE(drm_test_mm_insert), - KUNIT_CASE(drm_test_mm_replace), - KUNIT_CASE(drm_test_mm_insert_range), + KUNIT_CASE_SLOW(drm_test_mm_reserve), + KUNIT_CASE_SLOW(drm_test_mm_insert), + KUNIT_CASE_SLOW(drm_test_mm_replace), + KUNIT_CASE_SLOW(drm_test_mm_insert_range), KUNIT_CASE(drm_test_mm_frag), KUNIT_CASE(drm_test_mm_align), KUNIT_CASE(drm_test_mm_align32), KUNIT_CASE(drm_test_mm_align64), - KUNIT_CASE(drm_test_mm_evict), + KUNIT_CASE_SLOW(drm_test_mm_evict), KUNIT_CASE(drm_test_mm_evict_range), KUNIT_CASE(drm_test_mm_topdown), KUNIT_CASE(drm_test_mm_bottomup), KUNIT_CASE(drm_test_mm_lowest), KUNIT_CASE(drm_test_mm_highest), KUNIT_CASE(drm_test_mm_color), - KUNIT_CASE(drm_test_mm_color_evict), - KUNIT_CASE(drm_test_mm_color_evict_range), + KUNIT_CASE_SLOW(drm_test_mm_color_evict), + KUNIT_CASE_SLOW(drm_test_mm_color_evict_range), {} };