From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A59D8C43334 for ; Tue, 7 Jun 2022 19:24:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238463AbiFGTYT (ORCPT ); Tue, 7 Jun 2022 15:24:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354192AbiFGTWr (ORCPT ); Tue, 7 Jun 2022 15:22:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78FAA2DC3; Tue, 7 Jun 2022 11:09:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A13E26191F; Tue, 7 Jun 2022 18:09:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC936C385A5; Tue, 7 Jun 2022 18:09:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654625347; bh=1CltcFnzp83Lp3shBByI0qoMgoRiBqUKG72OG4ryCK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UYw6uwSgwEt9NdOs0Bo1hqlGbFzkVWJ7JJ2w2zU14OcUzrkcSTBMD6Pmq+0QIwi08 i2K4i5AWZbSITjyyp39fdIZpdUpKpmVeAQqpmkJC+5+wMlv5zxR65cY+HpbSr+8C4d hBZ6hVhcmRKSuQJ78XGLIMhsoKLIuVogmWwbAs3o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Gow , Daniel Latypov , Brendan Higgins , Andy Shevchenko , Shuah Khan Subject: [PATCH 5.15 652/667] list: test: Add a test for list_is_head() Date: Tue, 7 Jun 2022 19:05:17 +0200 Message-Id: <20220607164954.205666782@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164934.766888869@linuxfoundation.org> References: <20220607164934.766888869@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: David Gow commit 37dc573c0a547e1aed0c9abb480fab797bd3833f upstream. list_is_head() was added recently[1], and didn't have a KUnit test. The implementation is trivial, so it's not a particularly exciting test, but it'd be nice to get back to full coverage of the list functions. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/linux/list.h?id=0425473037db40d9e322631f2d4dc6ef51f97e88 Signed-off-by: David Gow Acked-by: Daniel Latypov Acked-by: Brendan Higgins Reviewed-by: Andy Shevchenko Signed-off-by: Shuah Khan Signed-off-by: Greg Kroah-Hartman --- lib/list-test.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) --- a/lib/list-test.c +++ b/lib/list-test.c @@ -234,6 +234,24 @@ static void list_test_list_bulk_move_tai KUNIT_EXPECT_EQ(test, i, 2); } +static void list_test_list_is_head(struct kunit *test) +{ + struct list_head a, b, c; + + /* Two lists: [a] -> b, [c] */ + INIT_LIST_HEAD(&a); + INIT_LIST_HEAD(&c); + list_add_tail(&b, &a); + + KUNIT_EXPECT_TRUE_MSG(test, list_is_head(&a, &a), + "Head element of same list"); + KUNIT_EXPECT_FALSE_MSG(test, list_is_head(&a, &b), + "Non-head element of same list"); + KUNIT_EXPECT_FALSE_MSG(test, list_is_head(&a, &c), + "Head element of different list"); +} + + static void list_test_list_is_first(struct kunit *test) { struct list_head a, b; @@ -710,6 +728,7 @@ static struct kunit_case list_test_cases KUNIT_CASE(list_test_list_move), KUNIT_CASE(list_test_list_move_tail), KUNIT_CASE(list_test_list_bulk_move_tail), + KUNIT_CASE(list_test_list_is_head), KUNIT_CASE(list_test_list_is_first), KUNIT_CASE(list_test_list_is_last), KUNIT_CASE(list_test_list_empty),