From patchwork Sat Feb 5 06:15:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 540221 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 86E1EC433F5 for ; Sat, 5 Feb 2022 06:16:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354426AbiBEGQ2 (ORCPT ); Sat, 5 Feb 2022 01:16:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351751AbiBEGQ0 (ORCPT ); Sat, 5 Feb 2022 01:16:26 -0500 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94663C061347 for ; Fri, 4 Feb 2022 22:16:06 -0800 (PST) Received: by mail-pj1-x1049.google.com with SMTP id x4-20020a17090ab00400b001b58c484826so10066420pjq.0 for ; Fri, 04 Feb 2022 22:16:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=vV1A3NKa8ohktKkIEGZo1VCH/ZlIgtA2YFnmP/ZP+iE=; b=l6dtqMZg2rtStETNCrBqau9WjMDhnM2XTGBgVwNv/XeiFQRQHDE7ovqTiPuzEtjHMj //gBIsUAXp+8CJQzrip2BLwNWg+dxcvGmHqADds+7h3+2s+Hm/TtoD+gDdk30KWC4+cv u30e1ul6b6ea5RjS1/R+ccQKRsiYz/0hBG6s+BTwjS6jtNvj5CWffFTtT7KlBnRRbrFd uXyv1K4hS6Ij9SFk7m+fPO4DM280BQSQx2EBcsAR2FBFw2dcbX2/aKcsuMDS1NLqvmX8 LTcH8BQBDCUSG+Nlp+/CVo27prma3RF+Vp9hIrBEshuLAhb50zi5d9g5F7XiDm4pSeLv Ndig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=vV1A3NKa8ohktKkIEGZo1VCH/ZlIgtA2YFnmP/ZP+iE=; b=ZDjhzGj5PLRq773QUNahJDbQFkSnPqhXSPKGZiSsOfmxYHp/2tBGlWn5v5A7bmQwwr 1JQTOMVLBjzwXRdhc/QatOIZuYjAf4A4aBdSXgyfKRDu8mA0d429RLSLlKrkJZfWQKpx MTVJ6OhFJk2xsIWL/Yf8JaEUy6U81jsWQf8u5uU9zH8mdsnrS+sUcUyqjJdO81yZEbGr 0cnBX5iqMPKJ6yLbq5/o6jeZ12iMZUXz0uWyqaWWwRh/rFpPPk2GavB5jTyUTrwzCADy XiZmOUxX6LrrRrDVqdRcqFEqDQaWtOh2NxKf584CYSVf0nwUB+6chmwN7F64ghItiZck xECQ== X-Gm-Message-State: AOAM533huAmASdxdvuLL6hFsbd+UcfU8jMcSPQwck4Oec2zy6227G1U+ qPuqFmljv6UyTOCYK6WiVCiBB7Wqx8K2aw== X-Google-Smtp-Source: ABdhPJyZdn33EiW+IAbpGPjVLz9f0aWxmwA0TrAs0tV5/qpiJgyy9Ff42kGHtC/0zn55iAJaLT/ThnAhz7On1w== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a63:1315:: with SMTP id i21mr2004840pgl.10.1644041766044; Fri, 04 Feb 2022 22:16:06 -0800 (PST) Date: Sat, 5 Feb 2022 14:15:36 +0800 Message-Id: <20220205061539.273330-1-davidgow@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH 1/3] list: test: Add test for list_del_init_careful() From: David Gow To: Shuah Khan , Andy Shevchenko , Linus Torvalds , Brendan Higgins Cc: David Gow , Daniel Latypov , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The list_del_init_careful() function was added[1] after the list KUnit test. Add a very basic test to cover it. Note that this test only covers the single-threaded behaviour (which matches list_del_init()), as is already the case with the test for list_empty_careful(). [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c6fe44d96fc1536af5b11cd859686453d1b7bfd1 Signed-off-by: David Gow --- lib/list-test.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/list-test.c b/lib/list-test.c index ee09505df16f..976e9ae1f3c5 100644 --- a/lib/list-test.c +++ b/lib/list-test.c @@ -161,6 +161,24 @@ static void list_test_list_del_init(struct kunit *test) KUNIT_EXPECT_TRUE(test, list_empty_careful(&a)); } +static void list_test_list_del_init_careful(struct kunit *test) +{ + /* This test doesn't check correctness under concurrent access */ + struct list_head a, b; + LIST_HEAD(list); + + list_add_tail(&a, &list); + list_add_tail(&b, &list); + + /* before: [list] -> a -> b */ + list_del_init(&a); + /* after: [list] -> b, a initialised */ + + KUNIT_EXPECT_PTR_EQ(test, list.next, &b); + KUNIT_EXPECT_PTR_EQ(test, b.prev, &list); + KUNIT_EXPECT_TRUE(test, list_empty_careful(&a)); +} + static void list_test_list_move(struct kunit *test) { struct list_head a, b; @@ -707,6 +725,7 @@ static struct kunit_case list_test_cases[] = { KUNIT_CASE(list_test_list_replace_init), KUNIT_CASE(list_test_list_swap), KUNIT_CASE(list_test_list_del_init), + KUNIT_CASE(list_test_list_del_init_careful), KUNIT_CASE(list_test_list_move), KUNIT_CASE(list_test_list_move_tail), KUNIT_CASE(list_test_list_bulk_move_tail), From patchwork Sat Feb 5 06:15:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 540459 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 A8B25C4332F for ; Sat, 5 Feb 2022 06:16:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351751AbiBEGQ2 (ORCPT ); Sat, 5 Feb 2022 01:16:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351914AbiBEGQ0 (ORCPT ); Sat, 5 Feb 2022 01:16:26 -0500 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C54FC061348 for ; Fri, 4 Feb 2022 22:16:11 -0800 (PST) Received: by mail-pg1-x549.google.com with SMTP id u24-20020a656718000000b0035e911d79edso3884861pgf.1 for ; Fri, 04 Feb 2022 22:16:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=tmuYmC0m8mvbfJAxQIBdx9zkbWIC9B6I2Z9WuJhYmSE=; b=ITilSpV3LDAPKoHX4WCaVmDBD0RUDgc9gX30+niTgT6rdP6U6Hfi7J9r5kWQDJgSSx rTlShTgwa8Vr/bzieViJX5pXG4hD/ZFg/vJNbLwsF/EPHo1tIpdTh3Utl72TIH6I7ZXl KYFxYXoMdfMtCetm5wReVbMZbcDu+3Mk2YGA3qpA5CX2jB6rN08eNuiWuwZk/D8qTNmd y4N8cn9NZFJnuOrmleShnpS0ULwYOPlAB/jEduI96iqwGLm/bXA5aSUPRAMJK6ReJTZJ ldgW6OSsT64DcpUjZpyzgqenczLys15ImiJGE1MPitfk085VVEBfg1CblwY9ziPIY8ww 5BjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=tmuYmC0m8mvbfJAxQIBdx9zkbWIC9B6I2Z9WuJhYmSE=; b=WLNEwzXIcrL7mzwz0be+0ir/SifhqENJSKJa5phJGnLWGj11HJsklE/Kb/Cq3Bf53f 5CNMPlF2eB7jHbCZpuPThyutBhwVyY42lLCfMCDtTDZomnx8IRcR7OK4W8aGrQywCjAA Z8T4bS+So2ImUyuNGI4JFO2ObOzcIsw5Ry53Cy7VgViijLq1NLja5eb8ZQYJkbPTpJ7s 6kWC9bRbXFBygl4W08+iG6vD7t9uDzinuYbNyRsfiEnQUBqxHdSJbKui1MuTO/ujhJKl rEx3+iHx8ttudL8IFFwOmgNolBwQTSvJEt8UgyRCb9hgFeGgQQ+5aouWTO0BzzqlYQLX oWHw== X-Gm-Message-State: AOAM532PPLLmqyPMvptdMEvVy21wvwANMrHm5UvAhPnfyPPkcEveNNHb HaBM7shyKHDDDWIiQajj372hWSZZbHHuSA== X-Google-Smtp-Source: ABdhPJyBaPKfYTmrgkAQA/OZ1IQkSPEDinSUL3sEOCbMICLR3KqVHBu0JlUWx3tgTkdOfuy12G6K7r+jCwP/NQ== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a17:902:70ca:: with SMTP id l10mr6667232plt.174.1644041770536; Fri, 04 Feb 2022 22:16:10 -0800 (PST) Date: Sat, 5 Feb 2022 14:15:37 +0800 In-Reply-To: <20220205061539.273330-1-davidgow@google.com> Message-Id: <20220205061539.273330-2-davidgow@google.com> Mime-Version: 1.0 References: <20220205061539.273330-1-davidgow@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH 2/3] list: test: Add a test for list_is_head() From: David Gow To: Shuah Khan , Andy Shevchenko , Linus Torvalds , Brendan Higgins Cc: David Gow , Daniel Latypov , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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 --- lib/list-test.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/list-test.c b/lib/list-test.c index 976e9ae1f3c5..7ce7eaebe060 100644 --- a/lib/list-test.c +++ b/lib/list-test.c @@ -252,6 +252,15 @@ static void list_test_list_bulk_move_tail(struct kunit *test) KUNIT_EXPECT_EQ(test, i, 2); } +static void list_test_list_is_head(struct kunit *test) +{ + struct list_head a, b; + + KUNIT_EXPECT_TRUE(test, list_is_head(&a, &a)); + KUNIT_EXPECT_FALSE(test, list_is_head(&a, &b)); +} + + static void list_test_list_is_first(struct kunit *test) { struct list_head a, b; @@ -729,6 +738,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), From patchwork Sat Feb 5 06:15:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 540460 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 98B4EC433EF for ; Sat, 5 Feb 2022 06:16:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352862AbiBEGQ1 (ORCPT ); Sat, 5 Feb 2022 01:16:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351460AbiBEGQ0 (ORCPT ); Sat, 5 Feb 2022 01:16:26 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 616C0C06109E for ; Fri, 4 Feb 2022 22:16:15 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id 68-20020a621547000000b004c74bbd2819so4143782pfv.18 for ; Fri, 04 Feb 2022 22:16:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=gl5quSdllNcUacMKlmR/GX6m0ySmM7gXrjH2h0fLFis=; b=k4s/EOHI5SkfQ/d0UUqb8GX2z6Ce6Lhbe9VyYzflbUbVqkEcqKoIT405legl1l1G9H 0LtiZ9GVVpmNS/bzvqhj36O0+XomRL5lESVXo9g2luEU8fxWuqsYZO0z5l5h0uB3TktM 4vzjLaKiw/asf0HjqXXSXxm38k9CL7AHnB1ZE15f2KH39fBh9jNLns6IulaaXt/QqpIj BlOHRTrGfPG+kR3ZGqZhVnUQ2YRRASX9unJPA+RKruvP7V2Rf4YnC6Zzeq4jHfT9kuiF g1jInl0XsUPMOLmiaZpVLGSwaEYZyuzFV/rkdPUpYIAk9KuepjkCgGqyy4IPzjLx298r 79Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=gl5quSdllNcUacMKlmR/GX6m0ySmM7gXrjH2h0fLFis=; b=iDCOzFLyFYzBM1+ccFSIXs4v8IjyZPWVnfnK+e+EJrbDE86sL+qAL3U42j/exYeAMW pRsJMs+sM1S0BRT9D6fMWIXrUOXLZLvpHfJPzc0VtkZdCTM0Nt649fwc1xSOnZaJiv5u gHv6x+6TIYWEiYt84xhKqfAFv6K6eICDOKqmP2zv3GYQJCBaS377O5QgQAxtqW4Cmkms bZF6RlSDL09KBXeumKn7gxrgnUPRC31qV4Q2b9b72smrUOOINNPGUuAL/pEqZX3LAwbj ZR9tXZFBz/USvJBSI3nksVsv2aN7x7IGemrhvh6QqQviQq7Ygi/7jJW4yg2LNx7iHRht QLJg== X-Gm-Message-State: AOAM533auWfa70H6J9kJ2ho9DdcG8NT8GgsOdvVQgyeRS/oYH5IUs3Yg HLxyQTNrSNtD2mRmjcR3wsmKq7N3PwDENg== X-Google-Smtp-Source: ABdhPJx2m8RdzEoyIpk9k4NiaQjQnuEukVSy4CM20gGV0C+JQh7BvtxJaH7Z1ADicaL/uNmztUFBbprPwjYXZA== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a62:8c14:: with SMTP id m20mr6528807pfd.6.1644041774840; Fri, 04 Feb 2022 22:16:14 -0800 (PST) Date: Sat, 5 Feb 2022 14:15:38 +0800 In-Reply-To: <20220205061539.273330-1-davidgow@google.com> Message-Id: <20220205061539.273330-3-davidgow@google.com> Mime-Version: 1.0 References: <20220205061539.273330-1-davidgow@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH 3/3] list: test: Add a test for list_entry_is_head() From: David Gow To: Shuah Khan , Andy Shevchenko , Linus Torvalds , Brendan Higgins Cc: David Gow , Daniel Latypov , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The list_entry_is_head() macro was added[1] after the list KUnit tests, so wasn't tested. Add a new KUnit test to complete the set. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e130816164e244b692921de49771eeb28205152d Signed-off-by: David Gow --- lib/list-test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/list-test.c b/lib/list-test.c index 7ce7eaebe060..4cd06a9fc73c 100644 --- a/lib/list-test.c +++ b/lib/list-test.c @@ -538,6 +538,18 @@ static void list_test_list_entry(struct kunit *test) struct list_test_struct, list)); } +static void list_test_list_entry_is_head(struct kunit *test) +{ + struct list_test_struct test_struct1, test_struct2; + LIST_HEAD(list); + + list_add_tail(&test_struct1.list, &list); + list_add_tail(&test_struct2.list, &list); + + KUNIT_EXPECT_FALSE(test, list_entry_is_head((&test_struct1), &list, list)); + KUNIT_EXPECT_FALSE(test, list_entry_is_head((&test_struct2), &list, list)); +} + static void list_test_list_first_entry(struct kunit *test) { struct list_test_struct test_struct1, test_struct2; @@ -753,6 +765,7 @@ static struct kunit_case list_test_cases[] = { KUNIT_CASE(list_test_list_splice_init), KUNIT_CASE(list_test_list_splice_tail_init), KUNIT_CASE(list_test_list_entry), + KUNIT_CASE(list_test_list_entry_is_head), KUNIT_CASE(list_test_list_first_entry), KUNIT_CASE(list_test_list_last_entry), KUNIT_CASE(list_test_list_first_entry_or_null),