diff --git a/mbed_greentea/mbed_greentea_cli.py b/mbed_greentea/mbed_greentea_cli.py
index f6a13c4..446b965 100644
--- a/mbed_greentea/mbed_greentea_cli.py
+++ b/mbed_greentea/mbed_greentea_cli.py
@@ -23,6 +23,7 @@ import os
 import sys
 import random
 import optparse
+import fnmatch
 from time import time
 try:
     from Queue import Queue
@@ -119,18 +120,6 @@ def create_filtered_test_list(ctest_test_list, test_by_names, skip_test, test_sp
     @return
     """
 
-    def filter_names_by_prefix(test_case_name_list, prefix_name):
-        """!
-        @param test_case_name_list List of all test cases
-        @param prefix_name Prefix of test name we are looking for
-        @result Set with names of test names starting with 'prefix_name'
-        """
-        result = list()
-        for test_name in test_case_name_list:
-            if test_name.startswith(prefix_name):
-                result.append(test_name)
-        return sorted(result)
-
     filtered_ctest_test_list = ctest_test_list
     test_list = None
     invalid_test_names = []
@@ -143,17 +132,15 @@ def create_filtered_test_list(ctest_test_list, test_by_names, skip_test, test_sp
         gt_logger.gt_log("test case filter (specified with -n option)")
 
         for test_name in set(test_list):
-            if test_name.endswith('*'):
-                # This 'star-sufix' filter allows users to filter tests with fixed prefixes
-                # Example: -n 'TESTS-mbed_drivers* will filter all test cases with name starting with 'TESTS-mbed_drivers'
-                for test_name_filtered in filter_names_by_prefix(ctest_test_list.keys(), test_name[:-1]):
-                    gt_logger.gt_log_tab("test filtered in '%s'"% gt_logger.gt_bright(test_name_filtered))
-                    filtered_ctest_test_list[test_name_filtered] = ctest_test_list[test_name_filtered]
-            elif test_name not in ctest_test_list:
-                invalid_test_names.append(test_name)
+            gt_logger.gt_log_tab(test_name)
+            matches = [test for test in ctest_test_list.keys() if fnmatch.fnmatch(test, test_name)]
+            gt_logger.gt_log_tab(str(ctest_test_list))
+            if matches:
+                for match in matches:
+                    gt_logger.gt_log_tab("test filtered in '%s'"% gt_logger.gt_bright(match))
+                    filtered_ctest_test_list[match] = ctest_test_list[match]
             else:
-                gt_logger.gt_log_tab("test filtered in '%s'"% gt_logger.gt_bright(test_name))
-                filtered_ctest_test_list[test_name] = ctest_test_list[test_name]
+                invalid_test_names.append(test_name)
 
     if skip_test:
         test_list = skip_test.split(',')

Test names are not correctly globbed
Test names only respect a wildcard that is placed at the end of the string. Ex. "mbed-os-*".

However, it does not respect the wildcard anywhere else. Ex. "*-timer"

The build tools accept these wildcards, so greentea should as well. This is the line responsible: https://github.com/ARMmbed/greentea/blob/32b95b44be653c3db527c02e1c5e1ffdc7d37f6f/mbed_greentea/mbed_greentea_cli.py#L146

Should be switched to `fnmatch`.

(This is mostly a note to myself to fix it)
diff --git a/test/mbed_gt_cli.py b/test/mbed_gt_cli.py
index 0646c20..8f4a1eb 100644
--- a/test/mbed_gt_cli.py
+++ b/test/mbed_gt_cli.py
@@ -21,6 +21,36 @@ import sys
 import unittest
 
 from mbed_greentea import mbed_greentea_cli
+from mbed_greentea.tests_spec import TestSpec
+
+test_spec_def = {
+    "builds": {
+        "K64F-ARM": {
+            "platform": "K64F",
+            "toolchain": "ARM",
+            "base_path": "./.build/K64F/ARM",
+            "baud_rate": 115200,
+            "tests": {
+                "mbed-drivers-test-generic_tests":{
+                    "binaries":[
+                        {
+                            "binary_type": "bootable",
+                            "path": "./.build/K64F/ARM/mbed-drivers-test-generic_tests.bin"
+                        }
+                    ]
+                },
+                "mbed-drivers-test-c_strings":{
+                    "binaries":[
+                        {
+                            "binary_type": "bootable",
+                            "path": "./.build/K64F/ARM/mbed-drivers-test-c_strings.bin"
+                        }
+                    ]
+                }
+            }
+        }
+    }
+}
 
 class GreenteaCliFunctionality(unittest.TestCase):
 
@@ -86,5 +116,36 @@ class GreenteaCliFunctionality(unittest.TestCase):
         os.chdir(curr_dir)
         shutil.rmtree(test1_dir)
 
+    def test_create_filtered_test_list(self):
+        test_spec = TestSpec()
+        test_spec.parse(test_spec_def)
+        test_build = test_spec.get_test_builds()[0]
+
+        test_list = mbed_greentea_cli.create_filtered_test_list(test_build.get_tests(),
+                                                                'mbed-drivers-test-generic_*',
+                                                                None,
+                                                                test_spec=test_spec)
+        self.assertEqual(set(test_list.keys()), set(['mbed-drivers-test-generic_tests']))
+
+        test_list = mbed_greentea_cli.create_filtered_test_list(test_build.get_tests(),
+                                                                '*_strings',
+                                                                None,
+                                                                test_spec=test_spec)
+        self.assertEqual(set(test_list.keys()), set(['mbed-drivers-test-c_strings']))
+
+        test_list = mbed_greentea_cli.create_filtered_test_list(test_build.get_tests(),
+                                                                'mbed*s',
+                                                                None,
+                                                                test_spec=test_spec)
+        expected = set(['mbed-drivers-test-c_strings', 'mbed-drivers-test-generic_tests'])
+        self.assertEqual(set(test_list.keys()), expected)
+
+        test_list = mbed_greentea_cli.create_filtered_test_list(test_build.get_tests(),
+                                                                '*-drivers-*',
+                                                                None,
+                                                                test_spec=test_spec)
+        expected = set(['mbed-drivers-test-c_strings', 'mbed-drivers-test-generic_tests'])
+        self.assertEqual(set(test_list.keys()), expected)
+
 if __name__ == '__main__':
     unittest.main()
diff --git a/test/mbed_gt_target_info.py b/test/mbed_gt_target_info.py
index e630e7b..a12ba09 100644
--- a/test/mbed_gt_target_info.py
+++ b/test/mbed_gt_target_info.py
@@ -416,7 +416,7 @@ mbed-gcc 1.1.0
         with patch("mbed_greentea.mbed_target_info.walk") as _walk:
             _walk.return_value = iter([("", ["foo"], []), ("foo", [], ["targets.json"])])
             result = list(mbed_target_info._find_targets_json("bogus_path"))
-            self.assertEqual(result, ["foo/targets.json"])
+            self.assertEqual(result, [os.path.join("foo", "targets.json")])
 
     def test_find_targets_json_ignored(self):
         with patch("mbed_greentea.mbed_target_info.walk") as _walk:

pip install -e .[dev]
parse_log_pytest
pytest
pytest
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
appdirs==1.4.4
beautifulsoup4==4.13.3
certifi==2025.1.31
charset-normalizer==3.4.1
colorama==0.3.9
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
fasteners==0.19
future==1.0.0
idna==3.10
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
intelhex==2.3.0
junit-xml==1.9
lockfile==0.12.2
-e git+https://github.com/ARMmbed/greentea.git@68508c5f4d7cf0635c75399d0ff7cfa896fdf2cc#egg=mbed_greentea
mbed-host-tests==1.8.15
mbed-ls==1.8.15
mbed-os-tools==1.8.15
mock==5.2.0
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
prettytable==2.5.0
pyserial==3.5
pytest @ file:///croot/pytest_1738938843180/work
requests==2.32.3
six==1.17.0
soupsieve==2.6
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
typing_extensions==4.13.0
urllib3==2.3.0
wcwidth==0.2.13

name: greentea
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - exceptiongroup=1.2.0=py39h06a4308_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - packaging=24.2=py39h06a4308_0
  - pip=25.0=py39h06a4308_0
  - pluggy=1.5.0=py39h06a4308_0
  - pytest=8.3.4=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py39h06a4308_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - appdirs==1.4.4
      - beautifulsoup4==4.13.3
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - colorama==0.3.9
      - fasteners==0.19
      - future==1.0.0
      - idna==3.10
      - intelhex==2.3.0
      - junit-xml==1.9
      - lockfile==0.12.2
      - mbed-host-tests==1.8.15
      - mbed-ls==1.8.15
      - mbed-os-tools==1.8.15
      - mock==5.2.0
      - prettytable==2.5.0
      - pyserial==3.5
      - requests==2.32.3
      - six==1.17.0
      - soupsieve==2.6
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - wcwidth==0.2.13
prefix: /opt/conda/envs/greentea

test/mbed_gt_cli.py::GreenteaCliFunctionality::test_create_filtered_test_list
test/mbed_gt_cli.py::GreenteaCliFunctionality::test_get_greentea_version test/mbed_gt_cli.py::GreenteaCliFunctionality::test_get_hello_string test/mbed_gt_cli.py::GreenteaCliFunctionality::test_get_local_host_tests_dir_default_path test/mbed_gt_cli.py::GreenteaCliFunctionality::test_get_local_host_tests_dir_invalid_path test/mbed_gt_cli.py::GreenteaCliFunctionality::test_get_local_host_tests_dir_valid_path test/mbed_gt_cli.py::GreenteaCliFunctionality::test_print_version test/mbed_gt_target_info.py::GreenteaTargetInfo::test_find_targets_json test/mbed_gt_target_info.py::GreenteaTargetInfo::test_find_targets_json_ignored test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_mbed_target_from_current_dir_ok test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_mbed_targets_from_yotta_local_module_invalid_path test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_mbed_targets_from_yotta_local_module_invalid_target test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_mbed_targets_from_yotta_local_module_valid test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_platform_property_from_targets_empty_json test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_platform_property_from_targets_in_json test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_platform_property_from_targets_invalid_json test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_platform_property_from_targets_no_file test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_platform_property_from_targets_no_json test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_platform_property_from_targets_no_value test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_yotta_target_from_local_config_failed_open test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_yotta_target_from_local_config_invalid_path test/mbed_gt_target_info.py::GreenteaTargetInfo::test_get_yotta_target_from_local_config_valid_path test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_add_target_info_mapping test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_mbed_target_from_target_json test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_mbed_target_from_target_json_missing_json_data test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_mbed_target_from_target_json_missing_keywords test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_mbed_target_from_target_json_missing_name test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_mbed_target_from_target_json_missing_target test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_mbed_target_from_target_json_multiple test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_mbed_target_from_target_json_no_keywords test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_mbed_target_from_target_json_no_name test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_json_for_build_name test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_search_cmd_output test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_search_cmd_output_new_style test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_search_cmd_output_new_style_text test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_search_cmd_output_new_style_text_2 test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_search_cmd_output_text test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_search_cmd_output_with_ssl_errors test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_target_cmd_output test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_target_cmd_output_fail test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_target_cmd_output_mixed_chars test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_target_cmd_output_mixed_nl test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_target_cmd_output_mixed_nl_whitechars test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_target_cmd_output_mixed_rcnl test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_target_cmd_output_mixed_rcnl_whitechars test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_target_cmd_output_mixed_version test/mbed_gt_target_info.py::GreenteaTargetInfo::test_parse_yotta_target_cmd_output_mixed_whitechars test/mbed_gt_target_info.py::GreenteaTargetInfo::test_platform_property test/mbed_gt_target_info.py::GreenteaTargetInfo::test_platform_property_from_default test/mbed_gt_target_info.py::GreenteaTargetInfo::test_platform_property_from_default_missing test/mbed_gt_target_info.py::GreenteaTargetInfo::test_platform_property_from_info_mapping test/mbed_gt_target_info.py::GreenteaTargetInfo::test_platform_property_from_info_mapping_bad_platform test/mbed_gt_target_info.py::GreenteaTargetInfo::test_platform_property_from_info_mapping_missing test/mbed_gt_target_info.py::GreenteaTargetInfo::test_platform_property_from_targets_json_base_target test/mbed_gt_target_info.py::GreenteaTargetInfo::test_platform_property_from_targets_json_empty test/mbed_gt_target_info.py::GreenteaTargetInfo::test_platform_property_from_targets_json_inherits
mbed_greentea/mbed_greentea_cli.py
mbed_greentea/mbed_greentea_cli.py