Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2317492rwd; Fri, 16 Jun 2023 02:13:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6HjnZmQrKFOumzlgygFyDt9HoYcnIEYg5a0rceWwPLPXkMXJvFtO6ruNj3mwPo5C0e65PL X-Received: by 2002:ac8:5945:0:b0:3f4:427:dbb8 with SMTP id 5-20020ac85945000000b003f40427dbb8mr2152913qtz.2.1686906814494; Fri, 16 Jun 2023 02:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686906814; cv=none; d=google.com; s=arc-20160816; b=lOxuUyLYGTdGZShyvVF15PUx3hjQJit9r3XMkqz+VatiZdkGp5NJDzZy9O5UYzsdTm UoYRpsAScZ50fAYXn7pE2akPGlptwfCtTVC4YUZHUvhk4kyBZBvaBp4jFC6DT7FxbUnX EoFEqQ/83RVhCflxQdTp4GROSzo04Kl+LUJKZ37nZhHu+Mur3G6VGaoK7+2FBCnDL7yh Azx35+SLcdvmSeARzSLYe+SQQIVJ0k4WDdD8eQy5ILGchb2ExLYtpKCq//YutfqYBUa4 lz6DgeBeLW7wZ85YtdEUQw2GSNKQo1QWS0e+ovtsc+fsW7D5QQ8lXsJ3kIPC+9gsZkDx RdZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=f1HjrLD6njVVPjduaddJfi5+Ds9joRkOIy3esLq1bnY=; b=HsuqIVyp3afDziz8H5R/a45xgHE8xTJU5pOvoUbioWTjSlEpz6CowynsI5F7iUga22 81PxTpwbHcq7U1DBgu4QA2IofjRgVtwgmP2kY7faWMoUpy5wWegElxqo8wVQCNaki+lW wUnajdtyxWstAUn3csn68rJOnqY6POQ9cIATsANSFKGVFfRevbEvLC+tzjYvX898Oakg A9xD67d8GwCohUOvxcFU1ZGty4D5b3Ner4eHSXOYNkNYssyN+Lfh0ek4nEJPKTloQZ/j cq+R6D3j25yqk96/L+VcuKci7Xh4X8wg5g7bUxtIu4ysmdscNdY1M/ViIruC2ANskT0q KpYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=KoXZXarV; 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=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r2-20020aa79622000000b00666ae7e325asi1579580pfg.191.2023.06.16.02.13.22; Fri, 16 Jun 2023 02:13:34 -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=@samsung.com header.s=mail20170921 header.b=KoXZXarV; 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=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229654AbjFPJAs (ORCPT + 99 others); Fri, 16 Jun 2023 05:00:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343849AbjFPI7s (ORCPT ); Fri, 16 Jun 2023 04:59:48 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FBAA1FEC for ; Fri, 16 Jun 2023 01:59:37 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230616085935euoutp017b2626f091caf0c3ac7ec1f21a981758~pGAwpGQDv0259202592euoutp01c for ; Fri, 16 Jun 2023 08:59:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230616085935euoutp017b2626f091caf0c3ac7ec1f21a981758~pGAwpGQDv0259202592euoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1686905975; bh=f1HjrLD6njVVPjduaddJfi5+Ds9joRkOIy3esLq1bnY=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=KoXZXarVSr/tD/cq7Yr116Qpv0UTVbKgzPKO47hFfs5Ou7v5oY2VR2r1o77XmxHl+ l996+etLl/hWWokJ0qKPX5rdIbEX+hVlBb1QRWaSSoX44e6vyYrFrj1ck2pNDbNbFZ Beje4hzUUapjgY0PMNBPSVe7UTXhO14VGhqp6p/c= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230616085935eucas1p1171b73897e1cd825a5d5ab373ed4c9c9~pGAwaB_uZ1146911469eucas1p1m; Fri, 16 Jun 2023 08:59:35 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 6C.45.42423.7742C846; Fri, 16 Jun 2023 09:59:35 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230616085935eucas1p2439375978f0ee33afd6310a9f8c5d07a~pGAwHTLq61755217552eucas1p2_; Fri, 16 Jun 2023 08:59:35 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230616085935eusmtrp1c68c5c817c528c9d8849b36ad7e6f2d5~pGAwGsbAm0890108901eusmtrp1a; Fri, 16 Jun 2023 08:59:35 +0000 (GMT) X-AuditID: cbfec7f2-a51ff7000002a5b7-4d-648c24771e35 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id DC.9E.14344.7742C846; Fri, 16 Jun 2023 09:59:35 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230616085935eusmtip252b10b84713a96d7276b9661b401440f~pGAv_AsVC1986719867eusmtip25; Fri, 16 Jun 2023 08:59:35 +0000 (GMT) Received: from localhost (106.210.248.231) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 16 Jun 2023 09:59:34 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH v2 4/8] test_sysctl: Add an unregister sysctl test Date: Fri, 16 Jun 2023 10:59:18 +0200 Message-ID: <20230616085922.3066990-5-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230616085922.3066990-1-j.granados@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [106.210.248.231] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKIsWRmVeSWpSXmKPExsWy7djPc7rlKj0pBpuuqFjs2XuSxeLyrjls FtPvvGezuDHhKaMDi8emVZ1sHp83yQUwRXHZpKTmZJalFunbJXBlHGpZwlhwWqRiVf9dlgbG NwJdjJwcEgImEj2v7zKC2EICKxglph/N7mLkArK/MEosa7zEAuF8ZpTYvGMqO0zHz+6z7BAd yxklFvdawRXd+nSCCcLZyijRvOEAE0gVm4COxPk3d5hBbBEBcYkTpzeD7WMWmMAoMesQB4gt LOAkcejsMhYQm0VAVWL+ri9g9bwCthKP73ZDbZaXaLs+HayXU8BO4vGkBnaI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qoS83d9AavnFbCVeHy3mx1im7xE 2/XpYL2cAnYSjyc1gMWFgGoab/ezQ9QLSpyc+YQFYr68RPPW2cwQtoTEwRcvgGwOoDnKEp+e J0CMrJX4/PcZ4wRGkVlIumch6Z6FpHsBI/MqRpHU0uLc9NxiI73ixNzi0rx0veT83E2MwIja duznlh2MK1991DvEyMTBeIhRgoNZSYR32YmuFCHelMTKqtSi/Pii0pzU4kOMpkBvTmSWEk3O B8Z0Xkm8oZmBqaGJmaWBqaWZsZI4r2dBR6KQQHpiSWp2ampBahFMHxMHp1QDk+Nt5qjca9Z8 Z+dZpWZ9ucwto9dkp+6jwGTmXdBh4M4ZOXWuxhy9mLPsCwPSDziuj5sh8SmXP/Vj8oRtDyT+ v7V7p29y51SZ17ZNB5dVTMi/pqzxVN4wt3bVu4mbztktNZ5/f/uOYhf5vjNlSbbLJSINq1Td j8TOOvC08muqcJvewrNsrlaa6gfXH3y39uT6bG6DpTt6s6XCLVd2/qj4E18tqXdlzsa9TT/3 Hrw78fhBBxN7yUvbeW7GVct2HFXe4L7qWqb0osfbKu9NfDiPP87t8R/BXy2ZHZkyKu4/VZed sHZSkvR7Jf1s1nbR9CWurVs1I/Vu7vlblhEbeiOBia2zYtfrLNtal00rJJ8mKLEUZyQaajEX FScCAI0Gvi0xAwAA X-CMS-MailID: 20230616085935eucas1p2439375978f0ee33afd6310a9f8c5d07a X-Msg-Generator: CA X-RootMTR: 20230616085935eucas1p2439375978f0ee33afd6310a9f8c5d07a X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230616085935eucas1p2439375978f0ee33afd6310a9f8c5d07a References: <20230616085922.3066990-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Add a test that checks that the unregistered directory is removed from /proc/sys/debug Signed-off-by: Joel Granados --- lib/test_sysctl.c | 30 ++++++++++++++++++++++++ tools/testing/selftests/sysctl/sysctl.sh | 16 +++++++++++++ 2 files changed, 46 insertions(+) diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c index 0cf7c547d61a..555244687443 100644 --- a/lib/test_sysctl.c +++ b/lib/test_sysctl.c @@ -170,12 +170,42 @@ static int test_sysctl_setup_node_tests(void) return 0; } +/* Used to test that unregister actually removes the directory */ +static struct ctl_table test_table_unregister[] = { + { + .procname = "unregister_error", + .data = &test_data.int_0001, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + }, + {} +}; + +static int test_sysctl_run_unregister_nested(void) +{ + struct ctl_table_header *unregister; + + unregister = register_sysctl("debug/test_sysctl/unregister_error", + test_table_unregister); + if (!unregister) + return -ENOMEM; + + unregister_sysctl_table(unregister); + return 0; +} + static int __init test_sysctl_init(void) { int err; err = test_sysctl_setup_node_tests(); + if (err) + goto out; + err = test_sysctl_run_unregister_nested(); + +out: return err; } module_init(test_sysctl_init); diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh index cb8f83dfe16b..a6d79d7a36e4 100755 --- a/tools/testing/selftests/sysctl/sysctl.sh +++ b/tools/testing/selftests/sysctl/sysctl.sh @@ -31,6 +31,7 @@ ALL_TESTS="$ALL_TESTS 0005:3:1:int_0003" ALL_TESTS="$ALL_TESTS 0006:50:1:bitmap_0001" ALL_TESTS="$ALL_TESTS 0007:1:1:boot_int" ALL_TESTS="$ALL_TESTS 0008:1:1:match_int" +ALL_TESTS="$ALL_TESTS 0009:1:1:unregister_error" function allow_user_defaults() { @@ -797,6 +798,20 @@ sysctl_test_0008() return 0 } +sysctl_test_0009() +{ + TARGET="${SYSCTL}/$(get_test_target 0009)" + echo -n "Testing if $TARGET unregistered correctly ..." + if [ -d $TARGET ]; then + echo "TEST FAILED" + rc=1 + test_rc + fi + + echo "ok" + return 0 +} + list_tests() { echo "Test ID list:" @@ -813,6 +828,7 @@ list_tests() echo "0006 x $(get_test_count 0006) - tests proc_do_large_bitmap()" echo "0007 x $(get_test_count 0007) - tests setting sysctl from kernel boot param" echo "0008 x $(get_test_count 0008) - tests sysctl macro values match" + echo "0009 x $(get_test_count 0009) - tests sysct unregister" } usage() -- 2.30.2