Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1727550rwr; Thu, 20 Apr 2023 21:22:49 -0700 (PDT) X-Google-Smtp-Source: AKy350Y+qWwL0Nfb9qkPpuyuG1oNHLRaUxq0XsnCkNVplzd31r0gnjvA4qefMXV/S+YoG7iq3gYP X-Received: by 2002:a17:902:e80a:b0:1a8:18ae:1b36 with SMTP id u10-20020a170902e80a00b001a818ae1b36mr4414034plg.18.1682050968927; Thu, 20 Apr 2023 21:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682050968; cv=none; d=google.com; s=arc-20160816; b=vPa0G5EkCvMhPvAlGcslaKcAgkg0SsVUEmUyF8/r58m+ibRICiQfw3WvWb+h6o3l3g Bpu8XvfmKCvGFbBmogZGlm38s6qdiirkF9cX++HBPenOOeV8IUduRkvcr+SkNhkU11bT SsCH0Vg02pbwJOcKGgXvI2gzQylUTt0PDfywtVNuUKkFdVk591WWuMGT0R+3hhXC0UVf vO7QS/vl9ULD6fEJSGhsnk8/tRul5MLOm8k0r3S/0XFW9WOHlIeGABvzCqzt1ptxBWN/ RvJb4usEq15sTAFarw5RNHW+nT/9gAJsbnK4ELM6eahNndEG6zoiIlSb0CP7fjgoQbnz tWRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=6axHHeceCfT18Iy9/ahE+yGfyWAXleNOBhmrrlTMIXA=; b=vBO+34m5Ks7Gu0U5p+3F4QZ9GGnFpBqRHftjeOd2+YLc3KmizGHs2zuBPhxZ1OK8ER JvC8esPGu6Nawicr0nRcI2cOEaz185nKTSZM/YQt3nTg7HRUv+0Uljgv2TZZB8eDHpQq Z8A0kimjbDIL/5DPqkUI2IQ2OAsvGez4mTi1QwON3NoFJKsJe+Ha5/1R6PH1yq4392BK jPq3/Iszsp4CMuKGwHm8V/kJBCQ2wlo2n0I0VUoUOMoRh6F/VUPTm4QzILu4WBCJpN/y MiCPMZmbnClmSuq8mKMYv7Ug//Nd7/mc0Buw0xRJqnlXfzbQSDxWSKGIC06fmL1jSOny YkEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Zd0eS4RY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 6-20020a17090a190600b002476dde42c7si3513461pjg.170.2023.04.20.21.22.34; Thu, 20 Apr 2023 21:22:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Zd0eS4RY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233442AbjDUECj (ORCPT + 99 others); Fri, 21 Apr 2023 00:02:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233260AbjDUECa (ORCPT ); Fri, 21 Apr 2023 00:02:30 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11ADD40D8 for ; Thu, 20 Apr 2023 21:02:29 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-54f6da2edbdso18152967b3.0 for ; Thu, 20 Apr 2023 21:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682049748; x=1684641748; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6axHHeceCfT18Iy9/ahE+yGfyWAXleNOBhmrrlTMIXA=; b=Zd0eS4RY8TdnluDs8kHriFgx0zcAaGgzda+ecPw1Et8sMbW84233s0kcsmUCTayTKt 39DD/0vEMLFYIbCGcHuT4jt4ze798iBDxMd2S3fLLChUbSRIgy+mpyNwRghxERfG4P99 IjWMCqHQNiVOWq/PD+UCZrXGEggqdXohmrqDWxe4Ieih3oRBRMUdqqxqmnoUtrLx+n/1 BouKZBgAliqQHTUnk3uYUrDnuaNLcr8tePVKUT+ioVQet42AlbT/j5rgQs08w9IN0enO Er1Lb6UWBKGses/tebvlTvtE3HimYo+gq6GNVxhgXro6kYyHyDbh6t6FbT/jNJslfK/a ICfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682049748; x=1684641748; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6axHHeceCfT18Iy9/ahE+yGfyWAXleNOBhmrrlTMIXA=; b=Isk69JI6pOoxyZ+h0FtXrfIzvhenZg8+++P8VcqG7lKlKcJnSm7OOdKxmhiCRx3SMO R3T5Q3+eC8VuH442SbVvbD5K/RSc+HZjBY82mYWUGhbML720w78a0BhgdFPCmyiHwDEw wObxGRghBVpD9F49zNzfRrZxVCGAu/hTAJcuWeh7GMMmWvFHyMIMN26Vukt6YZvkl6A3 +q8dZkLKTDyej5Q3CWCj/w8vGJgbPcud4UPHMTs+PY9hT85MsdO1Fupyctmm5HppLMQQ L4rZMKS2ufhhcjlnnUlHXD3G4/3FpVKBGgM4QHX39AZLW0V4naRy2Ji35xkMvd5YessB z4Tg== X-Gm-Message-State: AAQBX9ek19SsXuRJQRVq7DJp2TUXJpsbJJkeY1F2bapGmfVIC932o43l stTVUoDHJi8zMQO/WD0odZtuXXPtP+Fyzw== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a81:b61e:0:b0:54f:17b6:f30a with SMTP id u30-20020a81b61e000000b0054f17b6f30amr593605ywh.4.1682049748345; Thu, 20 Apr 2023 21:02:28 -0700 (PDT) Date: Fri, 21 Apr 2023 12:02:16 +0800 In-Reply-To: <20230421040218.2156548-1-davidgow@google.com> Mime-Version: 1.0 References: <20230421040218.2156548-1-davidgow@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230421040218.2156548-2-davidgow@google.com> Subject: [PATCH v3 2/4] Documentation: kunit: Note that assertions should not be used in cleanup From: David Gow To: Benjamin Berg , Brendan Higgins , Shuah Khan , Rae Moar , Daniel Latypov Cc: David Gow , maxime@cerno.tech, Stephen Boyd , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Sadiya Kazi Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As assertions abort the test cleanup process, they should be avoided from within a suite's exit function, or from within resource 'free' functions. Unlike with initialisation or main test execution, no further cleanup will be performed after a failed assertion, potentially causing a leak of resources. Signed-off-by: David Gow --- No changes since v2: https://lore.kernel.org/linux-kselftest/20230419085426.1671703-2-davidgow@google.com/ This patch was introduced in v2. --- Documentation/dev-tools/kunit/usage.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst index 9faf2b4153fc..9f720f1317d3 100644 --- a/Documentation/dev-tools/kunit/usage.rst +++ b/Documentation/dev-tools/kunit/usage.rst @@ -121,6 +121,12 @@ there's an allocation error. ``return`` so they only work from the test function. In KUnit, we stop the current kthread on failure, so you can call them from anywhere. +.. note:: + Warning: There is an exception to the above rule. You shouldn't use assertions + in the suite's exit() function, or in the free function for a resource. These + run when a test is shutting down, and an assertion here prevents further + cleanup code from running, potentially leading to a memory leak. + Customizing error messages -------------------------- -- 2.40.0.634.g4ca3ef3211-goog