All of lore.kernel.org
 help / color / mirror / Atom feed
From: "xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com>
To: Petr Vorel <pvorel@suse.cz>
Cc: "ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v1 2/3] shell: add kconfig parse api
Date: Thu, 6 Jan 2022 05:59:51 +0000	[thread overview]
Message-ID: <61D6857F.9060802@fujitsu.com> (raw)
In-Reply-To: <YdWsZpTjnBLszubC@pevik>

Hi Petr
> Hi Xu,
>
>>>> +'$TST_NEEDS_KCONFIGS'.
>>>> +Optional '$TST_NEEDS_KCONFIG_IFS' is used for splitting, default value is comma.
>>>> +Optional '$TST_TCONF_IF_KCONFIG' is used for deciding how to exit the test if kernel
>>>> +.config doesn't meet test's requirement, default value is 1(TCONF). Otherwise, just
>>> I wonder if we need TST_TCONF_IF_KCONFIG functionality in the test or if it's an
>>> user request (i.e. user like variable LTP_TCONF_IF_KCONFIG doc/user-guide.txt).
>>> Because I'm not sure whether test would need it, but I can imagine user want to
>>> have test running even kernel config is not available (e.g. embedded platforms).
>>> Or maybe we need both user variable and test variable.
>> Oh, I misunderstand the usage.
>
>> I should use TST_TCONF_IF_KCONFIG for non-found kconfig file instead of
>> non-found kconfig list.
>
>> I think one variable is enough.
>
> OK, but I'd like to know others' opinion what's needed.
> Cyril, Li?
>
>>> Also not sure about TST_TCONF_IF_KCONFIG name, IMHO "IF" should be replaced to
>>> something which describes what it does.
>> Thinking a good name isn't a easy thing.
>
>> how about TCONF_IF_NO_KCONFIG?
>
> Well, I was not sure about "IF" part. For use in test code it should have "TST_"
> prefix, for users to set it should have "LTP_" prefix.
When I write this v2 patch, I think we may introuce a 
LTP_KCONFIG_DISABLE macro that can disable kconfig parser function whole 
for the situation that some embedded platforms doesn't have config. So 
we don't need to distinguish whether kconfig file doesn't exist or perms 
leak or invalid config expression.

code may below
static int tst_kconfig_disable()
{
         static int check;

         if (check)
                 return check - 1;

         char *env = getenv("LTP_KCONFIG_DISABLE");

         if (env) {
                 if (!strcmp(env, "n") || !strcmp(env, "0"))
                         check = 1;
                 if (!strcmp(env, "y") || !strcmp(env, "1"))
                         check = 2;
                 return check - 1;
         }

         check = 1;
         return 0;
}

...
int tst_kconfig_check(const char *const kconfigs[])
{
         size_t expr_cnt = array_len(kconfigs);
         struct tst_expr *exprs[expr_cnt];
         unsigned int i, var_cnt;
         int ret = 0;

	if (tst_kconfig_disable())
		return 0
	...
}

Also, this macro is easy to understand and we don't need macro ie 
CONF_IF_NO_KCONFIG or TWARN_NO_IF_KCONFIG. Any idea?

Best Regards
Yang Xu
>
>>> Also this patchset is about syncing C API functionality with shell API. But you
>>> introduce TST_TCONF_IF_KCONFIG only for shell. Shouldn't it be functionality for
>>> both parts?
>> Yes, code maybe as below:
>
>> void tst_kconfig_read(struct tst_kconfig_var vars[], size_t vars_len)
>> +static char kconfig_flag;
>> +
>> +int tst_kconfig_read(struct tst_kconfig_var vars[], size_t vars_len)
>>    {
>>           char line[128];
>>           unsigned int vars_found = 0;
>> +       const char *flag = getenv("TWARN_IF_NO_KCONFIG");
>> +
>> +       if (flag&&  !strcmp(flag,"y"))
>> +               kconfig_flag = 'y';
>
>>           FILE *fp = open_kconfig();
>> -       if (!fp)
>> +       if (!fp) {
>> +               if (kconfig_flag == 'y') {
>> +                       tst_res(TWARN, "Cannot parse kernel .config");
>> +                       return 1;
>> +               }
>>                   tst_brk(TBROK, "Cannot parse kernel .config");
>> -
>> +       }
>>           while (fgets(line, sizeof(line), fp)) {
>>                   if (kconfig_parse_line(line, vars, vars_len))
>>                           vars_found++;
>> @@ -198,6 +210,7 @@ void tst_kconfig_read(struct tst_kconfig_var vars[],
>> size_t vars_len)
>
>>    exit:
>>           close_kconfig(fp);
>> +       return 0;
>>    }
>
> Sure, once we agree what should be implemented.
>
>>    static size_t array_len(const char *const kconfigs[])
>> @@ -504,7 +517,9 @@ int tst_kconfig_check(const char *const kconfigs[])
>
>>           var_cnt = populate_vars(exprs, expr_cnt, vars);
>
>> -       tst_kconfig_read(vars, var_cnt);
>> +       ret = tst_kconfig_read(vars, var_cnt);
>> +       if (ret)
>> +               return kconfig_flag == 'y' ? 0 : 1;
>
>
>
>
>>> More notes about this variable also below.
>
>>> BTW github actions have probably kernel config on expected place, which means
>>> that most of the new tests TCONF, but tst_check_kconfig05.sh TFAIL.
>> I guess we can export the  KCONFIG_PATH to solve this problem. But I
>> don't know the expected place on github actions.
>
> Sure, for github we can find config place.
> But this can happen to user who runs the test. IMHO test should not fail if
> user's system is without config. That's why I'd like to have a variable making
> errors non-fatal.
>
>>> tst_rhost_run 1 TCONF: veth(null)      0  TWARN  :  /__w/ltp/ltp/lib/tst_kernel.c:110: expected file /lib/modules/5.11.0-1022-azure/modules.dep does not exist or not a file
>>> 320
>>> (null)      0  TWARN  :  /__w/ltp/ltp/lib/tst_kernel.c:110: expected file /lib/modules/5.11.0-1022-azure/modules.builtin does not exist or not a file driver not available
>
>>>> +use TWRAN and continue to run test.
>>>> +
>>>> +Now, we support the length of kconfig list is 10.
>>> Why 10? Cyril suggested that in PR, where he suggested to use separated
>>> variables:
>>> https://github.com/linux-test-project/ltp/issues/891#issuecomment-989712350
>
>>> But for string used like array there is no performance limitation, thus I'd use
>>> something like 50 or 100. Because for certain IMA tests there are at least 6
>>> kconfig requirements, thus>   10 could be hit.
>> If case needs more than 10 kconfigs, we can use&  ie
>> "CONFIG_EX4_FS&  CONFIG_XFS_FS&  CONFIG_QUOTAL_FS, CONFIG_PROC_FS..."
> Sure. I just meant there is no reason to put low number and then workaround it.
>
>>>> --- a/testcases/lib/tst_test.sh
>>>> +	tst_check_kconfigs $kconfig1 $kconfig2 $kconfig3 $kconfig4 $kconfig5 $kconfig6\
>>>> +			$kconfig7 $kconfig8 $kconfig9 $kconfig10
>>>> +	if [ $? -ne 0 ]; then
>>>> +		if [ $TST_TCONF_IF_KCONFIG -eq 1 ]; then
>>>> +			tst_brk TCONF "kconfig not available"
>
>>>> +		else
>>>> +			tst_res TWARN "kconfig not available"
>>> This is quite strong: either test "fails" due TWARN non-zero exit code or it's
>>> skipped. I'd prefer to have user variable for systems which are properly
>>> configured (user will make sure all kconfig options are set), but it's just
>>> missing kconfig due system configuration.
>> I plan to fix the variable usage for non-found kconfig path/file instead
>> of kconfig list.
>
>> Best Regards
>> Yang Xu
>
> Kind regards,
> Petr

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

  reply	other threads:[~2022-01-06  6:00 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-04  6:57 [LTP] [PATCH v1 1/3] lib/tst_kconfig: Modify the return type of tst_kconfig_check function Yang Xu
2022-01-04  6:57 ` [LTP] [PATCH v1 2/3] shell: add kconfig parse api Yang Xu
2022-01-04 11:04   ` Petr Vorel
2022-01-05  7:15     ` xuyang2018.jy
2022-01-05 14:34       ` Petr Vorel
2022-01-06  5:59         ` xuyang2018.jy [this message]
2022-01-06  8:16           ` xuyang2018.jy
2022-01-06  9:25         ` [LTP] [PATCH v2 1/4] lib/tst_kconfig: Modify the return type of tst_kconfig_check function Yang Xu
2022-01-06  9:25           ` [LTP] [PATCH v2 2/4] lib: Introduce LTP_KCONFIG_DISABLE environment variables Yang Xu
2022-01-06  9:49             ` Petr Vorel
2022-01-06  9:52             ` Petr Vorel
2022-01-06 11:07             ` Cyril Hrubis
2022-01-06 11:50               ` Petr Vorel
2022-01-06 13:59                 ` Cyril Hrubis
2022-01-06 17:41                   ` Petr Vorel
2022-01-07  2:00                   ` xuyang2018.jy
2022-01-06  9:25           ` [LTP] [PATCH v2 3/4] shell: add kconfig parse api Yang Xu
2022-01-06 10:40             ` Petr Vorel
2022-01-06 11:19             ` Cyril Hrubis
2022-01-07  3:54               ` Li Wang
2022-01-07  4:08                 ` xuyang2018.jy
2022-01-07  7:04                   ` Li Wang
2022-01-07  8:28                     ` xuyang2018.jy
2022-01-07  8:41                       ` Li Wang
2022-01-07  9:46                         ` Cyril Hrubis
2022-01-07  9:56                           ` xuyang2018.jy
2022-01-07  9:05                       ` Petr Vorel
2022-01-07  9:22                         ` xuyang2018.jy
2022-01-07 12:07                           ` Petr Vorel
2022-01-07  7:33                 ` Petr Vorel
2022-01-06  9:25           ` [LTP] [PATCH v2 4/4] sysctl/sysctl02.sh: Use kconfig shell api Yang Xu
2022-01-06 11:20             ` Cyril Hrubis
2022-01-10  1:49               ` [LTP] [PATCH v3 1/4] lib/tst_kconfig: Modify the return type of tst_kconfig_check function Yang Xu
2022-01-10  1:49                 ` [LTP] [PATCH v3 2/4] lib: Introduce KCONFIG_SKIP_CHECK environment variable Yang Xu
2022-01-10  8:14                   ` Li Wang
2022-01-10 12:20                   ` Cyril Hrubis
2022-01-11  1:38                     ` xuyang2018.jy
2022-01-10  1:49                 ` [LTP] [PATCH v3 3/4] shell: add kconfig parse api Yang Xu
2022-01-10  8:26                   ` Li Wang
2022-01-10  8:46                     ` xuyang2018.jy
2022-01-10  9:13                       ` Li Wang
2022-01-10 13:43                   ` Cyril Hrubis
2022-01-11  5:29                     ` xuyang2018.jy
2022-01-11  6:10                     ` [LTP] [PATCH v4 1/5] lib/tst_kconfig: Modify the return type of tst_kconfig_check function Yang Xu
2022-01-11  6:10                       ` [LTP] [PATCH v4 2/5] lib: Introduce KCONFIG_SKIP_CHECK environment variable Yang Xu
2022-01-13 11:09                         ` Petr Vorel
2022-01-14  5:36                           ` xuyang2018.jy
2022-01-11  6:10                       ` [LTP] [PATCH v4 3/5] shell: add kconfig parse api Yang Xu
2022-01-11  7:52                         ` Li Wang
2022-01-11  8:37                           ` xuyang2018.jy
2022-01-13  9:15                             ` xuyang2018.jy
2022-01-13  9:42                               ` Li Wang
2022-01-13 15:51                             ` Cyril Hrubis
2022-01-14  6:26                               ` xuyang2018.jy
2022-01-14  9:19                                 ` xuyang2018.jy
2022-01-14  9:49                                   ` Petr Vorel
2022-01-11  6:10                       ` [LTP] [PATCH v4 4/5] sysctl/sysctl02.sh: Use kconfig shell api Yang Xu
2022-01-13 10:53                         ` Petr Vorel
2022-01-13 16:06                           ` Petr Vorel
2022-01-13 15:54                         ` Cyril Hrubis
2022-01-11  6:10                       ` [LTP] [PATCH v4 5/5] runtest.sh: add test_kconfig.sh into ltp c test target Yang Xu
2022-01-13 11:25                         ` Petr Vorel
2022-01-13 15:54                         ` Cyril Hrubis
2022-01-10  1:49                 ` [LTP] [PATCH v3 4/4] sysctl/sysctl02.sh: Use kconfig shell api Yang Xu
2022-01-10  8:30                   ` Li Wang
2022-01-10 14:15                   ` Cyril Hrubis
2022-01-11  5:34                     ` xuyang2018.jy
2022-01-10  8:10                 ` [LTP] [PATCH v3 1/4] lib/tst_kconfig: Modify the return type of tst_kconfig_check function Li Wang
2022-01-10 12:18                 ` Cyril Hrubis
2022-01-10  5:45               ` [LTP] [PATCH v2 4/4] sysctl/sysctl02.sh: Use kconfig shell api xuyang2018.jy
2022-01-06  9:54           ` [LTP] [PATCH v2 1/4] lib/tst_kconfig: Modify the return type of tst_kconfig_check function Petr Vorel
2022-01-06 10:57           ` Cyril Hrubis
2022-01-07  1:25             ` xuyang2018.jy
2022-01-04  6:57 ` [LTP] [PATCH v1 3/3] sysctl/sysctl02.sh: Use kconfig shell api Yang Xu

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=61D6857F.9060802@fujitsu.com \
    --to=xuyang2018.jy@fujitsu.com \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.