linux-test-project / ltp

Linux Test Project (mailing list: https://lists.linux.it/listinfo/ltp)
https://linux-test-project.readthedocs.io/
GNU General Public License v2.0
2.3k stars 1.01k forks source link

Add shell kconfig API #891

Closed xuyang0410 closed 2 years ago

xuyang0410 commented 2 years ago

A month ago, I recommended xfstests refer to ltp C kconfig API [1] and this patch was merged into xfstest community. I think we should introduce shell kconfig parser api into tst_test.sh and we can refer to xfstests kconfig api[2]. Any idea?

[1]Re: [PATCH v5] ext4: add test for all ext4/ext3/ext2 mount options [2]common/rc: add _require_kernel_config and _has_kernel_config

metan-ucw commented 2 years ago

If we are going to add it can we please do it as:

the shell library code would look like:

tst_kconfig_check "TST_REQUIRE_KCONFIG1" "TST_REQUIRE_KCONFIG2" ....
if [ $? -ne 0]
        exit $?

I guess that passing them up to TST_REQUIRE_KCONFIG10 would be enough for everyone. We can also explicitly warn if TST_REQUIRE_KCONFIG11 is defined so that if someone needs more than 10 it will tell him to adjust the library code.

And the tst_kconfig_check would just pass the argv+1 to the tst_kconfig_check(), should be as easy as:


int main(int argc, char *argv[])
{
        tst_kconfig_check(argv+1);

        exit(0);
}
pevik commented 2 years ago

I suppose we cannot have it all in single TST_REQUIRE_KCONFIG variable and separate by space because single kconfig pattern can contain spaces, right? (e.g. CONFIG_MMU & CONFIG_EXT4_FS=m).

How about have a default separator (e.g. space) and allow to overwrite it with another variable (e.g. TST_REQUIRE_KCONFIG_IFS). I mean similar way as TST_TEST_DATA and TST_TEST_DATA_IFS in tst_test.sh.

metan-ucw commented 2 years ago

@pevik Exactly we would have to choose a different separator than whitespace since expressions can contain these. Also if we decide to use separator we can just set use # since that will not appear in the expressions.

pevik commented 2 years ago

I'd be for '# then. Also, this issue has been reported some time ago https://github.com/linux-test-project/ltp/issues/700, can we close one of them?

xuyang0410 commented 2 years ago

Use "#" looks strange because kernel config file uses # to undefine those kconfig. How about using ,, something like CONFIG_MMU | CONFIG_EXT4_FS=m , CONFIG_QUOTACTL=y

xuyang0410 commented 2 years ago

I have done this but miss some cases and documentation. So I will send this on next week.

xuyang0410 commented 2 years ago

It has been Implemented in e3e5c71abfc and cc135d9c