Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp198829pxb; Tue, 28 Sep 2021 19:21:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb/fDCOOFhpeafMzuOuexdFDtUnACyhL5pU4K9BCAePoScCiebYwXpVWOx3yBVBu4mbQBH X-Received: by 2002:a65:63d0:: with SMTP id n16mr7559464pgv.432.1632882106244; Tue, 28 Sep 2021 19:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632882106; cv=none; d=google.com; s=arc-20160816; b=Shx89Fpgcigy6qtY+zPiCHN2mEktjAipcxt/osYr9taI1lzbwVoqd3ZFL0zMbWrbq/ r4gJa0VgNED6Ts2VlTwdMCuJrowTmRADMCBEa81BaWI9ptT64fsy3l6lTUt1SN6tcLjN BQblneEptqv0Y5h0zyMBKMNmQNn9mVSVJ45mRnHeTcL9mzQDsWjAyfHqkdK5vyUzUPE2 UIBAO50f/VIZlC0REl2nLlQ5NqBLmG1q2BUh3bZRw4lNquSF2ho9zzqzfmZE7cRDxa2Q ufIAbdZhylLs/zV4zh9EsOmPGHFZIuYjrYW3+pLAPt5Abq3hS86VO2Em+SUcfwJ9IHMj nC4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=3ncHSqeWvmQnAH4fmEz/nsHqUsBXIb6xkEvRSYXpDRo=; b=JsFU+4VWOkQyvoAgamDAOP/fG/vWpEozPQyq8dwyU+kDjEHOK0tnGNz6yChxvptNtp 7lctE0bFnpe6zhbxV/MOubyRlqNjlBB6noG4a9pswkhiDrZN9Lzh1g+lTrt8/iNVtyco UtK6m3IP4Db3d3/X9nzIPL/4Sq7Gap/tTqC7DLOVlvSXSv0J1Ut7Vm46FdH1BJtrQiS1 UDLe4JUjRQ+7fCz2fsue+y9KXzmJA+YdhurgjiBXr/eTP3svzYhSHAsCD3qHTNyErPv8 pcIAtT0BkFKMKJw0aDUxNaFZbCfsPrsdR2IMcB5t+1i/iK7pNjKvpUql9xaZcM9B+lQ6 H+bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cgfujflT; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si1073308pgp.630.2021.09.28.19.21.33; Tue, 28 Sep 2021 19:21:46 -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=@google.com header.s=20210112 header.b=cgfujflT; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243724AbhI2COR (ORCPT + 99 others); Tue, 28 Sep 2021 22:14:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243660AbhI2COR (ORCPT ); Tue, 28 Sep 2021 22:14:17 -0400 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36E2BC061745 for ; Tue, 28 Sep 2021 19:12:37 -0700 (PDT) Received: by mail-il1-x12a.google.com with SMTP id w1so1183233ilv.1 for ; Tue, 28 Sep 2021 19:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3ncHSqeWvmQnAH4fmEz/nsHqUsBXIb6xkEvRSYXpDRo=; b=cgfujflTOgMlCBvsPEW6ttFA5E2snmFqB9X3p0JX6mWK2Yrs/kIYyG59fADC8DZblc APjzHj1f8JQskgXuFj2epjqrQLgjI+gtvxFetIC5/a562j5WWQFwc+VTEU6RSdu8Ar+W czQSxYbAd2uKnaAGjmeq3CCErsNHHE2GpZ7u78V0Pf8gYUe3OBRMdvFY1kn46WuVvXSB R1/GRKK16Twy1oPRbr+mHY6MIFiV80vc61xA6z9Rnv9kAOgr6FN8s1dlh3fKcxUAM9Ef EGrZL91luO4XHm4EbCap8EUsvZXUfiVythEAL0LXDuARb2gv5uJpam+ehHBFzutr3bMA ZSIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3ncHSqeWvmQnAH4fmEz/nsHqUsBXIb6xkEvRSYXpDRo=; b=iXzYkLziptu8hBWQl9R+HwyEa+kri16LDHphy1yR64GaXIkpcHwq3FGeBNXt/WU/tC CEP+Sh8EjAQmedTDi/TFxNsHMqirmH85gfb9LKtUmHpCt4NzFaPQ9QbWnAGd8OBjt+m3 j3C93I+24439YDZbwdPcJ2hqv4H5g/6BoNZFd2BFgxT7l4wtGaBlSWe65iom7UtVOFGV XW0qsNL/Ihvn048q0hnlBn7OW6yvhsE5me6icKnqYhpdxxEh07yqInhhyY7MET3w0U3S MzGNG7f2n26q6J/v+PobfrsI5vSWbA+bfGiKsMUh2VbIqEI0U0YrezA0tE673P2eqFl2 4xEA== X-Gm-Message-State: AOAM533c5BUkSMQWwz7o9+aHCoEUswSe7Lxgk1TTnds04eh7F3FNPCMx q1rDfkWHtDfQ2feQ7yfdAkT6uYCKJxsUOvInbn8mgQ== X-Received: by 2002:a92:b301:: with SMTP id p1mr6366328ilh.10.1632881556082; Tue, 28 Sep 2021 19:12:36 -0700 (PDT) MIME-Version: 1.0 References: <20210928221111.1162779-1-dlatypov@google.com> In-Reply-To: From: Daniel Latypov Date: Tue, 28 Sep 2021 19:12:25 -0700 Message-ID: Subject: Re: [PATCH] kunit: tool: misc fixes (unused vars, imports, leaked files) To: David Gow Cc: Brendan Higgins , Linux Kernel Mailing List , KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , Shuah Khan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 28, 2021 at 5:34 PM 'David Gow' via KUnit Development wrote: > > On Wed, Sep 29, 2021 at 6:11 AM Daniel Latypov wrote: > > > > Drop some variables in unit tests that were unused and/or add assertions > > based on them. > > > > For ExitStack, it was imported, but the `es` variable wasn't used so it > > didn't do anything, and we were leaking the file objects. > > Refactor it to just use nested `with` statements to properly close them. > > > > And drop the direct use of .close() on file objects in the kunit tool > > unit test, as these can be leaked if test assertions fail. > > To clarify for a python novice: this is referring to using "with" so > that the file isn't leaked if the assertion fails, rather than > suggesting that leaks are okay for failing tests, right? Correct. Ah, I see how it can be misread now. But on that note, it's probably fine to leak the files as CPython should close the file object during GC. And tests failing should make those file objects go out of scope immediately. > > > Signed-off-by: Daniel Latypov > > --- > > These all seem sensible to me. Thanks for cleaning this up! > > Reviewed-by: David Gow > > -- David > > -- > You received this message because you are subscribed to the Google Groups "KUnit Development" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/CABVgOS%3D0K78N%2BKMK3km5TKVDD9L8AMRpNCfvihCqU2h3U-oE-w%40mail.gmail.com.