[LTP] [PATCH 5/5] mem/vma05.sh: Convert to the new shell library

Cyril Hrubis chrubis@suse.cz
Mon Dec 16 18:16:09 CET 2024


Hi!
> > +# env
> > +# {
> > +#  "needs_root": true,
> > +#  "needs_tmpdir": true,
> > +#  "needs_cmds": ["gdb"],
> > +#  "save_restore": [
> > +#   ["/proc/sys/kernel/core_pattern", "TBROK"],
> > +#   ["/proc/sys/kernel/core_uses_pid", "TBROK"]
> C API .save_restore has 3 members:
> 
> struct tst_path_val {
>         const char *path;
>         const char *val;
> 	unsigned int flags;
> };
> 
> Why don't you use it here? (e.g. NULL).

I did look at the parsed metadata in the ltp.json to check if we match
the format there and it seems that the parsing is broken, so there is no
point in designing the interface before we fix the C parser I guess.

This is there for the ksm01:

   "save_restore": [
     [
      "/sys/kernel/mm/ksm/run",
      "TST_SR_TBROK"
     ],
     [
      "/sys/kernel/mm/ksm/sleep_millisecs",
      "TST_SR_TBROK"
     ],
     [
      "/sys/kernel/mm/ksm/max_page_sharing",
      "TST_SR_SKIP_MISSING",
      "TST_SR_TCONF_RO"
     ],
     [
      "/sys/kernel/mm/ksm/merge_across_nodes",
      "1",
      "TST_SR_SKIP_MISSING",
      "TST_SR_TCONF_RO"
     ],
     [
      "/sys/kernel/mm/ksm/smart_scan",
      "0",
      "TST_SR_SKIP_MISSING",
      "TST_SR_TBROK_RO"
     ]
    ],

This is because the anonymous structures are parsed by the array parsing
code in the metaparse.c which is overly simplistics. And there are more
bugs in there unfortunately. I can fix the most pressing problems there:

- missing macro expansion
- missing NULL in the middle of intiliaziation
- properly concatenate entries
- limited recursive #include directive

Which will produce much saner output, but we will likely never be able
to produce clean enough output without using a proper tooling that can
do compile time arithmetics. Yes we have things like .needs_hugepages
with number of hugepages defined as (5 + 1) * 5 after a macro expansion.
Which ends up in the JSON as "(ARSZ + 1) * LOOP" which ends up as
"(50 + 1)*5" after this patch. Which is stil way better than the mess we
had there before.


Anyways, I will send a patch for the metaparse.c tomorrow, so that we
can fix that first.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list