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: 13379123 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5FE9FEEB580 for ; Mon, 11 Sep 2023 09:51:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 928AB10E256; Mon, 11 Sep 2023 09:51:18 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 62FB610E256 for ; Mon, 11 Sep 2023 09:51:16 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B6EFF6104F; Mon, 11 Sep 2023 09:51:15 +0000 (UTC) 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, Maxime Ripard , =?utf-8?q?Ma=C3=ADra_Canal?= , dri-devel@lists.freedesktop.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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)