twister: replace dt_compat_enabled_with_alias filter
Originally added in 7733b94224
.
This filter is not well-formed. It's meant to match nodes like
/leds/led_0 in this DTS:
/ {
aliases {
led0 = &led0;
};
leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = <...>;
label = "LED 0";
};
};
};
Uses look like this:
filter: dt_compat_enabled_with_alias("gpio-leds", "led0")
But notice how the led_0 node doesn't have compatible "gpio-leds";
it's actually the *parent* node that has that compatible.
Replace this with a new filter, dt_enabled_alias_with_parent_compat(),
which is used like this:
filter: dt_enabled_alias_with_parent_compat("led0", "gpio-leds")
This has a name and argument order that makes the meaning of the
filter clearer.
Replace in-tree users with the new filter.
Deprecate the old filter and warn about its use using the standard
logging module.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
d802fc3bf0
commit
51f55b437f
7 changed files with 49 additions and 11 deletions
|
@ -3,7 +3,7 @@ sample:
|
|||
tests:
|
||||
sample.basic.blinky:
|
||||
tags: LED gpio
|
||||
filter: dt_compat_enabled_with_alias("gpio-leds", "led0")
|
||||
filter: dt_enabled_alias_with_parent_compat("led0", "gpio-leds")
|
||||
depends_on: gpio
|
||||
harness: led
|
||||
integration_platforms:
|
||||
|
|
|
@ -3,6 +3,6 @@ sample:
|
|||
tests:
|
||||
sample.basic.button:
|
||||
tags: button gpio
|
||||
filter: dt_compat_enabled_with_alias("gpio-keys", "sw0")
|
||||
filter: dt_enabled_alias_with_parent_compat("sw0", "gpio-keys")
|
||||
depends_on: gpio
|
||||
harness: button
|
||||
|
|
|
@ -5,8 +5,8 @@ sample:
|
|||
tests:
|
||||
sample.basic.threads:
|
||||
tags: kernel threads gpio
|
||||
filter: dt_compat_enabled_with_alias("gpio-leds", "led0") and
|
||||
dt_compat_enabled_with_alias("gpio-leds", "led1")
|
||||
filter: dt_enabled_alias_with_parent_compat("led0", "gpio-leds") and
|
||||
dt_enabled_alias_with_parent_compat("led1", "gpio-leds")
|
||||
depends_on: gpio
|
||||
harness: console
|
||||
harness_config:
|
||||
|
|
|
@ -4,7 +4,7 @@ sample:
|
|||
tests:
|
||||
sample.mgmt.osdp.control_panel:
|
||||
tags: osdp
|
||||
filter: dt_compat_enabled_with_alias("gpio-leds", "led0") and CONFIG_SERIAL
|
||||
filter: dt_enabled_alias_with_parent_compat("led0", "gpio-leds") and CONFIG_SERIAL
|
||||
harness: osdp
|
||||
integration_platforms:
|
||||
- frdm_k64f
|
||||
|
|
|
@ -4,7 +4,7 @@ sample:
|
|||
tests:
|
||||
sample.mgmt.osdp.peripheral_device:
|
||||
tags: osdp
|
||||
filter: dt_compat_enabled_with_alias("gpio-leds", "led0") and CONFIG_SERIAL
|
||||
filter: dt_enabled_alias_with_parent_compat("led0", "gpio-leds") and CONFIG_SERIAL
|
||||
harness: osdp
|
||||
integration_platforms:
|
||||
- frdm_k64f
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import copy
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
@ -18,6 +19,8 @@ except ImportError:
|
|||
"Please install the ply package using your workstation's\n"
|
||||
"package manager or the 'pip' tool.")
|
||||
|
||||
_logger = logging.getLogger('twister')
|
||||
|
||||
reserved = {
|
||||
'and' : 'AND',
|
||||
'or' : 'OR',
|
||||
|
@ -233,13 +236,34 @@ def ast_expr(ast, env, edt):
|
|||
if alias in node.aliases and node.status == "okay":
|
||||
return True
|
||||
return False
|
||||
elif ast[0] == "dt_enabled_alias_with_parent_compat":
|
||||
# Checks if the DT has an enabled alias node whose parent has
|
||||
# a given compatible. For matching things like gpio-leds child
|
||||
# nodes, which do not have compatibles themselves.
|
||||
#
|
||||
# The legacy "dt_compat_enabled_with_alias" form is still
|
||||
# accepted but is now deprecated and causes a warning. This is
|
||||
# meant to give downstream users some time to notice and
|
||||
# adjust. Its argument order only made sense under the (bad)
|
||||
# assumption that the gpio-leds child node has the same compatible
|
||||
|
||||
alias = ast[1][0]
|
||||
compat = ast[1][1]
|
||||
|
||||
return ast_handle_dt_enabled_alias_with_parent_compat(edt, alias,
|
||||
compat)
|
||||
elif ast[0] == "dt_compat_enabled_with_alias":
|
||||
compat = ast[1][0]
|
||||
alias = ast[1][1]
|
||||
for node in edt.nodes:
|
||||
if node.status == "okay" and alias in node.aliases and node.matching_compat == compat:
|
||||
return True
|
||||
return False
|
||||
|
||||
_logger.warning('dt_compat_enabled_with_alias("%s", "%s"): '
|
||||
'this is deprecated, use '
|
||||
'dt_enabled_alias_with_parent_compat("%s", "%s") '
|
||||
'instead',
|
||||
compat, alias, alias, compat)
|
||||
|
||||
return ast_handle_dt_enabled_alias_with_parent_compat(edt, alias,
|
||||
compat)
|
||||
elif ast[0] == "dt_chosen_enabled":
|
||||
chosen = ast[1][0]
|
||||
node = edt.chosen_node(chosen)
|
||||
|
@ -247,6 +271,20 @@ def ast_expr(ast, env, edt):
|
|||
return True
|
||||
return False
|
||||
|
||||
def ast_handle_dt_enabled_alias_with_parent_compat(edt, alias, compat):
|
||||
# Helper shared with the now deprecated
|
||||
# dt_compat_enabled_with_alias version.
|
||||
|
||||
for node in edt.nodes:
|
||||
parent = node.parent
|
||||
if parent is None:
|
||||
continue
|
||||
if (node.status == "okay" and alias in node.aliases and
|
||||
parent.matching_compat == compat):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
mutex = threading.Lock()
|
||||
|
||||
def parse(expr_text, env, edt):
|
||||
|
|
|
@ -5,4 +5,4 @@ tests:
|
|||
min_flash: 48
|
||||
# Fix exclude when we can exclude just sim run
|
||||
platform_exclude: mps2_an385 mps2_an521
|
||||
filter: dt_compat_enabled_with_alias("gpio-leds", "led0")
|
||||
filter: dt_enabled_alias_with_parent_compat("led0", "gpio-leds")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue