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=-9.5 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 6608FC433E0 for ; Mon, 6 Jul 2020 21:13:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0E741206BE for ; Mon, 6 Jul 2020 21:13:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="q4ZqsO86" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E741206BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A0D4C6B000A; Mon, 6 Jul 2020 17:13:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E4E56B000C; Mon, 6 Jul 2020 17:13:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F9726B000D; Mon, 6 Jul 2020 17:13:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 78FC86B000A for ; Mon, 6 Jul 2020 17:13:16 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3F7152C88 for ; Mon, 6 Jul 2020 21:13:16 +0000 (UTC) X-FDA: 77008901592.13.hair48_5f15ddf26eae Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id E58EC18140B70 for ; Mon, 6 Jul 2020 21:13:15 +0000 (UTC) X-HE-Tag: hair48_5f15ddf26eae X-Filterd-Recvd-Size: 6064 Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Mon, 6 Jul 2020 21:13:15 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id v8so40824940iox.2 for ; Mon, 06 Jul 2020 14:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+16+7KnkX/9gcZH8MHFXYJspRfXIBLdOpWbNNV0TOlU=; b=q4ZqsO86c89YhXHMa8mndzuuWKeikqJBiNdooYKBQ59lbnHySGj2CkCuwC12c5KGPG 91pUyLBL+Ipzq6ohMANeeQKM/WoXPQDmg012R5LRgzirkNae03AFDibyxL4bI63sDO2y fgXAr0HF/9gAXJZYBioRmdXCLL6A1Sbc/C8rSHbuzGjfUIUyy7IKbo1Mp3lWzPmv3OIe avTwWB5fSeKGfirW4zyvsZReTnDiBng8yiFE+j6ANVXCgYFMWImmgpticBGIKHphSzw6 hYbg4pr0YmzChHJ8mF8YBJ7LnSCJ5NgHqC5Gb/MZOSsdGfntT77ExNXSdWNbyBzV6hxZ B0DQ== 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:mime-version:content-transfer-encoding; bh=+16+7KnkX/9gcZH8MHFXYJspRfXIBLdOpWbNNV0TOlU=; b=gX3FqrQU3QMwi0XWYetEpqWcuOHvrTDqvqr7larfnfaOB4uqj/szT91sUagkz5Hig0 ehnszFlzlMTSoIrRkWsAEPkXqhURPZ28CrS1pbKXhps0FWO2nvrXhNk0HeUfjsIhdBgd rMzoCl3vrXVuNLPXr3vMs4M5UppSttn+Lhaj9rzuq5vEav+Q1MQzTllQttaYU4y9dqR4 DgGhPrm2ckX1bT71lL66QNEdJ99oanom0xBWvwK+FcN511rKj+Qvw9ht0t5cfkP206Ck Mw4/O1OxVhv7WU1XFwzs1dylQMQHCgDb6TZ7s8Qy77dPgYUGBJ0ia2y2HzHpBXLsXnlp ufIg== X-Gm-Message-State: AOAM533HvBn60Hwq/u8+Pvk1R7ia8rnG8zduzJLA7y12yhvZ6Qp0gTxY 8rzWtKxsaIGXZ9/KOHLpE9Q= X-Google-Smtp-Source: ABdhPJz/oP9a0GR+Mz0G+YElZIM2kl7GU+Tjgdq41tPYHxqnhl/0p6pgyQhjjkDDhbSsfn6/Mz2E5g== X-Received: by 2002:a05:6602:2f92:: with SMTP id u18mr27569915iow.63.1594069995005; Mon, 06 Jul 2020 14:13:15 -0700 (PDT) Received: from urieldev.c.googlers.com.com (243.199.238.35.bc.googleusercontent.com. [35.238.199.243]) by smtp.gmail.com with ESMTPSA id i10sm1063652ild.14.2020.07.06.14.13.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 14:13:14 -0700 (PDT) From: Uriel Guajardo To: brendanhiggins@google.com, catalin.marinas@arm.com, akpm@linux-foundation.org Cc: changbin.du@intel.com, rdunlap@infradead.org, masahiroy@kernel.org, 0x7f454c46@gmail.com, urielguajardo@google.com, krzk@kernel.org, kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-mm@kvack.org Subject: [PATCH 1/2] kunit: support kunit failures from debugging tools Date: Mon, 6 Jul 2020 21:13:08 +0000 Message-Id: <20200706211309.3314644-2-urielguajardojr@gmail.com> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200706211309.3314644-1-urielguajardojr@gmail.com> References: <20200706211309.3314644-1-urielguajardojr@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: E58EC18140B70 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Uriel Guajardo Dynamic analyis tools can now fail the currently running kunit test case by calling kunit_fail_current_test(). A new header file is created so that no circular dependencies are created with external tools. This patch requires "kunit: KASAN integration", which places the currently running kunit test in task_struct. [1] [1] https://lore.kernel.org/linux-kselftest/20200606040349.246780-2-david= gow@google.com Signed-off-by: Uriel Guajardo --- include/kunit/test-bug.h | 15 +++++++++++++++ include/kunit/test.h | 1 + lib/kunit/test.c | 10 ++++++---- 3 files changed, 22 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..69ec3dd91c52 --- /dev/null +++ b/include/kunit/test-bug.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Base unit test (KUnit) API. + * + * Copyright (C) 2020, Google LLC. + * Author: Uriel Guajardo + */ + +#if IS_ENABLED(CONFIG_KUNIT) +extern void kunit_fail_current_test(void); +#else +static inline void kunit_fail_current_test(void) +{ +} +#endif diff --git a/include/kunit/test.h b/include/kunit/test.h index 1dc3d118f64b..c46715c739b5 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -11,6 +11,7 @@ =20 #include #include +#include #include #include #include diff --git a/lib/kunit/test.c b/lib/kunit/test.c index ef3bfb9fae48..8580ed831a8f 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -16,6 +16,12 @@ #include "string-stream.h" #include "try-catch-impl.h" =20 +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 =3D ctx->suite; struct kunit_case *test_case =3D ctx->test_case; =20 -#if (IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT)) current->kunit_test =3D test; -#endif /* IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT) */ =20 /* * kunit_run_case_internal may encounter a fatal error; if it does, @@ -603,9 +607,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 =3D NULL; -#endif /* IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT)*/ } EXPORT_SYMBOL_GPL(kunit_cleanup); =20 --=20 2.27.0.212.ge8ba1cc988-goog