Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7311678rwb; Tue, 15 Nov 2022 10:19:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf4mI0pQ9m1uy7WRoEnlJThtq/71/FK61qj9elUBnxAAQAe64PtkJo0Hr04A4kiVX028ogWs X-Received: by 2002:a17:906:ae52:b0:7ad:4a55:5e19 with SMTP id lf18-20020a170906ae5200b007ad4a555e19mr15125376ejb.65.1668536369686; Tue, 15 Nov 2022 10:19:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668536369; cv=none; d=google.com; s=arc-20160816; b=zMjw4+6syn6CstWFXhKmMk2ASREdDPVW/K7wDsWapt7XZy4xlUko5hRR1gu9DoIawg gpQgsTP4ko9lHvP4wBNj1vNurc1GN9BSJ43zZpdcXMsfDPeUMC4MjyRxCTUCZEll/94R KR1nAhQWz8xOXi4adDaCkX4FVBfvN44uwyyODaA5mXPTXRj2wTsiXh0qRbgKN2aoSqta H82DoIulSS/sJZcG0xrrgSPXwnAR+9IoTgIUusA8i1lJn9vvtL/BsdGEYn0dLSuCYkl0 QLc/5NPIdUrhpopTpQEbe50yf7j4xRJL3URNlDWL3B+7pmNVHfZvnmnlRuWRHD3d1kNf K05g== 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=dloXDD6CiDCziJT2tHzl/Z+qUNepzcAu8WiV9q7UGjY=; b=usuRTGFLW5qsZTJHhQBgT460v1qS6ts3G7tvJ9uWXnDPZjfUN/y6WaAv2fJrVh0aLj mwxBeehffCzHQeN/MEqOo3YIyfBC3IirAsiVRI3A16HZYWu+8k7Fx7OjVSAgtg+tm/T8 zKPBOMVsGP7yom2XLKUafBfCNJHOZabeHHQF0ZbOzV6CSgf/5XRsfpRkr7WZFiYrgJHw i/ArG7NC2jZ5NI0jGrIVlFEU16Wj1czC8TOe8+tHqnurfAWczpdVO+chZ14uBQysEs9t Gyl4K6r8E94C4KSy0sr5OchfjgmePbYBZR0by1rNXI4hnWoeLbwyipRzAWwdYOfOECYK 6WZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=JYgZvPF0; 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 qw18-20020a1709066a1200b00773db351c39si11829515ejc.64.2022.11.15.10.19.07; Tue, 15 Nov 2022 10:19:29 -0800 (PST) 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=20210112 header.b=JYgZvPF0; 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 S230034AbiKOSHZ (ORCPT + 90 others); Tue, 15 Nov 2022 13:07:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231601AbiKOSHQ (ORCPT ); Tue, 15 Nov 2022 13:07:16 -0500 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EC7313F10 for ; Tue, 15 Nov 2022 10:07:15 -0800 (PST) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-382f0906929so53345157b3.10 for ; Tue, 15 Nov 2022 10:07:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dloXDD6CiDCziJT2tHzl/Z+qUNepzcAu8WiV9q7UGjY=; b=JYgZvPF0ht9E2Q56igI2aIXCY5xA0bGmnckBjD/RIFHLRkjtv+/pzXCHaKmZK8RC7T 6nUGxAAbze5gI9EG7y5ZeS91Bjcq/ugdpKVdvkPU8iQZyglm6cX4SR3aE4ZsaCVXLqMP zZhIz9hAmeTrQ7lJfst/DoWgh42xSvNNX6OE5Up7hw/mziRWidAHgSkSxaNbKcw93dtd 1y+zFP3GPZTnVy6MQz9QEAbvl7MaC0lbNSm6CLtg/0DJc7RIt5bOGrTNMbeif4XsbXPu MBuJ26Zik/sPd/TWdYNnzMdJ/ofCt5U6qktYv7fHZIzqh+IUBTqpxihgAGdnGMxfKRLO nUOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dloXDD6CiDCziJT2tHzl/Z+qUNepzcAu8WiV9q7UGjY=; b=Un3MPCHPdKho+RBgw/rGJse9uobnBgSRcgA3iIA2BNgeqHkLVSBr0RUur9b/fFVoHi 7UzS1e6Z+CmDyXYXwmq7fa/lcB8yFPx7ROAbFa/+f4jnli66AHY95fJKgC4Tjfv9Arsg jtCX+1yn/4dNK2fZq/jxriOeNm/ijSXQldkSf7NtpNS0EV6yn4XEkpM5TgH0T9brQNKZ XUl69SU9N9PyqvNz5DBClxK3M6J8f+gcOpbZXPlIkzHQXZ62sBk1tZVZtkEhSp7owa0O gEJz70f1R9lh5apGXfsIS3uJKbksFa3wCjcI/SXouPIvd94BsSty3J0wz+5xSVH9pDTp Nq/A== X-Gm-Message-State: ANoB5pmoFuyRQDmthC8ErSYpSwrV9Hba0vjTRZX0NekmowV2f1nXUH0T EKyql7TrgzIjY6Gmz3L1nE+WnCgjcndqkcgMbAzDLA== X-Received: by 2002:a81:351:0:b0:344:ff29:4526 with SMTP id 78-20020a810351000000b00344ff294526mr18583621ywd.63.1668535634314; Tue, 15 Nov 2022 10:07:14 -0800 (PST) MIME-Version: 1.0 References: <20221109003618.3784591-1-dlatypov@google.com> <20221109003618.3784591-2-dlatypov@google.com> In-Reply-To: From: Daniel Latypov Date: Tue, 15 Nov 2022 10:07:03 -0800 Message-ID: Subject: Re: [PATCH v2 2/3] Documentation: KUnit: reword description of assertions To: David Gow Cc: Sadiya Kazi , brendanhiggins@google.com, rmoar@google.com, linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, skhan@linuxfoundation.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 On Mon, Nov 14, 2022 at 11:45 PM David Gow wrote: > +1 for the patch from me (modulo the "we" typo Sadiya mentioned). > > I otherwise also prefer Daniel's original here (though I'd possibly > merge it into one sentence, personally). > Maybe: > "In this example, as we need to be able to allocate an array in order > to test the sort function, we use ``KUNIT_ASSERT_NOT_ERR_OR_NULL()`` > to abort the test if there's an allocation error." > or > "In this example, we need to allocate an array to test the sort > function. We therefore use ``KUNIT_ASSERT_NOT_ERR_OR_NULL()``, which > will automatically abort the test if there's an allocation error." > > But any of the above wordings are fine for me. > > The note about ASSERT() working in any function is useful, though > there are definitely some "gotcha"s caused by killing the kthread > we'll need to resolve. (If there are any dangling references to things > on the stack, for example.) Still, not an issue for this bit of > documentation. > > Reviewed-by: David Gow > > (Once the "we" typo is fixed.) v3 is here, PTAL https://lore.kernel.org/all/20221111182906.1377191-2-dlatypov@google.com/ Copying the relevant section here: +In this example, we need to be able to allocate an array to test the ``sort()`` +function. So we use ``KUNIT_ASSERT_NOT_ERR_OR_NULL()`` to abort the test if +there's an allocation error. + +.. note:: + In other test frameworks, ``ASSERT`` macros are often implemented by calling + ``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. Daniel