• Daniel Latypov's avatar
    kunit: tool: refactor internal kconfig handling, allow overriding · 8a7c6f85
    Daniel Latypov authored
    Currently, you cannot ovewrwrite what's in your kunitconfig via
    --kconfig_add.
    Nor can you override something in a qemu_config via either means.
    
    This patch makes it so we have this level of priority
    * --kconfig_add
    * kunitconfig file (the default or the one from --kunitconfig)
    * qemu_config
    
    The rationale for this order is that the more "dynamic" sources of
    kconfig options should take priority.
    
    --kconfig_add is obviously the most dynamic.
    And for kunitconfig, users probably tweak the file manually or specify
    --kunitconfig more often than they delve into qemu_config python files.
    
    And internally, we convert the kconfigs from a python list into a set or
    dict fairly often. We should just use a dict internally.
    We exposed the set transform in the past since we didn't define __eq__,
    so also take the chance to shore up the kunit_kconfig.Kconfig interface.
    
    Example
    =======
    
    Let's consider the unrealistic example where someone would want to
    disable CONFIG_KUNIT.
    I.e. they run
    $ ./tools/testing/kunit/kunit.py config --kconfig_add=CONFIG_KUNIT=n
    
    Before
    ------
    We'd write the following
    > # CONFIG_KUNIT is not set
    > CONFIG_KUNIT_ALL_TESTS=y
    > CONFIG_KUNIT_TEST=y
    > CONFIG_KUNIT=y
    > CONFIG_KUNIT_EXAMPLE_TEST=y
    
    And we'd error out with
    > ERROR:root:Not all Kconfig options selected in kunitconfig were in the generated .config.
    > This is probably due to unsatisfied dependencies.
    > Missing: # CONFIG_KUNIT is not set
    
    After
    -----
    We'd write the following
    > # CONFIG_KUNIT is not set
    > CONFIG_KUNIT_TEST=y
    > CONFIG_KUNIT_ALL_TESTS=y
    > CONFIG_KUNIT_EXAMPLE_TEST=y
    
    And we'd error out with
    > ERROR:root:Not all Kconfig options selected in kunitconfig were in the generated .config.
    > This is probably due to unsatisfied dependencies.
    > Missing: CONFIG_KUNIT_EXAMPLE_TEST=y, CONFIG_KUNIT_TEST=y, CONFIG_KUNIT_ALL_TESTS=y
    Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
    Reviewed-by: default avatarDavid Gow <davidgow@google.com>
    Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    8a7c6f85
kunit_tool_test.py 27.5 KB