Skip to content

Commit 4161e5c

Browse files
committed
Move test config keys out of targets.json
Change TestConfig class methods to module methods
1 parent e48f994 commit 4161e5c

File tree

5 files changed

+38
-34
lines changed

5 files changed

+38
-34
lines changed

targets/targets.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,13 +1688,8 @@
16881688
"supported_form_factors": ["ARDUINO"],
16891689
"core": "Cortex-M4F",
16901690
"extra_labels_add": ["STM32F4", "STM32F439", "STM32F439ZI","STM32F439xx", "STM32F439xI"],
1691-
<<<<<<< HEAD
16921691
"macros": ["MBEDTLS_CONFIG_HW_SUPPORT", "HSE_VALUE=24000000", "HSE_STARTUP_TIMEOUT=5000", "CB_INTERFACE_SDIO","CB_CHIP_WL18XX","SUPPORT_80211D_ALWAYS","WLAN_ENABLED","MBEDTLS_ARC4_C","MBEDTLS_DES_C","MBEDTLS_MD4_C","MBEDTLS_MD5_C","MBEDTLS_SHA1_C"],
16931692
"device_has_add": ["CAN", "EMAC", "TRNG", "FLASH"],
1694-
=======
1695-
"macros": ["HSE_VALUE=24000000", "HSE_STARTUP_TIMEOUT=5000", "CB_INTERFACE_SDIO","CB_CHIP_WL18XX","SUPPORT_80211D_ALWAYS","WLAN_ENABLED","MBEDTLS_ARC4_C","MBEDTLS_DES_C","MBEDTLS_MD4_C","MBEDTLS_MD5_C","MBEDTLS_SHA1_C"],
1696-
"device_has_add": ["CAN", "EMAC", "TRNG", "FLASH", "ETHERNET", "ODIN_WIFI"],
1697-
>>>>>>> Add ETHERNET and ODIN_WIFI to odin device has. Add odin WiFi test configuration
16981693
"device_has_remove": ["RTC", "SLEEP"],
16991694
"features": ["LWIP"],
17001695
"release_versions": ["5"],

tools/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
from tools.config import ConfigException
3030
from tools.test_api import test_path_to_name, find_tests, get_test_config, print_tests, build_tests, test_spec_from_test_builds
31-
from tools.test_configs import TestConfig
31+
import tools.test_configs as TestConfig
3232
from tools.options import get_default_options_parser, extract_profile, extract_mcus
3333
from tools.build_api import build_project, build_library
3434
from tools.build_api import print_build_memory_usage

tools/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
from tools.utils import construct_enum
5151
from tools.memap import MemapParser
5252
from tools.targets import TARGET_MAP
53-
from tools.test_configs import TestConfig
53+
import tools.test_configs as TestConfig
5454
from tools.test_db import BaseDBAccess
5555
from tools.build_api import build_project, build_mbed_libs, build_lib
5656
from tools.build_api import get_target_supported_toolchains

tools/test_configs/__init__.py

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
from os.path import dirname, abspath, join
22

33
from tools.utils import json_file_to_dict
4-
from tools.targets import TARGET_MAP
54

6-
class TestConfig:
7-
CONFIG_DIR = dirname(abspath(__file__))
8-
CONFIG_MAP = json_file_to_dict(join(CONFIG_DIR, "config_paths.json"))
5+
CONFIG_DIR = dirname(abspath(__file__))
6+
CONFIG_MAP = json_file_to_dict(join(CONFIG_DIR, "config_paths.json"))
7+
TARGET_CONFIGS = json_file_to_dict(join(CONFIG_DIR, "target_configs.json"))
98

10-
@classmethod
11-
def get_valid_configs(cls, target_name):
12-
target = TARGET_MAP[target_name]
13-
config_dict = {}
14-
for attr in cls.CONFIG_MAP:
15-
if attr in target.device_has:
16-
config_dict[attr] = cls.CONFIG_MAP[attr]
17-
return config_dict
9+
def get_valid_configs(target_name):
10+
if target_name in TARGET_CONFIGS:
11+
target_config = TARGET_CONFIGS[target_name]
12+
else:
13+
return {}
1814

19-
@classmethod
20-
def get_config_path(cls, conf_name, target_name):
21-
configs = cls.get_valid_configs(target_name)
22-
if configs and conf_name.upper() in configs:
23-
return join(cls.CONFIG_DIR, configs[conf_name.upper()])
24-
else:
25-
return None
15+
config_dict = {}
16+
for attr in CONFIG_MAP:
17+
if attr in target_config['test_configurations']:
18+
config_dict[attr] = CONFIG_MAP[attr]
19+
return config_dict
2620

27-
@classmethod
28-
def get_default_config(cls, target_name):
29-
configs = cls.get_valid_configs(target_name)
30-
if configs:
31-
keys = configs.keys()
32-
return join(cls.CONFIG_DIR, configs[keys[0]])
33-
else:
34-
return None
21+
def get_config_path(conf_name, target_name):
22+
configs = get_valid_configs(target_name)
23+
if configs and conf_name.upper() in configs:
24+
return join(CONFIG_DIR, configs[conf_name.upper()])
25+
else:
26+
return None
27+
28+
def get_default_config(target_name):
29+
if target_name in TARGET_CONFIGS:
30+
config_name = TARGET_CONFIGS[target_name]['default_test_configuration']
31+
return join(CONFIG_DIR, CONFIG_MAP[config_name])
32+
else:
33+
return None
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"UBLOX_EVK_ODIN_W2": {
3+
"default_test_configuration": "ODIN_WIFI",
4+
"test_configurations": ["ODIN_WIFI", "ETHERNET"]
5+
},
6+
"K64F": {
7+
"default_test_configuration": "ETHERNET",
8+
"test_configurations": ["ETHERNET"]
9+
}
10+
}

0 commit comments

Comments
 (0)