Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp277888imj; Fri, 15 Feb 2019 23:46:30 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia5ztLnGCmEl+WeG72zRgBoWbIKm6PeEAn5UdMn2kTO/mLfOHuicLUjylVr32mhiy03kdXI X-Received: by 2002:a17:902:f83:: with SMTP id 3mr8004277plz.125.1550303190049; Fri, 15 Feb 2019 23:46:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550303190; cv=none; d=google.com; s=arc-20160816; b=Z6gGBLGCyFCUJwQCy0SodFD3DPNvSsN71LEOPstUbNuT3pQjTz6U3y00MfPCK88D2B BURomLkQwvXHIcDdgyvjIMdtXK3WybBxDzgELWqqDz97id12HzXpEyUOAVtdCRYO5QOH NWGGivpv5drJALJoNIskjc+WABaJTRZ9QqQT5nQbsOvr+LBjfjEdkb2ygpQ4BCz8UH3a oJQglN8hyhMEeOrL2rar1bFXpq+wRPAyV6TfEj13Fjd1+kbsoiHV9vtzfunTguwIHfNi w5of9eHV7yLVolh1V8ZqzmrFhW0SeY7XwK8DfXbhqtPZxtQ7Ws5AU+EvLwTufjqSfv/e S6LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:from:cc:references:message-id :subject:user-agent:in-reply-to:to:content-transfer-encoding :mime-version:dkim-signature; bh=KcTagHaqYcrpAdIbNbDAsu4ru1cCotk2uGYlcQpAKs0=; b=uKE5UKbKS6UHfEfE9nUQ/C4RRhOURaybE4/dRSR2gnrKCQHRtem/iL/HHNy97ioSrM q0vvNEfi1VK7xMZd9pQudDmWW7SDzWn+p5dSUM3zLJDgDr+ARIq8Zt1jkbPYq4al9rV6 KGJu7ydTV8Q6jrwX54GLVRw1nQ/HQ/dJH117KEJkkALSh8wP0qzeI5Ur8tK8glEkDn9C syq/GY9HRVJkiFvHwnEhPRCZeBJrDURRu60fRvIoDvEe3pv2dxmEW8dwNv6e/s4OEd9y 95I17++s6PQqU2KTdgln3J6H4ftsAOeAEb5Ydj3IQnMAD3dEXkuq1v/OFPHo9Iskiv5r pFGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JWfILZbH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si6870638pgu.52.2019.02.15.23.46.13; Fri, 15 Feb 2019 23:46:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JWfILZbH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391764AbfBOVBw (ORCPT + 99 others); Fri, 15 Feb 2019 16:01:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:50196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387600AbfBOVBw (ORCPT ); Fri, 15 Feb 2019 16:01:52 -0500 Received: from localhost (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7B30D222A1; Fri, 15 Feb 2019 21:01:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550264511; bh=0d7/hARS75SzoprRrnLrfXPrT3UWHjpDyCJthpKQ1To=; h=To:In-Reply-To:Subject:References:Cc:From:Date:From; b=JWfILZbHsiVsxX9/tobHKR1dVqbYDSTDNnKaZAc7cPSwiEBoJ5iqz+8Pq0o65OSP5 3u8Y1Te4ON7izdwItYq7jl4qYsAzP6Vx9u87v1tY7zRvJ7lA3C67MUOPvUSWhIaaCq aPQsYpq6k0EHKd/k2YhEAjHPPCfGVxi1k/x+TCj8= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Brendan Higgins , frowand.list@gmail.com, keescook@google.com, kieran.bingham@ideasonboard.com, mcgrof@kernel.org, robh@kernel.org, shuah@kernel.org In-Reply-To: <20190214213729.21702-3-brendanhiggins@google.com> User-Agent: alot/0.8 Subject: Re: [RFC v4 02/17] kunit: test: add test resource management API Message-ID: <155026451067.115909.17082794837098610153@swboyd.mtv.corp.google.com> References: <20190214213729.21702-1-brendanhiggins@google.com> <20190214213729.21702-3-brendanhiggins@google.com> Cc: gregkh@linuxfoundation.org, joel@jms.id.au, mpe@ellerman.id.au, joe@perches.com, brakmo@fb.com, rostedt@goodmis.org, Tim.Bird@sony.com, khilman@baylibre.com, julia.lawall@lip6.fr, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, jdike@addtoit.com, richard@nod.at, linux-um@lists.infradead.org, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, dan.j.williams@intel.com, linux-nvdimm@lists.01.org, knut.omang@oracle.com, devicetree@vger.kernel.org, pmladek@suse.com, Alexander.Levin@microsoft.com, amir73il@gmail.com, dan.carpenter@oracle.com, wfg@linux.intel.com, Brendan Higgins From: Stephen Boyd Date: Fri, 15 Feb 2019 13:01:50 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Brendan Higgins (2019-02-14 13:37:14) > @@ -104,6 +167,7 @@ struct kunit { > const char *name; /* Read only after initialization! */ > spinlock_t lock; /* Gaurds all mutable test state. */ > bool success; /* Protected by lock. */ > + struct list_head resources; /* Protected by lock. */ > void (*vprintk)(const struct kunit *test, > const char *level, > struct va_format *vaf); > @@ -127,6 +191,51 @@ int kunit_run_tests(struct kunit_module *module); > } \ > late_initcall(module_kunit_init##module) > =20 > +/** > + * kunit_alloc_resource() - Allocates a *test managed resource*. > + * @test: The test context object. > + * @init: a user supplied function to initialize the resource. > + * @free: a user supplied function to free the resource. > + * @context: for the user to pass in arbitrary data. Nitpick: "pass in arbitrary data to the init function"? Maybe that provides some more clarity. > + * > + * Allocates a *test managed resource*, a resource which will automatica= lly be > + * cleaned up at the end of a test case. See &struct kunit_resource for = an > + * example. > + */