]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
test: allow multiple config options in buildconfigspec
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 3 May 2025 13:31:54 +0000 (15:31 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 18 May 2025 07:16:51 +0000 (09:16 +0200)
In some cases we have alternative configuration options that supply the
same functionality, e.g CONFIG_NET and CONFIG_NET_LWIP.

Allow to specify all of them as arguments for buildconfigspec() and execute
the text if any of these is fulfilled, e.g.

    @pytest.mark.buildconfigspec('net', 'net_lwip')

Update the documentation.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
doc/develop/pytest/usage.rst
test/py/conftest.py

index 49d269d66a709438e589b7b09d904bca2f023a1e..779b2dbe24bafd387e3323432ef74a944884177d 100644 (file)
@@ -522,3 +522,27 @@ of the `ubman.config` object, for example
 Build configuration values (from `.config`) may be accessed via the dictionary
 `ubman.config.buildconfig`, with keys equal to the Kconfig variable
 names.
+
+A required configuration setting can be defined via a buildconfigspec()
+annotation. The name of the configuration option is specified in lower case. The
+following annotation for a test requires CONFIG_EFI_LOADER=y:
+
+.. code-block:: python
+
+    @pytest.mark.buildconfigspec('efi_loader')
+
+Sometimes multiple configuration option supply the same functionality. If
+multiple arguments are passed to buildconfigspec(), only one of the
+configuration options needs to be set. The following annotation requires that
+either of CONFIG_NET or CONFIG_NET_LWIP is set:
+
+.. code-block:: python
+
+    @pytest.mark.buildconfigspec('net', 'net lwip')
+
+The notbuildconfigspec() annotation can be used to require a configuration
+option not to be set. The following annotation requires CONFIG_RISCV=n:
+
+.. code-block:: python
+
+    @pytest.mark.notbuildconfigspec('riscv')
index 5aea85647afd519fc1db050915910b39dbee9624..6c3ac67979a2e0cbd2d60593cc963aa5a34e12ea 100644 (file)
@@ -711,9 +711,13 @@ def setup_buildconfigspec(item):
     """
 
     for options in item.iter_markers('buildconfigspec'):
-        option = options.args[0]
-        if not ubconfig.buildconfig.get('config_' + option.lower(), None):
-            pytest.skip('.config feature "%s" not enabled' % option.lower())
+        nomatch = True
+        for arg in options.args:
+            if ubconfig.buildconfig.get('config_' + arg.lower(), None):
+                nomatch = False
+        if nomatch:
+            argsString = ', '.join(options.args)
+            pytest.skip(f'.config features "{argsString}" not enabled')
     for options in item.iter_markers('notbuildconfigspec'):
         option = options.args[0]
         if ubconfig.buildconfig.get('config_' + option.lower(), None):