From patchwork Tue Dec 14 09:06:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1567623 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=B5bQKU14; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JCswL24F9z9s3q for ; Tue, 14 Dec 2021 20:07:45 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 90D393C8C3E for ; Tue, 14 Dec 2021 10:07:35 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id CCF383C2FF6 for ; Tue, 14 Dec 2021 10:07:33 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id EEE3920114A for ; Tue, 14 Dec 2021 10:07:32 +0100 (CET) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 42EBA212BA; Tue, 14 Dec 2021 09:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1639472852; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NTtCgY6gHtUjM1RqaQIlRIqsNKEVgozSSwiU8cT2pyQ=; b=B5bQKU14D/7W/J1Zko+BqMb0WYxBtquuPmEN0ohydAoT91nTnGKInKqEOfkZhMPen/RTJG rkmVwZ19bXebZ7FCsGuZP1ajlJxznKzJhc8hQOzM3T/Nv7l1QuXWJ0ahw6PnoPEuChwb3d kdsB8qQ+oiJaidNbY6ISeIvK07DH5sE= Received: from g78.suse.de (unknown [10.163.24.42]) by relay2.suse.de (Postfix) with ESMTP id 10B6AA3B81; Tue, 14 Dec 2021 09:07:32 +0000 (UTC) To: ltp@lists.linux.it Date: Tue, 14 Dec 2021 09:06:45 +0000 Message-Id: <20211214090648.14292-2-rpalethorpe@suse.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211214090648.14292-1-rpalethorpe@suse.com> References: <20211214090648.14292-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH 1/4] API: cgroup: Add safe_cgroup_occursin X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Similar to cg_read_strstr from kselftests. The name was changed because strstr from string.h returns a ptr and this does not. Signed-off-by: Richard Palethorpe Reviewed-by: Cyril Hrubis --- include/tst_cgroup.h | 8 ++++++++ lib/tst_cgroup.c | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/tst_cgroup.h b/include/tst_cgroup.h index 9e34321e4..632050e86 100644 --- a/include/tst_cgroup.h +++ b/include/tst_cgroup.h @@ -191,5 +191,13 @@ void safe_cgroup_scanf(const char *file, const int lineno, const char *fmt, ...) __attribute__ ((format (scanf, 5, 6), nonnull)); +#define SAFE_CGROUP_OCCURSIN(cg, file_name, needle) \ + safe_cgroup_occursin(__FILE__, __LINE__, \ + (cg), (file_name), (needle)) + +int safe_cgroup_occursin(const char *file, const int lineno, + const struct tst_cgroup_group *const cg, + const char *const file_name, + const char *const needle); #endif /* TST_CGROUP_H */ diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c index 61cc02fa7..f85dc4fdd 100644 --- a/lib/tst_cgroup.c +++ b/lib/tst_cgroup.c @@ -1153,3 +1153,15 @@ void safe_cgroup_scanf(const char *const file, const int lineno, "'%s': vsscanf('%s', '%s', ..): Less conversions than expected: %d != %d", file_name, buf, fmt, ret, conv_cnt); } + +int safe_cgroup_occursin(const char *const file, const int lineno, + const struct tst_cgroup_group *const cg, + const char *const file_name, + const char *const needle) +{ + char buf[BUFSIZ]; + + safe_cgroup_read(file, lineno, cg, file_name, buf, sizeof(buf)); + + return !!strstr(buf, needle); +} From patchwork Tue Dec 14 09:06:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1567625 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=spIy5PPz; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JCswX3GLHz9s3q for ; Tue, 14 Dec 2021 20:07:56 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 694E33C8C69 for ; Tue, 14 Dec 2021 10:07:54 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 011923C2FF6 for ; Tue, 14 Dec 2021 10:07:33 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 0C3C1201150 for ; Tue, 14 Dec 2021 10:07:33 +0100 (CET) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 90C3E212BC; Tue, 14 Dec 2021 09:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1639472852; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VFvWscb8XXS1rVvNIivEelaXa98jOF6cMCSjgdlAGks=; b=spIy5PPzg9lgx0bUFRgXB/8y5ZVsSEPUpV+YfOu2s0DN54FBM9kpZFoPV94Ol8C9KBrdXQ rX7F/cqdEqRtYbDSru6HQkVrrD6Exz7qBEuNvMseNu5SeWjJqQ0glk8qEITDwcyRXsQ2do RTJtTvk/7rlajdNerA7JkjebeLPCXHU= Received: from g78.suse.de (unknown [10.163.24.42]) by relay2.suse.de (Postfix) with ESMTP id 56FCAA3B81; Tue, 14 Dec 2021 09:07:32 +0000 (UTC) To: ltp@lists.linux.it Date: Tue, 14 Dec 2021 09:06:46 +0000 Message-Id: <20211214090648.14292-3-rpalethorpe@suse.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211214090648.14292-1-rpalethorpe@suse.com> References: <20211214090648.14292-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH 2/4] API: cgroup: Add cgroup.controllers X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Richard Palethorpe Reviewed-by: Cyril Hrubis --- lib/tst_cgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c index f85dc4fdd..eee89f3d5 100644 --- a/lib/tst_cgroup.c +++ b/lib/tst_cgroup.c @@ -147,6 +147,7 @@ typedef struct cgroup_file files_t[]; static const files_t cgroup_ctrl_files = { /* procs exists on V1, however it was read-only until kernel v3.0. */ { "cgroup.procs", "tasks", 0 }, + { "cgroup.controllers", NULL, 0 }, { "cgroup.subtree_control", NULL, 0 }, { "cgroup.clone_children", "cgroup.clone_children", 0 }, { } From patchwork Tue Dec 14 09:06:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1567627 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=Szhpd3SL; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JCsww2spYz9s3q for ; Tue, 14 Dec 2021 20:08:16 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id BBB023C8CB5 for ; Tue, 14 Dec 2021 10:08:13 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 9016E3C7616 for ; Tue, 14 Dec 2021 10:07:34 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 7DEA11001447 for ; Tue, 14 Dec 2021 10:07:33 +0100 (CET) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D6BEA1F3C4; Tue, 14 Dec 2021 09:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1639472852; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=guU6ZkVHfPw2mroxfiCghi8Q20dMQFo1exH4uIx8mUA=; b=Szhpd3SLIn8ldDKpxVOtIvdxjvTfgJ+5BIet3qt31cGEPYZhShNU4hqXS2MdGnDFy0uupj QbQt7LBfbo7gyq/tuNWtM0APWrFZsAghApcCH4xB6nY/ARa+5WOzbOR9L8s6kcNRT4ZCNr eLvAd6pbQ4KhpGdvR5E5xFfGKifLa88= Received: from g78.suse.de (unknown [10.163.24.42]) by relay2.suse.de (Postfix) with ESMTP id A2F03A3B81; Tue, 14 Dec 2021 09:07:32 +0000 (UTC) To: ltp@lists.linux.it Date: Tue, 14 Dec 2021 09:06:47 +0000 Message-Id: <20211214090648.14292-4-rpalethorpe@suse.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211214090648.14292-1-rpalethorpe@suse.com> References: <20211214090648.14292-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH 3/4] memcontrol01: Import first memcg kselftest X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This is a conversion of the first test in the memory cgroup kselftest. There will be a number of (more important) tests to follow; i.e. memcontrol02... Signed-off-by: Richard Palethorpe Reviewed-by: Cyril Hrubis --- runtest/controllers | 3 + testcases/kernel/controllers/memcg/.gitignore | 1 + .../kernel/controllers/memcg/memcontrol01.c | 77 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 testcases/kernel/controllers/memcg/memcontrol01.c diff --git a/runtest/controllers b/runtest/controllers index e3d0243f1..2b41a94d3 100644 --- a/runtest/controllers +++ b/runtest/controllers @@ -16,6 +16,9 @@ memcg_usage_in_bytes memcg_usage_in_bytes_test.sh memcg_stress memcg_stress_test.sh memcg_control memcg_control_test.sh +# kselftest ports +memcontrol01 memcontrol01 + cgroup_fj_function_debug cgroup_fj_function.sh debug cgroup_fj_function_cpuset cgroup_fj_function.sh cpuset cgroup_fj_function_cpu cgroup_fj_function.sh cpu diff --git a/testcases/kernel/controllers/memcg/.gitignore b/testcases/kernel/controllers/memcg/.gitignore index c0b6d0714..c3565f85c 100644 --- a/testcases/kernel/controllers/memcg/.gitignore +++ b/testcases/kernel/controllers/memcg/.gitignore @@ -5,3 +5,4 @@ /regression/memcg_test_3 /regression/memcg_test_4 /stress/memcg_process_stress +memcontrol01 diff --git a/testcases/kernel/controllers/memcg/memcontrol01.c b/testcases/kernel/controllers/memcg/memcontrol01.c new file mode 100644 index 000000000..6ef8e04d9 --- /dev/null +++ b/testcases/kernel/controllers/memcg/memcontrol01.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-2.0 +/*\ + * + * [Description] + * + * Conversion of first kselftest in cgroup/test_memcontrol.c. + * + */ +#define _GNU_SOURCE + +#include + +#include "tst_test.h" +#include "tst_cgroup.h" + +static const struct tst_cgroup_group *cg_test; +static struct tst_cgroup_group *parent, *child; +static struct tst_cgroup_group *parent2, *child2; + +/* + * This test creates two nested cgroups with and without enabling + * the memory controller. + * + * The LTP API automatically adds controllers to subtree_control when + * a child cgroup is added. So unlike the kselftest we remove the + * controller again. + */ +static void test_memcg_subtree_control(void) +{ + parent = tst_cgroup_group_mk(cg_test, "memcg_test_0"); + child = tst_cgroup_group_mk(parent, "memcg_test_1"); + parent2 = tst_cgroup_group_mk(cg_test, "memcg_test_2"); + child2 = tst_cgroup_group_mk(parent2, "memcg_test_3"); + + SAFE_CGROUP_PRINT(parent2, "cgroup.subtree_control", "-memory"); + + TST_EXP_POSITIVE( + SAFE_CGROUP_OCCURSIN(child, "cgroup.controllers", "memory"), + "child should have memory controller"); + TST_EXP_POSITIVE( + !SAFE_CGROUP_OCCURSIN(child2, "cgroup.controllers", "memory"), + "child2 should not have memory controller"); + + child2 = tst_cgroup_group_rm(child2); + parent2 = tst_cgroup_group_rm(parent2); + child = tst_cgroup_group_rm(child); + parent = tst_cgroup_group_rm(parent); +} + +static void setup(void) +{ + tst_cgroup_require("memory", NULL); + cg_test = tst_cgroup_get_test_group(); + + if (TST_CGROUP_VER(cg_test, "memory") == TST_CGROUP_V1) + tst_brk(TCONF, "V1 controllers do not have subtree control"); +} + +static void cleanup(void) +{ + if (child2) + child2 = tst_cgroup_group_rm(child2); + if (parent2) + parent2 = tst_cgroup_group_rm(parent2); + if (child) + child = tst_cgroup_group_rm(child); + if (parent) + parent = tst_cgroup_group_rm(parent); + + tst_cgroup_cleanup(); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = test_memcg_subtree_control, +}; From patchwork Tue Dec 14 09:06:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1567626 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=SyvWneNL; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JCswk6Dtvz9s3q for ; Tue, 14 Dec 2021 20:08:06 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6C3A03C8C07 for ; Tue, 14 Dec 2021 10:08:03 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 8B6693C2FF6 for ; Tue, 14 Dec 2021 10:07:34 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id C28F11401391 for ; Tue, 14 Dec 2021 10:07:33 +0100 (CET) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 2DDF61F3C5; Tue, 14 Dec 2021 09:07:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1639472853; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wShGmfe40mU3FCM486AfxSK+p+TS4vW9Vi9BDC+rGiA=; b=SyvWneNL+Ht4ebyAbk/SmDJELWjKg45DjMc0a+g5l36a5AMu4aWB6GD6du/N1I1qdJSTkP oJjK5L5fXJqot+QuKGWs2JDCJtAjJnh5UV92Ps14QIGWuVke1Tbjh5TbCJWGISbXbndh/i Cx0gEUoBbloV43sKzQfo4TYdspq3eNg= Received: from g78.suse.de (unknown [10.163.24.42]) by relay2.suse.de (Postfix) with ESMTP id E74F7A3B81; Tue, 14 Dec 2021 09:07:32 +0000 (UTC) To: ltp@lists.linux.it Date: Tue, 14 Dec 2021 09:06:48 +0000 Message-Id: <20211214090648.14292-5-rpalethorpe@suse.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211214090648.14292-1-rpalethorpe@suse.com> References: <20211214090648.14292-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 4/4] scripts/coccinelle: Helper for converting CGroup selftests X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Helps with bulk rewriting. Signed-off-by: Richard Palethorpe Reviewed-by: Cyril Hrubis --- .../coccinelle/kselftest-cgroup-to-ltp.cocci | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 scripts/coccinelle/kselftest-cgroup-to-ltp.cocci diff --git a/scripts/coccinelle/kselftest-cgroup-to-ltp.cocci b/scripts/coccinelle/kselftest-cgroup-to-ltp.cocci new file mode 100644 index 000000000..f91c2c467 --- /dev/null +++ b/scripts/coccinelle/kselftest-cgroup-to-ltp.cocci @@ -0,0 +1,40 @@ +@@ +expression cgn, cgns; +@@ + +- cgn = cg_name(..., cgns); ++ cgn = tst_cgroup_group_mk(cg_test, cgns); + +@@ +expression cg, fname, data; +@@ + +- if (cg_write(cg, fname, data)) { +- ... +- } ++ SAFE_CGROUP_PRINT(cg, fname, data); + +@@ +expression cg; +@@ + +... when != TST_CGROUP_VER(...) + +- SAFE_CGROUP_PRINT(cg, "cgroup.subtree_control", "+memory"); ++ if (TST_CGROUP_VER(cg, "memory") != TST_CGROUP_V1) ++ SAFE_CGROUP_PRINT(cg, "cgroup.subtree_control", "+memory"); + +@@ +expression cg, fname, needle; +@@ + +- cg_read_strstr(cg, fname, needle) ++ !SAFE_CGROUP_OCCURSIN(cg, fname, needle) + +@@ +identifier l; +expression cg, fname; +@@ + +- l = cg_read_long(cg, fname); ++ SAFE_CGROUP_SCANF(cg, fname, "%ld", &l);