Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1308017pxk; Mon, 31 Aug 2020 15:58:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwM2Sp+1VWrAR0j/IwyFn9f3x/VbUpjnbdWHqDWRiADxBUEdQu+K4BQH+47o+XFkx/LBec/ X-Received: by 2002:aa7:c387:: with SMTP id k7mr1433571edq.242.1598914734499; Mon, 31 Aug 2020 15:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598914734; cv=none; d=google.com; s=arc-20160816; b=EHo8/IkbEFNbXL7NXi2NuJOp9pznp22NA8ZynN8CTJPAE+VztLAJWnE7PtiggAQvl8 f3UsE6Pm17+OrLcNcibpkfSkAs3mFJyovqeemJwnkpQFztlLvfRqYWNVQ9cXkQzQXj04 kbWuFRfdAAfJNDc15Oe77hjWgUh1ne9M/RPrLBRdBnHWis4jeUDR/rbOGe82pvX/UFrK jSWtAvxBdhwKfamrDE906532XMC/DJ/Ia8hr09m1hCVkf+bZYcU8/qgbYexZtycf4eri TaW6sIT0srcgQYrVG7kIZ/B2e/mVEbjE9OivfEXshxQL/vngZXJ6FhT3OthkZuhzDaeX lMyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=va7gdVSZd9oGcktmFSi4633m1KmqtF16W8cC99ywrMo=; b=cd2EletFsOxwD7gnKOvDpVE0gR7A9l3PVkRE9oYp/whY5+M/w3CMebfLR6tspFWhia 7vQy2Yg2XeHA9dqLzeNbacbCAXnK72kHJ0HidWYHmfM4nrEEjJGA3Fr0FTKv4vr6vG+W EbDQid/SDIe83q9I9ujtHY4joad0GNPiwePUcFM6Nsc/H6mjoXX+n1pY9O2xrNFcyUgW PfK+iA1j/ZjDdXTgKoPZUA68UjdCC+23XO9UnLJU5vwFyPPIKA/ZjXJha7qdVN9o1adY vMGGdTdnsv6eBtUEE6zttuC9ZqOZ6A3BmNB0z6Wv2TD/mymIyAfSerIwY05McEyyYnL+ VPZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=WjlB03xt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si5269484edz.97.2020.08.31.15.58.32; Mon, 31 Aug 2020 15:58:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=WjlB03xt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730258AbgHaV3R (ORCPT + 99 others); Mon, 31 Aug 2020 17:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728352AbgHaV3Q (ORCPT ); Mon, 31 Aug 2020 17:29:16 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 857C1C061573 for ; Mon, 31 Aug 2020 14:29:16 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id h10so7612247ioq.6 for ; Mon, 31 Aug 2020 14:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=va7gdVSZd9oGcktmFSi4633m1KmqtF16W8cC99ywrMo=; b=WjlB03xtnU+43wht78tHLoS8a424N3Kd+/ROTOPBFZ7Kk02fAInH1cmTngPOuY1KNe UeIBt8RalhfROJkDxcePklvzDqg8TmWtuYWfvTRq58aE+XIrld97k8ukOw8yPapfzKPS U7adjw89nSoej8pbAX+2Gj0ZNyJPVqhqYmxqg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=va7gdVSZd9oGcktmFSi4633m1KmqtF16W8cC99ywrMo=; b=Nn05yue135rIFzJWgLwnGrqzmA4x+mybCuElf+EUIhezWLiCoZ6TvUCwlTmGng/Oji 2FTjGvEUDr2zKpKUgrS/4ozHIO500j2QJBtRphpVaKUaoJShdmqx8OWIe7hTG34maoai Z1S3tedZO5O4FmMr3tt+WTqYCpJr+qu/CLH7w4QCn+gBeTofUkLt2EcUcXB3KVfhQ9Ut qVov0eZ9tyzeR7wQIv5xuSbSJqH6wTFo5sbm1AtVz4D+nutSoEhZqt/s2r/DgSri7cQD JqqJ2oAzd6XXLb5dDJRjTy9dM42wD5MNGsL7zoJ1Js5K2PaMRCsBuSeZQDl4o8YwFKj9 28hg== X-Gm-Message-State: AOAM530K9qwHP36pnjm5fcmGAeyKDsqV2BUqAMZS4LXOLON/zT94+NUj 1uPDRJWs+HLpdpGFEv1aTpW2XA== X-Received: by 2002:a6b:d811:: with SMTP id y17mr2890886iob.16.1598909355836; Mon, 31 Aug 2020 14:29:15 -0700 (PDT) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id j66sm4476366ili.71.2020.08.31.14.29.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Aug 2020 14:29:15 -0700 (PDT) Subject: Re: [PATCH 1/2] kunit: support failure from dynamic analysis tools To: Uriel Guajardo , brendanhiggins@google.com Cc: urielguajardo@google.com, akpm@linux-foundation.org, keescook@chromium.org, rdunlap@infradead.org, herbert@gondor.apana.org.au, christian.brauner@ubuntu.com, peterz@infradead.org, ardb@kernel.og, arnd@arndb.de, julien.grall@arm.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Shuah Khan References: <20200813205722.1384108-1-urielguajardojr@gmail.com> From: Shuah Khan Message-ID: Date: Mon, 31 Aug 2020 15:29:13 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200813205722.1384108-1-urielguajardojr@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/13/20 2:57 PM, Uriel Guajardo wrote: > Adds an API to allow dynamic analysis tools to fail the currently > running KUnit test case. > > - Always places the kunit test in the task_struct to allow other tools > to access the currently running KUnit test. > > - Creates a new header file to avoid circular dependencies that could be > created from the test.h file. > > Requires KASAN-KUnit integration patch to access the kunit test from > task_struct: > https://lore.kernel.org/linux-kselftest/20200606040349.246780-2-davidgow@google.com/ > > Signed-off-by: Uriel Guajardo > --- > include/kunit/test-bug.h | 24 ++++++++++++++++++++++++ > include/kunit/test.h | 1 + > lib/kunit/test.c | 10 ++++++---- > 3 files changed, 31 insertions(+), 4 deletions(-) > create mode 100644 include/kunit/test-bug.h > > diff --git a/include/kunit/test-bug.h b/include/kunit/test-bug.h > new file mode 100644 > index 000000000000..283c19ec328f > --- /dev/null > +++ b/include/kunit/test-bug.h > @@ -0,0 +1,24 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * KUnit API allowing dynamic analysis tools to interact with KUnit tests > + * > + * Copyright (C) 2020, Google LLC. > + * Author: Uriel Guajardo > + */ > + > +#ifndef _KUNIT_TEST_BUG_H > +#define _KUNIT_TEST_BUG_H > + > +#if IS_ENABLED(CONFIG_KUNIT) > + > +extern void kunit_fail_current_test(void); > + > +#else > + > +static inline void kunit_fail_current_test(void) > +{ > +} > + > +#endif > + > +#endif /* _KUNIT_TEST_BUG_H */ > diff --git a/include/kunit/test.h b/include/kunit/test.h > index 3391f38389f8..81bf43a1abda 100644 > --- a/include/kunit/test.h > +++ b/include/kunit/test.h > @@ -11,6 +11,7 @@ > > #include > #include > +#include > #include > #include > #include > diff --git a/lib/kunit/test.c b/lib/kunit/test.c > index dcc35fd30d95..d8189d827368 100644 > --- a/lib/kunit/test.c > +++ b/lib/kunit/test.c > @@ -16,6 +16,12 @@ > #include "string-stream.h" > #include "try-catch-impl.h" > > +void kunit_fail_current_test(void) > +{ > + if (current->kunit_test) > + kunit_set_failure(current->kunit_test); > +} > + > static void kunit_print_tap_version(void) > { > static bool kunit_has_printed_tap_version; > @@ -284,9 +290,7 @@ static void kunit_try_run_case(void *data) > struct kunit_suite *suite = ctx->suite; > struct kunit_case *test_case = ctx->test_case; > > -#if (IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT)) > current->kunit_test = test; > -#endif /* IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT) */ > > /* > * kunit_run_case_internal may encounter a fatal error; if it does, > @@ -602,9 +606,7 @@ void kunit_cleanup(struct kunit *test) > spin_unlock(&test->lock); > kunit_remove_resource(test, res); > } > -#if (IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT)) > current->kunit_test = NULL; > -#endif /* IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT)*/ > } > EXPORT_SYMBOL_GPL(kunit_cleanup); > > Is this patch still needed. Doesn't apply on top of Linux 5.9. From q quick review, doesn't looks like it is needed. Not seeing any CONFIG_KASAN's in lib/kunit/test.c Here is the .rej --- lib/kunit/test.c +++ lib/kunit/test.c @@ -290,9 +296,7 @@ static void kunit_try_run_case(void *data) struct kunit_suite *suite = ctx->suite; struct kunit_case *test_case = ctx->test_case; -#if (IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT)) current->kunit_test = test; -#endif /* IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT) */ /* * kunit_run_case_internal may encounter a fatal error; if it does, @@ -608,9 +612,7 @@ void kunit_cleanup(struct kunit *test) spin_unlock(&test->lock); kunit_remove_resource(test, res); } -#if (IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT)) current->kunit_test = NULL; -#endif /* IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT)*/ } EXPORT_SYMBOL_GPL(kunit_cleanup); If this is still needed, please send me rebased patch. thanks, -- Shuah