Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5821074rwb; Wed, 9 Aug 2023 09:30:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLJrDGH5/2BCP6gQ405G6BK8YZ1fepmLfCoablUzZ0+A/tcvHzB4pml7nbA0/1crrPXHKd X-Received: by 2002:a05:6a20:3244:b0:13b:a016:465b with SMTP id hm4-20020a056a20324400b0013ba016465bmr2495586pzc.19.1691598655833; Wed, 09 Aug 2023 09:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691598655; cv=none; d=google.com; s=arc-20160816; b=bXVHk6Zt5FePQksLWxkQS0N4P1+5oi9t2QHBeAgevTB9fhDaBzmFQ5nNV4FVe5MBZu 5lnLcNObQREG+yUuNSUMwbKwcJDVg7PsVMdOpM1lL2gGBVjM40/1AaQlnOlMqygK+D3I ehPYp+uZUglRI791C/rAVYA3g7q0Q2/PfdBgjkvLsCHGlCGaQ0zm3l2/MXr4nLguyJbA OpL9DfRUquNCD7LFogS2cNDcB5uDr/nYzZQFbVFYSQZYLljuSuvdR+AYALdUAWSeBu1s KcFEAIMWBneONRy6/ucfSbwhTmey2lvFGMNI+NqwwUgDy1q5jws3fo2364SOTKzTbkrh tfwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s7GI22R3yH/vG/yzGrHV/vPELeeEUsf/yheeCZUF8g0=; fh=bGF4ESczbIrmrNxFOdEMfzJNgTVkRsqDRt+LRN0CeSg=; b=DiZoQzf9KQsSkbHtMQPrESyQlGFDrtWd4tt5kxPWplW0odnGPw4mWBNGLme+Kzjy/0 M34TUQdNcAYtZBPZQYPGeDvwKjppiAPqvkPm7CpDjHfbAyvqwv0Y7IyDf+jH0HFAG9k/ g9FSnxSzOQTe3rLlPrk1O//PPp48ACfL5W6wlRWZNxrcdFvT0/yVLkXLmHQiFqt7dXWr 4mQbKSgmajXgLnWohk/QFkiLoSnNRWGCQ7CNolB8W5Npx0iRjrBS7g6z4pCu6Oi1vqhr gDFtmT99Ea7he3illr5wqhwUNT8ktLcQpwXtMDJfXik+FXfKJbajU1OkPoJmUsdIRm5M Yhqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=VdX++k4b; 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=cirrus.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e124-20020a636982000000b00564ca42aad9si7142451pgc.894.2023.08.09.09.30.43; Wed, 09 Aug 2023 09:30:55 -0700 (PDT) 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=@cirrus.com header.s=PODMain02222019 header.b=VdX++k4b; 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=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233071AbjHIPzP (ORCPT + 99 others); Wed, 9 Aug 2023 11:55:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233803AbjHIPzC (ORCPT ); Wed, 9 Aug 2023 11:55:02 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AF331FF7; Wed, 9 Aug 2023 08:55:02 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 379CrDUd002197; Wed, 9 Aug 2023 10:54:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= PODMain02222019; bh=s7GI22R3yH/vG/yzGrHV/vPELeeEUsf/yheeCZUF8g0=; b= VdX++k4bPy2xRwMBr/eJrWj5Qjcocf31cRQrN3ESC/4IWY7EV2wpkjXBrABljzgu qNAejUibJFwzwZtpuKElw6Ugf/PfWwgNCjW5Jtbxsf4PPpwJ2W1FoRUMgvVxYGQ2 HeXHHY6ZhBr+Si98LEphpNaIzhPiV3gA6RJ8gcWCIbUvw7yXOnbiC/L4CxsZacvK GdmOFBja6GfEM8BBqTzNcmGUVmdhlfTGI9qxgd1i/fWXJvPIG7SaxvIguG5T0Qn0 CMFe1m4n6B5jcl42YH5+01gtEDozaKDDX2jFK/NrfsS8slKWV+/bt4VLxqsereCt Q9Ig8HUhG3CtoBcUar2Xag== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3sb7vtanrr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Aug 2023 10:54:50 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 9 Aug 2023 16:54:48 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.30 via Frontend Transport; Wed, 9 Aug 2023 16:54:48 +0100 Received: from EDIN4L06LR3.ad.cirrus.com (EDIN4L06LR3.ad.cirrus.com [198.61.64.220]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 01D95475; Wed, 9 Aug 2023 15:54:47 +0000 (UTC) From: Richard Fitzgerald To: , , CC: , , , , Richard Fitzgerald Subject: [PATCH v3 6/7] kunit: kunit-test: Add test of logging only a newline Date: Wed, 9 Aug 2023 16:54:37 +0100 Message-ID: <20230809155438.22470-7-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230809155438.22470-1-rf@opensource.cirrus.com> References: <20230809155438.22470-1-rf@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: YMGL8l3INJVl6RSBMdHNKl7pkBt4r9hm X-Proofpoint-ORIG-GUID: YMGL8l3INJVl6RSBMdHNKl7pkBt4r9hm X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham 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 Add a test that logging a string containing only a newline appends one newline to the log. Signed-off-by: Richard Fitzgerald --- lib/kunit/kunit-test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/kunit/kunit-test.c b/lib/kunit/kunit-test.c index c079550c3afd..7e710c73c7e5 100644 --- a/lib/kunit/kunit-test.c +++ b/lib/kunit/kunit-test.c @@ -627,6 +627,12 @@ static void kunit_log_newline_test(struct kunit *test) kunit_init_log_frag(frag); list_add_tail(&frag->list, suite.log); + /* Log only a newline */ + kunit_log_append(suite.log, "\n"); + KUNIT_EXPECT_TRUE(test, list_is_singular(suite.log)); + KUNIT_EXPECT_STREQ(test, frag->buf, "\n"); + frag->buf[0] = '\0'; + /* String that exactly fills fragment leaving no room for \n */ memset(frag->buf, 0, sizeof(frag->buf)); memset(frag->buf, 'x', sizeof(frag->buf) - 9); -- 2.30.2