public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] tunable: make use of save_restore
Date: Thu, 22 Jun 2023 17:39:48 +0800	[thread overview]
Message-ID: <20230622093948.530764-1-liwang@redhat.com> (raw)

SAFE_ACCESS requires the pathname is exist otherwise TBROK.
so let's use TST_SR_TBROK in save_restore.

Suggested-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/mem/tunable/max_map_count.c   | 18 +-----------------
 testcases/kernel/mem/tunable/min_free_kbytes.c |  8 +-------
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/testcases/kernel/mem/tunable/max_map_count.c b/testcases/kernel/mem/tunable/max_map_count.c
index 82a69a61e..f33095473 100644
--- a/testcases/kernel/mem/tunable/max_map_count.c
+++ b/testcases/kernel/mem/tunable/max_map_count.c
@@ -53,21 +53,6 @@
 #define MAP_COUNT_DEFAULT	1024
 #define MAX_MAP_COUNT		65536L
 
-static long old_max_map_count = -1;
-
-static void setup(void)
-{
-	SAFE_ACCESS(PATH_SYSVM "max_map_count", F_OK);
-
-	old_max_map_count = get_sys_tune("max_map_count");
-}
-
-static void cleanup(void)
-{
-	if (old_max_map_count != -1)
-		set_sys_tune("max_map_count", old_max_map_count, 0);
-}
-
 /* This is a filter to exclude map entries which aren't accounted
  * for in the vm_area_struct's map_count.
  */
@@ -205,11 +190,10 @@ static void max_map_count_test(void)
 static struct tst_test test = {
 	.needs_root = 1,
 	.forks_child = 1,
-	.setup = setup,
-	.cleanup = cleanup,
 	.test_all = max_map_count_test,
 	.save_restore = (const struct tst_path_val[]) {
 		{"/proc/sys/vm/overcommit_memory", "0", TST_SR_TBROK},
+		{"/proc/sys/vm/max_map_count", NULL, TST_SR_TBROK},
 		{}
 	},
 };
diff --git a/testcases/kernel/mem/tunable/min_free_kbytes.c b/testcases/kernel/mem/tunable/min_free_kbytes.c
index dd07a0323..19da409e8 100644
--- a/testcases/kernel/mem/tunable/min_free_kbytes.c
+++ b/testcases/kernel/mem/tunable/min_free_kbytes.c
@@ -218,21 +218,15 @@ static void setup(void)
 	default_tune = get_sys_tune("min_free_kbytes");
 }
 
-static void cleanup(void)
-{
-	if (default_tune != -1)
-		set_sys_tune("min_free_kbytes", default_tune, 0);
-}
-
 static struct tst_test test = {
 	.needs_root = 1,
 	.forks_child = 1,
 	.max_runtime = TST_UNLIMITED_RUNTIME,
 	.setup = setup,
-	.cleanup = cleanup,
 	.test_all = min_free_kbytes_test,
 	.save_restore = (const struct tst_path_val[]) {
 		{"/proc/sys/vm/overcommit_memory", NULL, TST_SR_TBROK},
+		{"/proc/sys/vm/min_free_kbytes", NULL, TST_SR_TBROK},
 		{}
 	},
 };
-- 
2.40.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2023-06-22  9:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22  9:39 Li Wang [this message]
2023-06-22 10:00 ` [LTP] [PATCH] tunable: make use of save_restore Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230622093948.530764-1-liwang@redhat.com \
    --to=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox