[LTP] [PATCH v5] save_restore: Introduce new struct field for flags

Martin Doucha mdoucha@suse.cz
Thu Nov 24 11:10:02 CET 2022


On 24. 11. 22 4:09, Li Wang wrote:
> But before applying patch-v5 as it is, I found additional two tiny issues:
> 
> 1. the usage in newlib_tests should be corrected as well
> 2. tst_hugepage need to update the argument in tst_sys_conf_save()

Good catch. I'm surprised that tst_hugepage.c compiles with only a 
warning...

> 
> If everyone agrees on the improvements, I will merge with below fixes:
> 
> --- a/lib/newlib_tests/test19.c
> +++ b/lib/newlib_tests/test19.c
> @@ -24,9 +24,9 @@ static struct tst_test test = {
>          .test_all = run,
>          .setup = setup,
>          .save_restore = (const struct tst_path_val[]) {
> -               {"?/proc/nonexistent", NULL},
> -               {"!/proc/sys/kernel/numa_balancing", NULL},
> -               {"/proc/sys/kernel/core_pattern", NULL},
> +               {"/proc/nonexistent", NULL, TST_SR_SKIP},
> +               {"/proc/sys/kernel/numa_balancing", NULL, TST_SR_TBROK},
> +               {"/proc/sys/kernel/core_pattern", NULL, TST_SR_TCONF},
>                  {}
>          },
>   };
> diff --git a/lib/newlib_tests/test20.c b/lib/newlib_tests/test20.c
> index 3982ab7..3726cea 100644
> --- a/lib/newlib_tests/test20.c
> +++ b/lib/newlib_tests/test20.c
> @@ -39,7 +39,7 @@ static struct tst_test test = {
>          .test_all = do_test,
>          .hugepages = {2, TST_NEEDS},
>          .save_restore = (const struct tst_path_val[]) {
> -               {"!/proc/sys/kernel/numa_balancing", "0"},
> +               {"/proc/sys/kernel/numa_balancing", "0", TST_SR_TBROK},
>                  {}
>          },
>   };
> diff --git a/lib/tst_hugepage.c b/lib/tst_hugepage.c
> index e97cc56..41f65d7 100644
> --- a/lib/tst_hugepage.c
> +++ b/lib/tst_hugepage.c
> @@ -7,6 +7,7 @@
> 
>   #include "tst_test.h"
>   #include "tst_hugepage.h"
> +#include "tst_sys_conf.h"

tst_sys_conf.h is already included through tst_test.h

>   unsigned long tst_hugepages;
>   char *nr_opt;
> @@ -24,6 +25,12 @@ unsigned long tst_reserve_hugepages(struct 
> tst_hugepage *hp)
>   {
>          unsigned long val, max_hpages;
> 
> +       struct tst_path_val pvl = {
> +               .path = PATH_NR_HPAGES,
> +               .val = NULL,
> +               .flags = TST_SR_SKIP,
> +       };

The save() is followed by unconditional SAFE_FILE_PRINTF() so the flags 
should be TST_SR_SKIP_MISSING | TST_SR_TCONF_RO instead. I'll send a v6.

> +
>          if (access(PATH_HUGEPAGES, F_OK)) {
>                  if (hp->policy == TST_NEEDS)
>                          tst_brk(TCONF, "hugetlbfs is not supported");
> @@ -59,7 +66,7 @@ unsigned long tst_reserve_hugepages(struct 
> tst_hugepage *hp)
>          }
> 
>   set_hugepages:
> - tst_sys_conf_save("?/proc/sys/vm/nr_hugepages");
> +       tst_sys_conf_save(&pvl);
>          SAFE_FILE_PRINTF(PATH_NR_HPAGES, "%lu", tst_hugepages);
>          SAFE_FILE_SCANF(PATH_NR_HPAGES, "%lu", &val);
>          if (val != tst_hugepages)
> 
> 
> -- 
> Regards,
> Li Wang

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic



More information about the ltp mailing list