From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F8F1C433E6 for ; Mon, 31 Aug 2020 21:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E90C620719 for ; Mon, 31 Aug 2020 21:29:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598909359; bh=ZDT28xfUkP1M8J8ASix6Vm8/VXe7dJSKAagxg06IY/s=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-ID:From; b=mD2nAjr9JWosm30DnRwlOWCmbk3fukkq/udZ8d3o6n26NfCy9vjMjKFOriAN5b0J1 QCkO1Jzd2k8d9loRfjOebRUyizEn6M9IBSZLzF/5mxJ2WN/TgLCBUd670nyBL4vCr2 j5pQRdOn3YPxgzvBBqqha8t0IZ9N+gD6SCu694Pw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730263AbgHaV3R (ORCPT ); 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-Google-Smtp-Source: ABdhPJy48awb963u3Jr6eP4TskOJYw/H3bcAOBQuCF1AsS/1fowlxgVQDhdVetgBTVCcuH5yHNXHFg== 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