diff mbox series

kunit: tool: revamp message for invalid kunitconfig

Message ID 20211111183356.4073001-1-dlatypov@google.com (mailing list archive)
State Accepted
Commit c44895b6cd8517c022dcc3d6fd4cd9bea1184a06
Delegated to: Brendan Higgins
Headers show
Series kunit: tool: revamp message for invalid kunitconfig | expand

Commit Message

Daniel Latypov Nov. 11, 2021, 6:33 p.m. UTC
The current error message is precise, but not very clear if you don't
already know what it's talking about, e.g.

> $ make ARCH=um olddefconfig O=.kunit
> ERROR:root:Provided Kconfig is not contained in validated .config. Following fields found in kunitconfig, but not in .config: CONFIG_DRM=y

Try to reword the error message so that it's
* your missing options usually have unsatisified dependencies
* if you're on UML, that might be the cause (it is, in this example)

Signed-off-by: Daniel Latypov <dlatypov@google.com>
---

Note: this is based on https://lore.kernel.org/linux-kselftest/20211106013058.2621799-1-dlatypov@google.com/
There's a fairly trivial merge conflict between these two patches (that
patch changes the line above where this diff starts).

---
 tools/testing/kunit/kunit_kernel.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)


base-commit: c949316af0a7c2103521aaa39be85392e2f02bab

Comments

David Gow Nov. 12, 2021, 4:52 a.m. UTC | #1
On Fri, Nov 12, 2021 at 2:34 AM Daniel Latypov <dlatypov@google.com> wrote:
>
> The current error message is precise, but not very clear if you don't
> already know what it's talking about, e.g.
>
> > $ make ARCH=um olddefconfig O=.kunit
> > ERROR:root:Provided Kconfig is not contained in validated .config. Following fields found in kunitconfig, but not in .config: CONFIG_DRM=y
>
> Try to reword the error message so that it's
> * your missing options usually have unsatisified dependencies
> * if you're on UML, that might be the cause (it is, in this example)
>
> Signed-off-by: Daniel Latypov <dlatypov@google.com>
> ---

Thanks -- I think this is a good improvement: the previous message was
pretty opaque.

Reviewed-by: David Gow <davidgow@google.com>

>
> Note: this is based on https://lore.kernel.org/linux-kselftest/20211106013058.2621799-1-dlatypov@google.com/
> There's a fairly trivial merge conflict between these two patches (that
> patch changes the line above where this diff starts).
>
> ---
>  tools/testing/kunit/kunit_kernel.py | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
> index 7d459d6d6ff2..350883672be0 100644
> --- a/tools/testing/kunit/kunit_kernel.py
> +++ b/tools/testing/kunit/kunit_kernel.py
> @@ -266,15 +266,17 @@ class LinuxSourceTree(object):
>         def validate_config(self, build_dir) -> bool:
>                 kconfig_path = get_kconfig_path(build_dir)
>                 validated_kconfig = kunit_config.parse_file(kconfig_path)
> -               if not self._kconfig.is_subset_of(validated_kconfig):
> -                       invalid = self._kconfig.entries() - validated_kconfig.entries()
> -                       message = 'Provided Kconfig is not contained in validated .config. Following fields found in kunitconfig, ' \
> -                                         'but not in .config: %s' % (
> -                                       ', '.join([str(e) for e in invalid])
> -                       )
> -                       logging.error(message)
> -                       return False
> -               return True
> +               if self._kconfig.is_subset_of(validated_kconfig):
> +                       return True
> +               invalid = self._kconfig.entries() - validated_kconfig.entries()
> +               message = 'Not all Kconfig options selected in kunitconfig were in the generated .config.\n' \
> +                         'This is probably due to unsatisfied dependencies.\n' \
> +                         'Missing: ' + ', '.join([str(e) for e in invalid])
> +               if self._arch == 'um':
> +                       message += '\nNote: many Kconfig options aren\'t available on UML. You can try running ' \
> +                                  'on a different architecture with something like "--arch=x86_64".'
> +               logging.error(message)
> +               return False
>
>         def build_config(self, build_dir, make_options) -> bool:
>                 kconfig_path = get_kconfig_path(build_dir)
>
> base-commit: c949316af0a7c2103521aaa39be85392e2f02bab
> --
> 2.34.0.rc1.387.gb447b232ab-goog
>
Brendan Higgins Dec. 7, 2021, 10:53 p.m. UTC | #2
On Thu, Nov 11, 2021 at 1:34 PM Daniel Latypov <dlatypov@google.com> wrote:
>
> The current error message is precise, but not very clear if you don't
> already know what it's talking about, e.g.
>
> > $ make ARCH=um olddefconfig O=.kunit
> > ERROR:root:Provided Kconfig is not contained in validated .config. Following fields found in kunitconfig, but not in .config: CONFIG_DRM=y
>
> Try to reword the error message so that it's
> * your missing options usually have unsatisified dependencies
> * if you're on UML, that might be the cause (it is, in this example)
>
> Signed-off-by: Daniel Latypov <dlatypov@google.com>

Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
diff mbox series

Patch

diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
index 7d459d6d6ff2..350883672be0 100644
--- a/tools/testing/kunit/kunit_kernel.py
+++ b/tools/testing/kunit/kunit_kernel.py
@@ -266,15 +266,17 @@  class LinuxSourceTree(object):
 	def validate_config(self, build_dir) -> bool:
 		kconfig_path = get_kconfig_path(build_dir)
 		validated_kconfig = kunit_config.parse_file(kconfig_path)
-		if not self._kconfig.is_subset_of(validated_kconfig):
-			invalid = self._kconfig.entries() - validated_kconfig.entries()
-			message = 'Provided Kconfig is not contained in validated .config. Following fields found in kunitconfig, ' \
-					  'but not in .config: %s' % (
-					', '.join([str(e) for e in invalid])
-			)
-			logging.error(message)
-			return False
-		return True
+		if self._kconfig.is_subset_of(validated_kconfig):
+			return True
+		invalid = self._kconfig.entries() - validated_kconfig.entries()
+		message = 'Not all Kconfig options selected in kunitconfig were in the generated .config.\n' \
+			  'This is probably due to unsatisfied dependencies.\n' \
+			  'Missing: ' + ', '.join([str(e) for e in invalid])
+		if self._arch == 'um':
+			message += '\nNote: many Kconfig options aren\'t available on UML. You can try running ' \
+				   'on a different architecture with something like "--arch=x86_64".'
+		logging.error(message)
+		return False
 
 	def build_config(self, build_dir, make_options) -> bool:
 		kconfig_path = get_kconfig_path(build_dir)