Skip to content

Commit b2d0667

Browse files
committed
Add native full_testcase_name_map for clean test names
Introduces a new `full_testcase_name_map` parameter that stores filtered test case names during cartesian config parsing, removing type_specific and io-* provider prefixes natively using variant label attributes. Changes: - Add full_testcase_name_map generation in cartesian_config.py - Update discovery.py to use a native map - Add full_testcase_name_map to reserved keys Assisted-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Houqi (Nick) Zuo <hzuo@redhat.com>
1 parent 5d549aa commit b2d0667

3 files changed

Lines changed: 51 additions & 2 deletions

File tree

avocado_vt/discovery.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def convert_parameters(self, params):
4747
:return: dict with test name and vt parameters
4848
"""
4949
test_name = params.get("_short_name_map_file")["subtests.cfg"]
50+
# Use native full_testcase_name_map if available
51+
full_testcase_name_map = params.get("full_testcase_name_map")
52+
if full_testcase_name_map and "subtests.cfg" in full_testcase_name_map:
53+
params["full_testcase_name"] = full_testcase_name_map["subtests.cfg"]
5054
if get_opt(self.config, "vt.config") and get_opt(
5155
self.config, "vt.short_names_when_config"
5256
):

avocado_vt/plugins/vt_resolver.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ def _parameters_to_runnable(self, params):
2323

2424
# Flatten the vt_params, discarding the attributes that are not
2525
# scalars, and will not be used in the context of nrunner
26-
for key in ("_name_map_file", "_short_name_map_file", "dep"):
26+
for key in (
27+
"_name_map_file",
28+
"_short_name_map_file",
29+
"full_testcase_name_map",
30+
"dep",
31+
):
2732
if key in vt_params:
2833
del vt_params[key]
2934

virttest/cartesian_config.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,14 @@
140140
import sys
141141

142142
_reserved_keys = set(
143-
("name", "shortname", "dep", "_short_name_map_file", "_name_map_file")
143+
(
144+
"name",
145+
"shortname",
146+
"dep",
147+
"_short_name_map_file",
148+
"_name_map_file",
149+
"full_testcase_name_map",
150+
)
144151
)
145152
options = None
146153
num_failed_cases = 5
@@ -1803,6 +1810,39 @@ def _parse(self, lexer, node=None, prev_indent=-1):
18031810
)
18041811
node3.content += [(lexer.filename, lexer.linenum, op)]
18051812

1813+
# Create filtered testcase name map
1814+
# Filter out type_specific and io-* provider prefixes while preserving
1815+
# actual test names, parameters, and variants (including @default)
1816+
clean_parts = []
1817+
1818+
for label in node3.name:
1819+
label_name = str(label.name)
1820+
label_var = str(label.var_name) if label.var_name else None
1821+
1822+
# Skip type_specific subtest marker
1823+
if label_var == "subtest" and label_name == "type_specific":
1824+
continue
1825+
1826+
# Skip io-* provider subtests (io-github-autotest-qemu, io-github-autotest-libvirt, etc.)
1827+
if label_var == "subtest" and label_name.startswith("io-"):
1828+
continue
1829+
1830+
# Keep everything else:
1831+
# - Actual test subtests
1832+
# - Parameters (diff_parameter variants)
1833+
# - Regular variants (including @default)
1834+
clean_parts.append(label_name)
1835+
1836+
# Only create the map if we have actual content after filtering
1837+
if clean_parts:
1838+
clean_op = LUpdateFileMap()
1839+
clean_op.set_operands(
1840+
lexer.filename,
1841+
".".join(clean_parts),
1842+
"full_testcase_name_map",
1843+
)
1844+
node3.content += [(lexer.filename, lexer.linenum, clean_op)]
1845+
18061846
if node3.default and self.defaults:
18071847
# Move default variant in front of rest
18081848
# of all variants.

0 commit comments

Comments
 (0)