Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4456637imu; Fri, 30 Nov 2018 18:09:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xj65wVfLiOUvAHahUVipOtgVSLHw6VaOe5rxVE9rmjYTu6t++AtR3Rui2obVGZJyWtHosx X-Received: by 2002:a62:3948:: with SMTP id g69mr7980235pfa.114.1543630179208; Fri, 30 Nov 2018 18:09:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543630179; cv=none; d=google.com; s=arc-20160816; b=d0mSUAV5zM0UYgCkcrAiZWsknmISNVy2phY6C1faEEk/BDWaDeudonf4+KSMsc74JN wVLhG7AfMbc4Ng0uQM+G/8uofkwPA0ZX1NyIIZClsTmOUANt+VzYhxkooHQ9HTVRggmD jnuuPWlSV+D2Re5+TWPsa0GQDbbNZcfKAym2Hg+/HwQBf6eMiSHOHKdXyn1BhZUZUkKL TWEEsnAp315Wg1o1fkB1HC6mngarBPP91+N1Hi2YER58IvIP7hP1MO6cOXbufcHu0fAO ODG0xyuynPrKeGePBQ+jpEcOCSFDNSrct3io6T/rLDqotDtUzVK1F+1jPL1nSwnO06nO s0Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=VdfIe7+VxwPLFKcKXYB9P/WieXnBdcv7g7QGMIAOBz0=; b=XhBenNSYbZRPqwQRu6X4xx4L3ksRU2aMTTegIRVxE00Bz/T21bG059eDxUYV1YG2pd PgEf0kzkYRIuY2wsbU6SvCpuFe+YNCZuAOFPkHmplqcvcS+4YRDvI3ClhpP6iX7Wom4X KMk+HrzI+KVhaGVbQwVKvHEnIinyHYtaqAJxjyvYjyIx/wF4Oey7y2s0f4OuJQnkYEJd 1BYxlduNKeoIVszKYHr311d88AkMw6pJR2QwVJUy2b3f7PC2YXSyWjsIl1ubQwYz4lsj Qg/dEk2PD6SqhMOpLcXMHb6Rso2l6Xc9uctAHI2Ls6qz9DUjGkzGRTrXMybxxes3/Ccx 9n6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Sbi4dxUG; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id go15si7264459plb.219.2018.11.30.18.09.24; Fri, 30 Nov 2018 18:09:39 -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=@google.com header.s=20161025 header.b=Sbi4dxUG; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726679AbeLANUJ (ORCPT + 99 others); Sat, 1 Dec 2018 08:20:09 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:43128 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbeLANUI (ORCPT ); Sat, 1 Dec 2018 08:20:08 -0500 Received: by mail-ot1-f68.google.com with SMTP id a11so6882651otr.10 for ; Fri, 30 Nov 2018 18:08:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VdfIe7+VxwPLFKcKXYB9P/WieXnBdcv7g7QGMIAOBz0=; b=Sbi4dxUG4nwVMYT/J6jCAbUel9qcHcl3iIc4yfUCia+USkaMAEipBeMO9MMWpqew5n 0WvExpaiRTB3TE6op+OKWYAZwEsBwNXaNEYyw0VH9flxmQ4ctaxSrIaYthTT9yV+nKBB a4H4y5VhyVvwCDcEPCZYjtQwcw1coWeozTL5hTRzNXov/NAjWhCu8WP6MlBXv98tTR20 FVtJFzkvlpeykaDKn+NJlLcqTQYCqmFqpEQA6Lh7yoxB3Py//pWuwzRJaCoLL4VI1eXU UDTHN6qSxqSfXwkq6TG6zg/NUEKnXD5L7f5StM0WiV3h/pOIXoemC5eJR8e31iFs21xI TYtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VdfIe7+VxwPLFKcKXYB9P/WieXnBdcv7g7QGMIAOBz0=; b=TsEqG21OBLgmzCAVUi3pXAp+uA0MfENOJf1aZFcHlj65u5K2l2QhIeU0fflK7VtsJQ prHctVF/CRaIHSa5oCzb5XctIV9tlTQ4JnJPIhHvWkwKg3TViBbsB1phf4SdTw3AthQl vOLBKFOV+9aAlUCmKSNKUNanV9UhvH9FcvHJggXlhvjUaQ7kBhf+tGmVZUS2dS05ZW/1 c/H0YMWQBiy6xHyQH3ynBaxBaF0d5o2PCrbhP6IjlCG1lYpVi5X0qTUuNWdLiGGAjRv0 o5SQTPT5a2ZWojr2rhu0N/i55j/mXIKtZBe0u1j2RUsna4AMcAg7RhzetlvEkOJy/zfC 52mw== X-Gm-Message-State: AA+aEWbm3BMERc8XECEAWVbB3oqF+Yew6oUCyIeZ9EC30jx9A7mhJ96T gE5unJhnCk/OxUm8rGZ1NG4ZLholEbESN0/SlYyH6w== X-Received: by 2002:a9d:5549:: with SMTP id h9mr4631361oti.83.1543630127325; Fri, 30 Nov 2018 18:08:47 -0800 (PST) MIME-Version: 1.0 References: <20181128193636.254378-1-brendanhiggins@google.com> <20181128193636.254378-2-brendanhiggins@google.com> <20181130032802.GG18410@garbanzo.do-not-panic.com> In-Reply-To: <20181130032802.GG18410@garbanzo.do-not-panic.com> From: Brendan Higgins Date: Fri, 30 Nov 2018 18:08:36 -0800 Message-ID: Subject: Re: [RFC v3 01/19] kunit: test: add KUnit test runner core To: mcgrof@kernel.org Cc: Greg KH , Kees Cook , shuah@kernel.org, Joel Stanley , mpe@ellerman.id.au, joe@perches.com, brakmo@fb.com, rostedt@goodmis.org, Tim.Bird@sony.com, khilman@baylibre.com, Julia Lawall , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Linux Kernel Mailing List , jdike@addtoit.com, richard@nod.at, linux-um@lists.infradead.org, Daniel Vetter , dri-devel@lists.freedesktop.org, Rob Herring , dan.j.williams@intel.com, linux-nvdimm@lists.01.org, kieran.bingham@ideasonboard.com, Frank Rowand , Knut Omang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 29, 2018 at 7:28 PM Luis Chamberlain wrote: > > > +static void kunit_run_case_internal(struct kunit *test, > > + struct kunit_module *module, > > + struct kunit_case *test_case) > > +{ > > + int ret; > > + > > + if (module->init) { > > + ret = module->init(test); > > + if (ret) { > > + kunit_err(test, "failed to initialize: %d", ret); > > + kunit_set_success(test, false); > > + return; > > + } > > + } > > + > > + test_case->run_case(test); > > +} > > <-- snip --> > > > +static bool kunit_run_case(struct kunit *test, > > + struct kunit_module *module, > > + struct kunit_case *test_case) > > +{ > > + kunit_set_success(test, true); > > + > > + kunit_run_case_internal(test, module, test_case); > > + kunit_run_case_cleanup(test, module, test_case); > > + > > + return kunit_get_success(test); > > +} > > So we are running the module->init() for each test case... is that > correct? Shouldn't the init run once? Also, typically init calls are Yep, it's correct. `module->init()` should run once before every test case, reason being that the kunit_module serves as a test fixture in which each test cases should be run completely independently of every other. init and exit is supposed to allow code common to all test cases to run since it is so common to have dependencies needed for a test to be common to every test case. Maybe it is confusing that I call it kunit_module? Maybe I should call it kunit_fixture or something? > pegged with __init so we free them later. You seem to have skipped the > init annotations. Why? Like I said above, these aren't normal init functions. A kunit_module->init() function should run once before each test case and thus should reside in the same linker section as any other KUnit test code. Cheers