<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 17, 2022 at 12:07 AM Martin Doucha <<a href="mailto:mdoucha@suse.cz">mdoucha@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Tests using the .save_restore functionality currently cannot run<br>
without root privileges at all because the test will write<br>
into the path at least at the end and trigger error, even when<br>
the config paths are flagged as optional.<br>
<br>
Introduce new tst_path_val field for flags and replace path prefix flags<br>
with bit flags. Also introduce new flags to control handling of read/write<br>
errors and read-only sysfiles and rewrite save_restore implementation<br>
accordingly.<br>
<br>
Signed-off-by: Martin Doucha <<a href="mailto:mdoucha@suse.cz" target="_blank">mdoucha@suse.cz</a>><br>
---<br>
Changes since v1:<br>
- TST_SR_IF_ACCESS => TST_SR_COND_ACCESS<br>
- TST_SR_IGNORE_RO => TST_SR_SKIP_RO<br>
- TST_SR_IGNORE_MISSING => TST_SR_SKIP_MISSING (to match the IGNORE_RO change)<br>
<br>
Changes since v2:<br>
- Fixed save_restore example in C Test API docs<br>
<br>
Changes since v3:<br>
- Renamed flags to match tst_brk() constants<br>
- Added TERRNO to tst_res(TINFO) messages in tst_sys_conf.c<br>
- Added save_restore flags to newly added hugemmap08<br>
<br>
Changes since v4:<br>
- Print caller line number in print_error()<br>
<br>
I've removed Jan Stancek's ack because the changes are rather significant.<br>
Please review again.<br>
<br>
I'll send a follow-up patchset to replace setup() code which requires root<br>
privileges without good reason after this patch gets merged. Here I've kept<br>
test changes to the minimum needed to maintain current save_restore behavior<br>
with the new flags system. The only change in behavior is the use of read-only<br>
handling flags where it's clear that the change is desired.<br>
<br>
Though a few tests should get closer attention during review:<br>
- all KSM tests<br>
- add_key05<br>
- migrate_pages02<br>
<br>
<br>
<br>
 doc/c-test-api.txt                            |  40 +++----<br>
 include/tst_sys_conf.h                        |  18 +++-<br>
 lib/tst_sys_conf.c                            | 100 +++++++++++-------<br>
 lib/tst_test.c                                |   3 +-<br>
 testcases/cve/icmp_rate_limit01.c             |   2 +-<br>
 testcases/kernel/containers/userns/userns08.c |   2 +-<br>
 testcases/kernel/kvm/kvm_pagefault01.c        |   3 +-<br>
 .../kernel/mem/hugetlb/hugemmap/hugemmap08.c  |   2 +-<br>
 testcases/kernel/mem/ksm/ksm01.c              |  10 +-<br>
 testcases/kernel/mem/ksm/ksm02.c              |  10 +-<br>
 testcases/kernel/mem/ksm/ksm03.c              |  10 +-<br>
 testcases/kernel/mem/ksm/ksm04.c              |  10 +-<br>
 testcases/kernel/mem/ksm/ksm05.c              |   2 +-<br>
 testcases/kernel/mem/ksm/ksm06.c              |   9 +-<br>
 testcases/kernel/syscalls/add_key/add_key05.c |   9 +-<br>
 testcases/kernel/syscalls/bind/bind06.c       |   2 +-<br>
 testcases/kernel/syscalls/fork/fork13.c       |   2 +-<br>
 .../kernel/syscalls/ipc/msgget/msgget03.c     |   2 +-<br>
 testcases/kernel/syscalls/madvise/madvise06.c |   3 +-<br>
 testcases/kernel/syscalls/madvise/madvise08.c |   2 +-<br>
 .../syscalls/migrate_pages/migrate_pages02.c  |   3 +-<br>
 testcases/kernel/syscalls/sendto/sendto03.c   |   2 +-<br>
 .../kernel/syscalls/setsockopt/setsockopt05.c |   2 +-<br>
 .../kernel/syscalls/setsockopt/setsockopt06.c |   2 +-<br>
 .../kernel/syscalls/setsockopt/setsockopt07.c |   2 +-<br>
 .../kernel/syscalls/setsockopt/setsockopt08.c |   2 +-<br>
 .../kernel/syscalls/setsockopt/setsockopt09.c |   2 +-<br>
 testcases/kernel/syscalls/syslog/syslog11.c   |   2 +-<br>
 28 files changed, 157 insertions(+), 101 deletions(-)<br>
<br>
diff --git a/doc/c-test-api.txt b/doc/c-test-api.txt<br>
index 834a342fd..e6d121dce 100644<br>
--- a/doc/c-test-api.txt<br>
+++ b/doc/c-test-api.txt<br>
@@ -1602,35 +1602,39 @@ LTP library can be instructed to save and restore value of specified<br>
 field 'save_restore'. It is a NULL-terminated array of struct<br>
 'tst_path_val' where each tst_path_val.path represents a file, whose<br>
 value is saved at the beginning and restored at the end of the test.<br>
-If non-NULL value is passed it is written to the respective file at<br>
-the beginning of the test. Only the first line of a specified file<br>
-is saved and restored.<br>
+If non-NULL string is passed in tst_path_val.val, it is written<br>
+to the respective file at the beginning of the test. Only the first line<br>
+of a specified file is saved and restored.<br>
<br>
-Pathnames can be optionally prefixed to specify how strictly (during<br>
-'store') are handled errors:<br>
+By default, the test will end with TCONF if the file is read-only or<br>
+does not exist. If the optional write of new value fails, the test will end<br>
+with 'TBROK'. This behavior can be changed using tst_path_val.flags:<br>
<br>
-* (no prefix) - test ends with 'TCONF', if file doesn't exist<br>
-* '?'         - test prints info message and continues,<br>
-                if file doesn't exist or open/read fails<br>
-* '!'         - test ends with 'TBROK', if file doesn't exist<br>
+* 'TST_SR_TBROK_MISSING' – End test with 'TBROK' if the file does not exist<br>
+* 'TST_SR_TCONF_MISSING' – End test with 'TCONF' if the file does not exist<br>
+* 'TST_SR_SKIP_MISSING' – Continue without saving the file if it does not exist<br>
+* 'TST_SR_TBROK_RO' – End test with 'TBROK' if the file is read-only<br>
+* 'TST_SR_TCONF_RO' – End test with 'TCONF' if the file is read-only<br>
+* 'TST_SR_SKIP_RO' – Continue without saving the file if it is read-only<br>
+* 'TST_SR_IGNORE_ERR' – Ignore errors when writing new value into the file<br>
+<br>
+Common flag combinations also have shortcuts:<br>
+<br>
+* 'TST_SR_TCONF' – Equivalent to 'TST_SR_TCONF_MISSING | TST_SR_TCONF_RO'<br>
+* 'TST_SR_TBROK' – Equivalent to 'TST_SR_TBROK_MISSING | TST_SR_TBROK_RO'<br>
+* 'TST_SR_SKIP' – Equivalent to 'TST_SR_SKIP_MISSING | TST_SR_SKIP_RO'<br>
<br>
 'restore' is always strict and will TWARN if it encounters any error.<br>
<br>
 [source,c]<br>
 -------------------------------------------------------------------------------<br>
-static void setup(void)<br>
-{<br>
-       FILE_PRINTF("/proc/sys/kernel/core_pattern", "/mypath");<br>
-       SAFE_TRY_FILE_PRINTF("/proc/sys/user/max_user_namespaces", "%d", 10);<br>
-}<br>
-<br>
 static struct tst_test test = {<br>
        ...<br>
        .setup = setup,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"/proc/sys/kernel/core_pattern", NULL},<br>
-               {"?/proc/sys/user/max_user_namespaces", NULL},<br>
-               {"!/sys/kernel/mm/ksm/run", "1"},<br>
+               {"/proc/sys/kernel/core_pattern", NULL, TST_SR_TCONF},<br>
+               {"/proc/sys/user/max_user_namespaces", NULL, TST_SR_SKIP},<br>
+               {"/sys/kernel/mm/ksm/run", "1", TST_SR_TBROK},<br>
                {}<br>
        },<br>
 };<br>
diff --git a/include/tst_sys_conf.h b/include/tst_sys_conf.h<br>
index b7bbe36fc..4c85767be 100644<br>
--- a/include/tst_sys_conf.h<br>
+++ b/include/tst_sys_conf.h<br>
@@ -5,14 +5,26 @@<br>
 #ifndef TST_SYS_CONF_H__<br>
 #define TST_SYS_CONF_H__<br>
<br>
+#define TST_SR_TCONF_MISSING 0x0<br>
+#define TST_SR_TBROK_MISSING 0x1<br>
+#define TST_SR_SKIP_MISSING 0x2<br>
+#define TST_SR_TCONF_RO 0x0<br>
+#define TST_SR_TBROK_RO 0x4<br>
+#define TST_SR_SKIP_RO 0x8<br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+#define TST_SR_IGNORE_ERR 0x10<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">I didn't see any test using TST_SR_IGNORE_ERR flag in this patch,</div><div class="gmail_default" style="font-size:small">is this prepared for the coming patchset?</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+#define TST_SR_TCONF (TST_SR_TCONF_MISSING | TST_SR_TCONF_RO)<br>
+#define TST_SR_TBROK (TST_SR_TBROK_MISSING | TST_SR_TBROK_RO)<br>
+#define TST_SR_SKIP (TST_SR_SKIP_MISSING | TST_SR_SKIP_RO)<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">I'd suggest using "_TSKIP" to replace "_SKIP' to be consistent.</div><div class="gmail_default" style="font-size:small">Then the whole format will look quite perfect and easy to memorize:).</div></div><div><br></div><div><div class="gmail_default" style="font-size:small">Reviewed-by: Li Wang <<a href="mailto:liwang@redhat.com">liwang@redhat.com</a>></div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
 struct tst_path_val {<br>
         const char *path;<br>
         const char *val;<br>
+       unsigned int flags;<br>
 };<br>
<br>
-int tst_sys_conf_save_str(const char *path, const char *value);<br>
-int tst_sys_conf_save(const char *path);<br>
-void tst_sys_conf_set(const char *path, const char *value);<br>
+void tst_sys_conf_save_str(const char *path, const char *value);<br>
+int tst_sys_conf_save(const struct tst_path_val *conf);<br>
 void tst_sys_conf_restore(int verbose);<br>
 void tst_sys_conf_dump(void);<br>
<br>
diff --git a/lib/tst_sys_conf.c b/lib/tst_sys_conf.c<br>
index 003698825..c0981dcb1 100644<br>
--- a/lib/tst_sys_conf.c<br>
+++ b/lib/tst_sys_conf.c<br>
@@ -20,6 +20,15 @@ struct tst_sys_conf {<br>
<br>
 static struct tst_sys_conf *save_restore_data;<br>
<br>
+static void print_error(const int lineno, int info_only, const char *err,<br>
+       const char *path)<br>
+{<br>
+       if (info_only)<br>
+               tst_res_(__FILE__, lineno, TINFO | TERRNO, err, path);<br>
+       else<br>
+               tst_brk_(__FILE__, lineno, TBROK | TERRNO, err, path);<br>
+}<br>
+<br>
 void tst_sys_conf_dump(void)<br>
 {<br>
        struct tst_sys_conf *i;<br>
@@ -28,7 +37,7 @@ void tst_sys_conf_dump(void)<br>
                tst_res(TINFO, "%s = %s", i->path, i->value);<br>
 }<br>
<br>
-int tst_sys_conf_save_str(const char *path, const char *value)<br>
+void tst_sys_conf_save_str(const char *path, const char *value)<br>
 {<br>
        struct tst_sys_conf *n = SAFE_MALLOC(sizeof(*n));<br>
<br>
@@ -40,45 +49,45 @@ int tst_sys_conf_save_str(const char *path, const char *value)<br>
<br>
        n->next = save_restore_data;<br>
        save_restore_data = n;<br>
-<br>
-       return 0;<br>
 }<br>
<br>
-int tst_sys_conf_save(const char *path)<br>
+int tst_sys_conf_save(const struct tst_path_val *conf)<br>
 {<br>
        char line[PATH_MAX];<br>
+       int ttype, iret;<br>
        FILE *fp;<br>
        void *ret;<br>
-       char flag;<br>
<br>
-       if (!path)<br>
+       if (!conf || !conf->path)<br>
                tst_brk(TBROK, "path is empty");<br>
<br>
-       flag = path[0];<br>
-       if (flag  == '?' || flag == '!')<br>
-               path++;<br>
-<br>
-       if (access(path, F_OK) != 0) {<br>
-               switch (flag) {<br>
-               case '?':<br>
-                       tst_res(TINFO, "Path not found: '%s'", path);<br>
-                       break;<br>
-               case '!':<br>
-                       tst_brk(TBROK|TERRNO, "Path not found: '%s'", path);<br>
-                       break;<br>
-               default:<br>
-                       tst_brk(TCONF|TERRNO, "Path not found: '%s'", path);<br>
+       if (access(conf->path, F_OK) != 0) {<br>
+               if (conf->flags & TST_SR_SKIP_MISSING) {<br>
+                       tst_res(TINFO | TERRNO, "Path not found: %s",<br>
+                               conf->path);<br>
+                       return 1;<br>
                }<br>
-               return 1;<br>
+<br>
+               ttype = (conf->flags & TST_SR_TBROK_MISSING) ? TBROK : TCONF;<br>
+               tst_brk(ttype | TERRNO, "Path not found: %s", conf->path);<br>
        }<br>
<br>
-       fp = fopen(path, "r");<br>
-       if (fp == NULL) {<br>
-               if (flag == '?')<br>
+       if (access(conf->path, W_OK) != 0) {<br>
+               if (conf->flags & TST_SR_SKIP_RO) {<br>
+                       tst_res(TINFO | TERRNO, "Path is not writable: %s",<br>
+                               conf->path);<br>
                        return 1;<br>
+               }<br>
<br>
-               tst_brk(TBROK | TERRNO, "Failed to open FILE '%s' for reading",<br>
-                       path);<br>
+               ttype = (conf->flags & TST_SR_TBROK_RO) ? TBROK : TCONF;<br>
+               tst_brk(ttype | TERRNO, "Path is not writable: %s", conf->path);<br>
+       }<br>
+<br>
+       fp = fopen(conf->path, "r");<br>
+<br>
+       if (fp == NULL) {<br>
+               print_error(__LINE__, conf->flags & TST_SR_IGNORE_ERR,<br>
+                       "Failed to open '%s' for reading", conf->path);<br>
                return 1;<br>
        }<br>
<br>
@@ -86,24 +95,41 @@ int tst_sys_conf_save(const char *path)<br>
        fclose(fp);<br>
<br>
        if (ret == NULL) {<br>
-               if (flag == '?')<br>
+               if (conf->flags & TST_SR_IGNORE_ERR)<br>
                        return 1;<br>
<br>
                tst_brk(TBROK | TERRNO, "Failed to read anything from '%s'",<br>
-                       path);<br>
+                       conf->path);<br>
        }<br>
<br>
-       return tst_sys_conf_save_str(path, line);<br>
-}<br>
+       tst_sys_conf_save_str(conf->path, line);<br>
<br>
-void tst_sys_conf_set(const char *path, const char *value)<br>
-{<br>
-       char flag = path[0];<br>
-       if (flag  == '?' || flag == '!')<br>
-               path++;<br>
+       if (!conf->val)<br>
+               return 0;<br>
+<br>
+       fp = fopen(conf->path, "w");<br>
+<br>
+       if (fp == NULL) {<br>
+               print_error(__LINE__, conf->flags & TST_SR_IGNORE_ERR,<br>
+                       "Failed to open '%s' for writing", conf->path);<br>
+               return 0;<br>
+       }<br>
+<br>
+       iret = fputs(conf->val, fp);<br>
<br>
-       if (value)<br>
-               SAFE_FILE_PRINTF(path, "%s", value);<br>
+       if (iret < 0) {<br>
+               print_error(__LINE__, conf->flags & TST_SR_IGNORE_ERR,<br>
+                       "Failed to write into '%s'", conf->path);<br>
+       }<br>
+<br>
+       iret = fclose(fp);<br>
+<br>
+       if (iret < 0) {<br>
+               print_error(__LINE__, conf->flags & TST_SR_IGNORE_ERR,<br>
+                       "Failed to close '%s'", conf->path);<br>
+       }<br>
+<br>
+       return 0;<br>
 }<br>
<br>
 void tst_sys_conf_restore(int verbose)<br>
diff --git a/lib/tst_test.c b/lib/tst_test.c<br>
index 1732fd058..4976dded8 100644<br>
--- a/lib/tst_test.c<br>
+++ b/lib/tst_test.c<br>
@@ -1203,8 +1203,7 @@ static void do_setup(int argc, char *argv[])<br>
                const struct tst_path_val *pvl = tst_test->save_restore;<br>
<br>
                while (pvl->path) {<br>
-                       if (!tst_sys_conf_save(pvl->path))<br>
-                               tst_sys_conf_set(pvl->path, pvl->val);<br>
+                       tst_sys_conf_save(pvl);<br>
                        pvl++;<br>
                }<br>
        }<br>
diff --git a/testcases/cve/icmp_rate_limit01.c b/testcases/cve/icmp_rate_limit01.c<br>
index 1263762d2..8f876722f 100644<br>
--- a/testcases/cve/icmp_rate_limit01.c<br>
+++ b/testcases/cve/icmp_rate_limit01.c<br>
@@ -269,7 +269,7 @@ static struct tst_test test = {<br>
                NULL<br>
        },<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/proc/sys/user/max_user_namespaces", NULL},<br>
+               {"/proc/sys/user/max_user_namespaces", NULL, TST_SR_SKIP},<br>
                {}<br>
        },<br>
        .tags = (const struct tst_tag[]) {<br>
diff --git a/testcases/kernel/containers/userns/userns08.c b/testcases/kernel/containers/userns/userns08.c<br>
index 0f1cb54a9..afdad6cad 100644<br>
--- a/testcases/kernel/containers/userns/userns08.c<br>
+++ b/testcases/kernel/containers/userns/userns08.c<br>
@@ -135,7 +135,7 @@ static struct tst_test test = {<br>
                NULL<br>
        },<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/proc/sys/user/max_user_namespaces", NULL},<br>
+               {"/proc/sys/user/max_user_namespaces", NULL, TST_SR_SKIP},<br>
                {}<br>
        },<br>
        .tags = (const struct tst_tag[]) {<br>
diff --git a/testcases/kernel/kvm/kvm_pagefault01.c b/testcases/kernel/kvm/kvm_pagefault01.c<br>
index e355fa448..91891848a 100644<br>
--- a/testcases/kernel/kvm/kvm_pagefault01.c<br>
+++ b/testcases/kernel/kvm/kvm_pagefault01.c<br>
@@ -217,7 +217,8 @@ static struct tst_test test = {<br>
        .cleanup = tst_kvm_cleanup,<br>
        .needs_root = 1,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/sys/module/kvm/parameters/tdp_mmu", "0"},<br>
+               {"/sys/module/kvm/parameters/tdp_mmu", "0",<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
                {}<br>
        },<br>
        .supported_archs = (const char *const []) {<br>
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap08.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap08.c<br>
index 8b3bca5e3..bacd443d8 100644<br>
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap08.c<br>
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap08.c<br>
@@ -131,7 +131,7 @@ static struct tst_test test = {<br>
        .needs_hugetlbfs = 1,<br>
        .forks_child = 1,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {PATH_OC_HPAGES, NULL},<br>
+               {PATH_OC_HPAGES, NULL, TST_SR_TCONF},<br>
                {}<br>
        },<br>
        .tcnt = 2,<br>
diff --git a/testcases/kernel/mem/ksm/ksm01.c b/testcases/kernel/mem/ksm/ksm01.c<br>
index 1f3852fc3..fafa2da71 100644<br>
--- a/testcases/kernel/mem/ksm/ksm01.c<br>
+++ b/testcases/kernel/mem/ksm/ksm01.c<br>
@@ -80,10 +80,12 @@ static struct tst_test test = {<br>
        },<br>
        .setup = setup,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"!/sys/kernel/mm/ksm/run", NULL},<br>
-               {"!/sys/kernel/mm/ksm/sleep_millisecs", NULL},<br>
-               {"?/sys/kernel/mm/ksm/max_page_sharing", NULL},<br>
-               {"?/sys/kernel/mm/ksm/merge_across_nodes", "1"},<br>
+               {"/sys/kernel/mm/ksm/run", NULL, TST_SR_TBROK},<br>
+               {"/sys/kernel/mm/ksm/sleep_millisecs", NULL, TST_SR_TBROK},<br>
+               {"/sys/kernel/mm/ksm/max_page_sharing", NULL,<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
+               {"/sys/kernel/mm/ksm/merge_across_nodes", "1",<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
                {}<br>
        },<br>
        .needs_kconfigs = (const char *const[]){<br>
diff --git a/testcases/kernel/mem/ksm/ksm02.c b/testcases/kernel/mem/ksm/ksm02.c<br>
index 4183108d5..b5c90464e 100644<br>
--- a/testcases/kernel/mem/ksm/ksm02.c<br>
+++ b/testcases/kernel/mem/ksm/ksm02.c<br>
@@ -101,10 +101,12 @@ static struct tst_test test = {<br>
        },<br>
        .setup = setup,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"!/sys/kernel/mm/ksm/run", NULL},<br>
-               {"!/sys/kernel/mm/ksm/sleep_millisecs", NULL},<br>
-               {"?/sys/kernel/mm/ksm/max_page_sharing", NULL},<br>
-               {"?/sys/kernel/mm/ksm/merge_across_nodes", "1"},<br>
+               {"/sys/kernel/mm/ksm/run", NULL, TST_SR_TBROK},<br>
+               {"/sys/kernel/mm/ksm/sleep_millisecs", NULL, TST_SR_TBROK},<br>
+               {"/sys/kernel/mm/ksm/max_page_sharing", NULL,<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
+               {"/sys/kernel/mm/ksm/merge_across_nodes", "1",<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
                {}<br>
        },<br>
        .needs_kconfigs = (const char *const[]){<br>
diff --git a/testcases/kernel/mem/ksm/ksm03.c b/testcases/kernel/mem/ksm/ksm03.c<br>
index 1cf2e4954..94029054f 100644<br>
--- a/testcases/kernel/mem/ksm/ksm03.c<br>
+++ b/testcases/kernel/mem/ksm/ksm03.c<br>
@@ -83,10 +83,12 @@ static struct tst_test test = {<br>
        },<br>
        .setup = setup,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"!/sys/kernel/mm/ksm/run", NULL},<br>
-               {"!/sys/kernel/mm/ksm/sleep_millisecs", NULL},<br>
-               {"?/sys/kernel/mm/ksm/max_page_sharing", NULL},<br>
-               {"?/sys/kernel/mm/ksm/merge_across_nodes", "1"},<br>
+               {"/sys/kernel/mm/ksm/run", NULL, TST_SR_TBROK},<br>
+               {"/sys/kernel/mm/ksm/sleep_millisecs", NULL, TST_SR_TBROK},<br>
+               {"/sys/kernel/mm/ksm/max_page_sharing", NULL,<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
+               {"/sys/kernel/mm/ksm/merge_across_nodes", "1",<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
                {}<br>
        },<br>
        .needs_kconfigs = (const char *const[]){<br>
diff --git a/testcases/kernel/mem/ksm/ksm04.c b/testcases/kernel/mem/ksm/ksm04.c<br>
index 9fe9d6dd5..2302a2a1d 100644<br>
--- a/testcases/kernel/mem/ksm/ksm04.c<br>
+++ b/testcases/kernel/mem/ksm/ksm04.c<br>
@@ -103,10 +103,12 @@ static struct tst_test test = {<br>
        },<br>
        .setup = setup,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"!/sys/kernel/mm/ksm/run", NULL},<br>
-               {"!/sys/kernel/mm/ksm/sleep_millisecs", NULL},<br>
-               {"?/sys/kernel/mm/ksm/max_page_sharing", NULL},<br>
-               {"?/sys/kernel/mm/ksm/merge_across_nodes", "1"},<br>
+               {"/sys/kernel/mm/ksm/run", NULL, TST_SR_TBROK},<br>
+               {"/sys/kernel/mm/ksm/sleep_millisecs", NULL, TST_SR_TBROK},<br>
+               {"/sys/kernel/mm/ksm/max_page_sharing", NULL,<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
+               {"/sys/kernel/mm/ksm/merge_across_nodes", "1",<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
                {}<br>
        },<br>
        .needs_kconfigs = (const char *const[]){<br>
diff --git a/testcases/kernel/mem/ksm/ksm05.c b/testcases/kernel/mem/ksm/ksm05.c<br>
index 146a9a3b7..c4cb779aa 100644<br>
--- a/testcases/kernel/mem/ksm/ksm05.c<br>
+++ b/testcases/kernel/mem/ksm/ksm05.c<br>
@@ -89,7 +89,7 @@ static struct tst_test test = {<br>
        .test_all = test_ksm,<br>
        .min_kver = "2.6.32",<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"!/sys/kernel/mm/ksm/run", "1"},<br>
+               {"/sys/kernel/mm/ksm/run", "1", TST_SR_TBROK},<br>
                {}<br>
        },<br>
        .needs_kconfigs = (const char *const[]){<br>
diff --git a/testcases/kernel/mem/ksm/ksm06.c b/testcases/kernel/mem/ksm/ksm06.c<br>
index 21c82edc1..0b159e5c7 100644<br>
--- a/testcases/kernel/mem/ksm/ksm06.c<br>
+++ b/testcases/kernel/mem/ksm/ksm06.c<br>
@@ -137,10 +137,11 @@ static struct tst_test test = {<br>
        },<br>
        .setup = setup,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/sys/kernel/mm/ksm/max_page_sharing", NULL},<br>
-               {"!/sys/kernel/mm/ksm/run", NULL},<br>
-               {"!/sys/kernel/mm/ksm/sleep_millisecs", NULL},<br>
-               {"/sys/kernel/mm/ksm/merge_across_nodes", NULL},<br>
+               {"/sys/kernel/mm/ksm/max_page_sharing", NULL,<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
+               {"/sys/kernel/mm/ksm/run", NULL, TST_SR_TBROK},<br>
+               {"/sys/kernel/mm/ksm/sleep_millisecs", NULL, TST_SR_TBROK},<br>
+               {"/sys/kernel/mm/ksm/merge_across_nodes", NULL, TST_SR_TCONF},<br>
                {}<br>
        },<br>
        .needs_kconfigs = (const char *const[]){<br>
diff --git a/testcases/kernel/syscalls/add_key/add_key05.c b/testcases/kernel/syscalls/add_key/add_key05.c<br>
index 63cb262bb..74b0b54dd 100644<br>
--- a/testcases/kernel/syscalls/add_key/add_key05.c<br>
+++ b/testcases/kernel/syscalls/add_key/add_key05.c<br>
@@ -220,9 +220,12 @@ static struct tst_test test = {<br>
        .forks_child = 1,<br>
        .cleanup = cleanup,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/proc/sys/kernel/keys/gc_delay", "1"},<br>
-               {"?/proc/sys/kernel/keys/maxkeys", "200"},<br>
-               {"?/proc/sys/kernel/keys/maxbytes", "20000"},<br>
+               {"/proc/sys/kernel/keys/gc_delay", "1",<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
+               {"/proc/sys/kernel/keys/maxkeys", "200",<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
+               {"/proc/sys/kernel/keys/maxbytes", "20000",<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
                {}<br>
        },<br>
        .bufs = (struct tst_buffers []) {<br>
diff --git a/testcases/kernel/syscalls/bind/bind06.c b/testcases/kernel/syscalls/bind/bind06.c<br>
index 618cfce46..f7813d26a 100644<br>
--- a/testcases/kernel/syscalls/bind/bind06.c<br>
+++ b/testcases/kernel/syscalls/bind/bind06.c<br>
@@ -110,7 +110,7 @@ static struct tst_test test = {<br>
                NULL<br>
        },<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/proc/sys/user/max_user_namespaces", NULL},<br>
+               {"/proc/sys/user/max_user_namespaces", NULL, TST_SR_SKIP},<br>
                {}<br>
        },<br>
        .tags = (const struct tst_tag[]) {<br>
diff --git a/testcases/kernel/syscalls/fork/fork13.c b/testcases/kernel/syscalls/fork/fork13.c<br>
index fe30d1e9c..bbfbf5c3b 100644<br>
--- a/testcases/kernel/syscalls/fork/fork13.c<br>
+++ b/testcases/kernel/syscalls/fork/fork13.c<br>
@@ -113,7 +113,7 @@ static struct tst_test test = {<br>
        .max_runtime = 600,<br>
        .test_all = check,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"!/proc/sys/kernel/pid_max", PID_MAX_STR},<br>
+               {"/proc/sys/kernel/pid_max", PID_MAX_STR, TST_SR_TBROK},<br>
                {}<br>
        },<br>
        .tags = (const struct tst_tag[]) {<br>
diff --git a/testcases/kernel/syscalls/ipc/msgget/msgget03.c b/testcases/kernel/syscalls/ipc/msgget/msgget03.c<br>
index 2257ae0f9..9e6c66cb4 100644<br>
--- a/testcases/kernel/syscalls/ipc/msgget/msgget03.c<br>
+++ b/testcases/kernel/syscalls/ipc/msgget/msgget03.c<br>
@@ -76,7 +76,7 @@ static struct tst_test test = {<br>
        .cleanup = cleanup,<br>
        .test_all = verify_msgget,<br>
        .save_restore = (const struct tst_path_val[]){<br>
-               {"/proc/sys/kernel/msgmni", NULL},<br>
+               {"/proc/sys/kernel/msgmni", NULL, TST_SR_TCONF},<br>
                {}<br>
        }<br>
 };<br>
diff --git a/testcases/kernel/syscalls/madvise/madvise06.c b/testcases/kernel/syscalls/madvise/madvise06.c<br>
index 27aff18f1..c1c55bbc2 100644<br>
--- a/testcases/kernel/syscalls/madvise/madvise06.c<br>
+++ b/testcases/kernel/syscalls/madvise/madvise06.c<br>
@@ -239,7 +239,8 @@ static struct tst_test test = {<br>
        .needs_tmpdir = 1,<br>
        .needs_root = 1,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/proc/sys/vm/swappiness", NULL},<br>
+               {"/proc/sys/vm/swappiness", NULL,<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
                {}<br>
        },<br>
        .needs_cgroup_ctrls = (const char *const []){ "memory", NULL },<br>
diff --git a/testcases/kernel/syscalls/madvise/madvise08.c b/testcases/kernel/syscalls/madvise/madvise08.c<br>
index 10549f4b4..0996cf91b 100644<br>
--- a/testcases/kernel/syscalls/madvise/madvise08.c<br>
+++ b/testcases/kernel/syscalls/madvise/madvise08.c<br>
@@ -213,7 +213,7 @@ static struct tst_test test = {<br>
        .needs_root = 1,<br>
        .forks_child = 1,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {CORE_PATTERN, NULL},<br>
+               {CORE_PATTERN, NULL, TST_SR_TCONF},<br>
                {}<br>
        },<br>
 };<br>
diff --git a/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c b/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c<br>
index 32da57042..4d5b2b8d5 100644<br>
--- a/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c<br>
+++ b/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c<br>
@@ -327,7 +327,8 @@ static struct tst_test test = {<br>
        .test_all = run,<br>
        .setup = setup,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/proc/sys/kernel/numa_balancing", "0"},<br>
+               {"/proc/sys/kernel/numa_balancing", "0",<br>
+                       TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},<br>
                {}<br>
        },<br>
 };<br>
diff --git a/testcases/kernel/syscalls/sendto/sendto03.c b/testcases/kernel/syscalls/sendto/sendto03.c<br>
index 5d2c1e112..3709b287c 100644<br>
--- a/testcases/kernel/syscalls/sendto/sendto03.c<br>
+++ b/testcases/kernel/syscalls/sendto/sendto03.c<br>
@@ -218,7 +218,7 @@ static struct tst_test test = {<br>
                NULL<br>
        },<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/proc/sys/user/max_user_namespaces", NULL},<br>
+               {"/proc/sys/user/max_user_namespaces", NULL, TST_SR_SKIP},<br>
                {}<br>
        },<br>
        .tags = (const struct tst_tag[]) {<br>
diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt05.c b/testcases/kernel/syscalls/setsockopt/setsockopt05.c<br>
index 651583fb6..580467dc8 100644<br>
--- a/testcases/kernel/syscalls/setsockopt/setsockopt05.c<br>
+++ b/testcases/kernel/syscalls/setsockopt/setsockopt05.c<br>
@@ -102,7 +102,7 @@ static struct tst_test test = {<br>
                NULL<br>
        },<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/proc/sys/user/max_user_namespaces", NULL},<br>
+               {"/proc/sys/user/max_user_namespaces", NULL, TST_SR_SKIP},<br>
                {}<br>
        },<br>
        .tags = (const struct tst_tag[]) {<br>
diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt06.c b/testcases/kernel/syscalls/setsockopt/setsockopt06.c<br>
index 9c818646b..e67996a78 100644<br>
--- a/testcases/kernel/syscalls/setsockopt/setsockopt06.c<br>
+++ b/testcases/kernel/syscalls/setsockopt/setsockopt06.c<br>
@@ -130,7 +130,7 @@ static struct tst_test test = {<br>
                NULL<br>
        },<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/proc/sys/user/max_user_namespaces", NULL},<br>
+               {"/proc/sys/user/max_user_namespaces", NULL, TST_SR_SKIP},<br>
                {}<br>
        },<br>
        .tags = (const struct tst_tag[]) {<br>
diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt07.c b/testcases/kernel/syscalls/setsockopt/setsockopt07.c<br>
index 616159a90..1c5a0ed6d 100644<br>
--- a/testcases/kernel/syscalls/setsockopt/setsockopt07.c<br>
+++ b/testcases/kernel/syscalls/setsockopt/setsockopt07.c<br>
@@ -143,7 +143,7 @@ static struct tst_test test = {<br>
                NULL<br>
        },<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/proc/sys/user/max_user_namespaces", NULL},<br>
+               {"/proc/sys/user/max_user_namespaces", NULL, TST_SR_SKIP},<br>
                {}<br>
        },<br>
        .tags = (const struct tst_tag[]) {<br>
diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt08.c b/testcases/kernel/syscalls/setsockopt/setsockopt08.c<br>
index 563444635..a29125fd7 100644<br>
--- a/testcases/kernel/syscalls/setsockopt/setsockopt08.c<br>
+++ b/testcases/kernel/syscalls/setsockopt/setsockopt08.c<br>
@@ -159,7 +159,7 @@ static struct tst_test test = {<br>
                NULL<br>
        },<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/proc/sys/user/max_user_namespaces", NULL},<br>
+               {"/proc/sys/user/max_user_namespaces", NULL, TST_SR_SKIP},<br>
                {}<br>
        },<br>
        .tags = (const struct tst_tag[]) {<br>
diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt09.c b/testcases/kernel/syscalls/setsockopt/setsockopt09.c<br>
index 98f7fd00e..b49b17e7d 100644<br>
--- a/testcases/kernel/syscalls/setsockopt/setsockopt09.c<br>
+++ b/testcases/kernel/syscalls/setsockopt/setsockopt09.c<br>
@@ -124,7 +124,7 @@ static struct tst_test test = {<br>
                NULL<br>
        },<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"?/proc/sys/user/max_user_namespaces", NULL},<br>
+               {"/proc/sys/user/max_user_namespaces", NULL, TST_SR_SKIP},<br>
                {}<br>
        },<br>
        .tags = (const struct tst_tag[]) {<br>
diff --git a/testcases/kernel/syscalls/syslog/syslog11.c b/testcases/kernel/syscalls/syslog/syslog11.c<br>
index ca1ecbbe3..733da5f96 100644<br>
--- a/testcases/kernel/syscalls/syslog/syslog11.c<br>
+++ b/testcases/kernel/syscalls/syslog/syslog11.c<br>
@@ -58,7 +58,7 @@ static void run(unsigned int n)<br>
 static struct tst_test test = {<br>
        .test = run,<br>
        .save_restore = (const struct tst_path_val[]) {<br>
-               {"!/proc/sys/kernel/printk", NULL},<br>
+               {"/proc/sys/kernel/printk", NULL, TST_SR_TBROK},<br>
                {}<br>
        },<br>
        .needs_root = 1,<br>
-- <br>
2.37.3<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>