Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kconfig validation #37

Closed
webknjaz opened this issue Feb 6, 2018 · 3 comments
Closed

kconfig validation #37

webknjaz opened this issue Feb 6, 2018 · 3 comments

Comments

@webknjaz
Copy link

webknjaz commented Feb 6, 2018

Hello,

Is it possible to use this project for the purpose of validation of option dependencies in linux kernel config? if yes, could you please point to some specific doc/code where I could start. TIA.

@ulfalizer
Copy link
Owner

ulfalizer commented Feb 6, 2018

Hello,

If you want to check that each value set in a defconfig file matches the final value the symbol gets, then you could do the following, adapted from merge_config.py:

...
kconf.load_config(defconfig_file_to_check)

# Print warnings for symbols whose actual value doesn't match the assigned
# value
for sym in kconf.defined_syms:
    # Was the symbol assigned to?
    if sym.user_value is not None:
        # Tristate values are represented as 0, 1, 2. Having them as
        # "n", "m", "y" is more convenient here, so convert.
        if sym.type in (BOOL, TRISTATE):
            user_value = TRI_TO_STR[sym.user_value]
        else:
            user_value = sym.user_value

        if user_value != sym.str_value:
            print('warning: {} was assigned the value "{}" but got the '
                  'value "{}" -- check dependencies'
                  .format(sym.name, user_value, sym.str_value))

This works fine for defconfig files, because you always expect the final value to match the assigned value in those (look up make savedefconfig -- they're a kind of "minimal" .config from which the full .config is derived). It might get a bit more iffy for old "full" .config files.

If you want to do a batch job over multiple defconfig files in the kernel, take a look at how the test_defconfig() test is implemented in the test suite. The list_undefined.py script might give you some ideas too.

@webknjaz
Copy link
Author

webknjaz commented Feb 7, 2018

Thanks for the pointers :) I'll try

@ulfalizer
Copy link
Owner

Closing for now. Open another issue (or reopen this one, if that's possible) if you have other questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants