Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1437091yba; Wed, 24 Apr 2019 22:58:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhibb1EZCqv+zTu8o8VAcHVWuQfZ0MAH3MFVffjk37Ggjtmr231maXCaZQrtLDodGjr66D X-Received: by 2002:a17:902:9a83:: with SMTP id w3mr37548018plp.241.1556171938058; Wed, 24 Apr 2019 22:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556171938; cv=none; d=google.com; s=arc-20160816; b=wf08cQHY0KqHghzIxLJedKPJFQotrqIauAh95+YSURdS8xFkWPgnlT7zGEgrQPi6sn mZHeBa87kp4/kKGceimnihETcNX+REXMyWReAWTimQP2EI8hixB7uTGdiXTSMsj1mSTP BAGhmzZRj8XAcdsjkrDHrsF9LpdSJIaU8C6USfa4QY90cCd/jmg6NqGAZkrzZs+MzaEr ouYYalDZEcpL38fF3AfF6Vd46oCHZrj4Zb9XRd3DTiUhzoX3eVBHUFZ9xF9zwCFXbNkz FQbP3V/N7AbSlYb6/smAtNb0+9om3v0ZT/zARLCNaMXs8rpz70aph1P8f2fZidEOdzWC l4Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2UctWeOPYH7gh4xbfG1yAVrMDrr9BA28kij+L+zI8ew=; b=w/5/GUf/AxUGBoFmSfAezJupLeNjlkmsnJoocl5ZWznne6nRPRf/oYz7uDryIbyvng eSjkP+sIgSS90lfn0xeshGUF9wzU4FQa8TGrcRKerlZ/TXQPYdrNkhegPlE+kmPqP4na KorKsl6lEtJAm6roAlMHTuhp7SWJ8g9A0SAk2DKVjJHb1C8EUJFXzQ4iep7EG0amw3gy hoaaz0yCybmNhJgO8JVsPYxrlGiW8JeiGQ6naq0sJi6Xp2RMlXNq2lOCXMeZ5aQEgu6d FZkUUd5i7SPBguXtv8w8aDnFhMjFMnxYwInTzGpqBEncuq9lz3g0Coq0p3zc1Ur3p8rh /jOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CLotHtY+; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u6si21316729pfh.265.2019.04.24.22.58.42; Wed, 24 Apr 2019 22:58:58 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=CLotHtY+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388320AbfDXS60 (ORCPT + 99 others); Wed, 24 Apr 2019 14:58:26 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:33974 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727055AbfDXS6Z (ORCPT ); Wed, 24 Apr 2019 14:58:25 -0400 Received: by mail-qk1-f193.google.com with SMTP id n68so11540744qka.1; Wed, 24 Apr 2019 11:58:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=2UctWeOPYH7gh4xbfG1yAVrMDrr9BA28kij+L+zI8ew=; b=CLotHtY+q8bXpvMX/SmQYLYdHZDyptDBtVd2cOQxdfaESxO2GsaKBrVF49T8XhHBCG Szqjxn5y7AoftBOAS7GPEHxEAWyzpAK2xrGl2bZBmHGrZ+rjWzBZObsUloOpGA8UTEQZ kZQUgRbPVKQ9r3GhKJgmOXE/mrXnfkT0RfZRB7ybzGmJPsfAwouSLyKmAjjiJGiqn7OP Cvt7SiavnNk5zXR6a6jFgB4tjsojrv5Az9VpqVXcJjpKcJ14M55qHMrYQDwyBrPy9xu8 GzkveWV12G8hWu9HkoHepAdt5dv7rStCnYO8qRP82Q9471RkyW7m8IH6sRVxInSuA1aC 4yxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=2UctWeOPYH7gh4xbfG1yAVrMDrr9BA28kij+L+zI8ew=; b=NncOPWAGT+Z8jhL/FERUSTVw/VKvHpIn12dCtptDgpquk4nRvGUJapk6OYrdX+jkl2 tYxAILOgKytuqj/AxcClc6gZgCsBpliuIopH6YQTFXDdUZ076ERcbTSRuZCQi7heOz5V 0WBCkB3DY1acKNkCFcJtvArsIwvLZoGwWifOIGXIl02/DLUIa9BxZMbR7OqVUGG2ccLA XIxXHrdvz/oKwh2kH/XiCs+7KuX4pTdglapqX2r4q4DWdED9VaMcm8shPtTaSr1IfCVX +3pP27y50SjFxokzPUf1zX3ACgI8mGhmjK4XpmY1ySQQYFEM4kC3H+w7t0Q3seDKkqul LYpA== X-Gm-Message-State: APjAAAUdpBQt/v3GhraOCdcXin0DuaUN9a7NwLIKSiqlkngaPMMOJM1d o4emcW5O73WTObtKSC4nnqxuUHk= X-Received: by 2002:a05:620a:1334:: with SMTP id p20mr1205504qkj.244.1556132304679; Wed, 24 Apr 2019 11:58:24 -0700 (PDT) Received: from gabell (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id h189sm564936qkc.89.2019.04.24.11.58.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2019 11:58:23 -0700 (PDT) Date: Wed, 24 Apr 2019 14:58:14 -0400 From: Masayoshi Mizuma To: Brendan Higgins Cc: corbet@lwn.net, frowand.list@gmail.com, keescook@google.com, kieran.bingham@ideasonboard.com, mcgrof@kernel.org, robh@kernel.org, shuah@kernel.org, yamada.masahiro@socionext.com, pmladek@suse.com, linux-doc@vger.kernel.org, amir73il@gmail.com, dri-devel@lists.freedesktop.org, Alexander.Levin@microsoft.com, linux-kselftest@vger.kernel.org, linux-nvdimm@lists.01.org, khilman@baylibre.com, knut.omang@oracle.com, Felix Guo , wfg@linux.intel.com, joel@jms.id.au, jdike@addtoit.com, dan.carpenter@oracle.com, devicetree@vger.kernel.org, linux-kbuild@vger.kernel.org, Tim.Bird@sony.com, linux-um@lists.infradead.org, rostedt@goodmis.org, julia.lawall@lip6.fr, kunit-dev@googlegroups.com, richard@nod.at, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, daniel@ffwll.ch, mpe@ellerman.id.au, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v1 14/17] Documentation: kunit: add documentation for KUnit Message-ID: <20190424185813.xabwr4lt6aunvpsd@gabell> References: <20190404220652.19765-1-brendanhiggins@google.com> <20190404220652.19765-15-brendanhiggins@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190404220652.19765-15-brendanhiggins@google.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Brendan, KUNIT_ASSERT_NOT_ERR_OR_NULL() should be replaced to KUNIT_EXPECT_NOT_ERR_OR_NULL(), right? On Thu, Apr 04, 2019 at 03:06:49PM -0700, Brendan Higgins wrote: > Add documentation for KUnit, the Linux kernel unit testing framework. > - Add intro and usage guide for KUnit > - Add API reference > > Signed-off-by: Felix Guo > Signed-off-by: Brendan Higgins > --- > diff --git a/Documentation/kunit/start.rst b/Documentation/kunit/start.rst > new file mode 100644 > index 0000000000000..5cdba5091905e > --- /dev/null > +++ b/Documentation/kunit/start.rst > +Assertions > +~~~~~~~~~~ > + > +KUnit also has the concept of an *assertion*. An assertion is just like an > +expectation except the assertion immediately terminates the test case if it is > +not satisfied. > + > +For example: > + > +.. code-block:: c > + > + static void mock_test_do_expect_default_return(struct kunit *test) > + { > + struct mock_test_context *ctx = test->priv; > + struct mock *mock = ctx->mock; > + int param0 = 5, param1 = -5; > + const char *two_param_types[] = {"int", "int"}; > + const void *two_params[] = {¶m0, ¶m1}; > + const void *ret; > + > + ret = mock->do_expect(mock, > + "test_printk", test_printk, > + two_param_types, two_params, > + ARRAY_SIZE(two_params)); > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ret); KUNIT_EXPECT_NOT_ERR_OR_NULL(test, ret); > + KUNIT_EXPECT_EQ(test, -4, *((int *) ret)); > + } > + > +In this example, the method under test should return a pointer to a value, so > +if the pointer returned by the method is null or an errno, we don't want to > +bother continuing the test since the following expectation could crash the test > +case. `ASSERT_NOT_ERR_OR_NULL(...)` allows us to bail out of the test case if +case. `KUNIT_EXPECT_NOT_ERR_OR_NULL(...)` allows us to bail out of the test case if Thanks! Masa