forked from espressif/esp-bsp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
123 lines (112 loc) · 4.89 KB
/
conftest.py
File metadata and controls
123 lines (112 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import os
import uuid
import pytest
def pytest_generate_tests(metafunc):
allowed_ids = set()
# get markers from test case (e.g. 'esp_box_3')
for marker in metafunc.definition.iter_markers():
allowed_ids.add(marker.name)
all_params = [
pytest.param('/dev/boards/esp-box-3',
'/dev/boards/esp-box-3',
'build_esp-box-3',
id='esp_box_3'),
pytest.param('/dev/boards/esp32_c3_lcdkit',
'/dev/boards/esp32_c3_lcdkit',
'build_esp32_c3_lcdkit',
id='esp32_c3_lcdkit'),
pytest.param('/dev/boards/esp32_p4_box',
'/dev/boards/esp32_p4_box',
'build_esp32_p4_box',
id='esp32_p4_box'),
pytest.param('/dev/boards/esp32_p4_function_ev_board',
'/dev/boards/esp32_p4_function_ev_board',
'build_esp32_p4_function_ev_board',
id='esp32_p4_function_ev_board'),
pytest.param('/dev/boards/esp32_s3_eye',
'/dev/boards/esp32_s3_eye',
'build_esp32_s3_eye',
id='esp32_s3_eye'),
pytest.param('/dev/boards/esp32_s3_lcd_ev_board',
'/dev/boards/esp32_s3_lcd_ev_board',
'build_esp32_s3_lcd_ev_board',
id='esp32_s3_lcd_ev_board'),
pytest.param('/dev/boards/esp32_s3_lcd_ev_board-2',
'/dev/boards/esp32_s3_lcd_ev_board-2',
'build_esp32_s3_lcd_ev_board',
id='esp32_s3_lcd_ev_board_2'),
pytest.param('/dev/boards/esp32_s3_usb_otg',
'/dev/boards/esp32_s3_usb_otg',
'build_esp32_s3_usb_otg',
id='esp32_s3_usb_otg'),
pytest.param('/dev/boards/esp_wrover_kit',
'/dev/boards/esp_wrover_kit',
'build_esp_wrover_kit',
id='esp_wrover_kit'),
pytest.param('/dev/boards/esp32_azure_iot_kit',
'/dev/boards/esp32_azure_iot_kit',
'build_esp32_azure_iot_kit',
id='esp32_azure_iot_kit'),
pytest.param('/dev/boards/m5dial',
'/dev/boards/m5dial',
'build_m5dial',
id='m5dial'),
pytest.param('/dev/boards/m5stack_core',
'/dev/boards/m5stack_core',
'build_m5stack_core',
id='m5stack_core'),
pytest.param('/dev/boards/m5stack_core_2',
'/dev/boards/m5stack_core_2',
'build_m5stack_core',
id='m5stack_core_2'),
pytest.param('/dev/boards/m5stack_core_s3',
'/dev/boards/m5stack_core_s3',
'build_m5stack_core_s3',
id='m5stack_core_s3'),
pytest.param('/dev/boards/m5stack_core_s3_se',
'/dev/boards/m5stack_core_s3_se',
'build_m5stack_core_s3',
id='m5stack_core_s3_se'),
pytest.param('/dev/boards/m5_atom_s3',
'/dev/boards/m5_atom_s3',
'build_m5_atom_s3',
id='m5_atom_s3'),
pytest.param('/dev/boards/esp32_s3_devkitc_1_1',
'/dev/boards/esp32_s3_devkitc_1_1',
'build_esp_bsp_devkit',
id='esp_bsp_devkit'),
pytest.param('/dev/boards/esp32_s2_devkitc_1',
'/dev/boards/esp32_s2_devkitc_1',
'build_esp_bsp_generic',
id='esp_bsp_generic'),
pytest.param('/dev/boards/esp32_s3_korvo_2',
'/dev/boards/esp32_s3_korvo_2',
'build_esp32_s3_korvo_2',
id='esp32_s3_korvo_2'),
]
# filter by markers
selected_params = [
p for p in all_params if p.id in allowed_ids
]
# if not markers, use all
if not selected_params:
selected_params = all_params
if 'port' in metafunc.fixturenames and 'flash_port' in metafunc.fixturenames:
metafunc.parametrize(
'port, flash_port, build_dir',
selected_params
)
@pytest.fixture
def build_dir(build_dir: str) -> str:
return f'{build_dir}'
# This fixing using cache when used "-n auto" (parallel)
def pytest_configure(config):
# If run pytest-xdist (parallel), set unique cache dir
worker_id = os.getenv("PYTEST_XDIST_WORKER", None)
if worker_id:
cache_dir = f"/tmp/pytest-embedded-cache-{uuid.uuid4()}"
os.environ["PYTEST_EMBEDDED_CACHE_DIR"] = cache_dir
os.makedirs(cache_dir, exist_ok=True)
print(f"Using embedded cache dir: {cache_dir}")