Skip to content

Commit 57b2ef8

Browse files
committed
Merge branch 'feat/diag_cpuinfo' into 'master'
feat(tools): add basic system information to diag report Closes IDF-12100 See merge request espressif/esp-idf!36627
2 parents 9f253c7 + 350dbaf commit 57b2ef8

File tree

4 files changed

+70
-15
lines changed

4 files changed

+70
-15
lines changed

tools/idf_py_actions/diag/recipes/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ variable, format it as `${NAME}`, such as `${IDF_PATH}`.
9090
Brief description of the `step`, displayed in the `idf.py diag` progress
9191
beneath the `recipe` description.
9292

93+
* system: string (optional)
94+
Can be used to restrict the operating system on which the step will be
95+
executed. It should be Linux, Darwin, or Windows. If specified, the step
96+
will only run on the designated system.
97+
9398
* output: string (optional)
9499

95100
Global output directory for the `step`. This directory serves as the main

tools/idf_py_actions/diag/recipes/idf.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,10 @@ steps:
66
cmds:
77
- exec:
88
cmd: 'idf.py --version'
9-
timeout: 10
109
output: esp_idf.ver
1110

1211
- name: 'ESP-IDF Git Version'
1312
cmds:
1413
- exec:
1514
cmd: 'git -C ${IDF_PATH} describe'
1615
output: esp_idf_git.ver
17-
18-
- name: 'Platform Information'
19-
cmds:
20-
- exec:
21-
cmd:
22-
- python
23-
- -c
24-
- |
25-
import platform
26-
print(f'system: {platform.system()}')
27-
print(f'release: {platform.release()}')
28-
print(f'machine: {platform.machine()}')
29-
output: platform.inf
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
description: System information
2+
tags: [system, base, project]
3+
steps:
4+
- name: 'Platform Information'
5+
cmds:
6+
- exec:
7+
cmd:
8+
- python
9+
- -c
10+
- |
11+
import platform
12+
print(f'system: {platform.system()}')
13+
print(f'release: {platform.release()}')
14+
print(f'machine: {platform.machine()}')
15+
output: platform.inf
16+
17+
- name: 'Linux System Information'
18+
system: Linux
19+
output: linux
20+
cmds:
21+
- file:
22+
path: '/proc/cpuinfo'
23+
- file:
24+
path: '/etc/os-release'
25+
- exec:
26+
cmd: 'uname -a'
27+
output: uname
28+
29+
- name: 'Darwin Information'
30+
system: Darwin
31+
output: darwin
32+
cmds:
33+
- exec:
34+
cmd: 'sysctl machdep.cpu'
35+
output: machdep.cpu
36+
- exec:
37+
cmd: 'sw_vers'
38+
output: sw_vers
39+
- exec:
40+
cmd: 'uname -a'
41+
output: uname
42+
43+
- name: 'Windows Information'
44+
system: Windows
45+
output: windows
46+
cmds:
47+
- exec:
48+
cmd: 'systeminfo'
49+
output: systeminfo

tools/idf_py_actions/diag_ext.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import atexit
44
import difflib
55
import os
6+
import platform
67
import re
78
import shutil
89
import sys
@@ -289,7 +290,7 @@ def validate_recipe(recipe: Dict) -> None:
289290
dependencies and to provide more informative error messages.
290291
"""
291292
recipe_keys = ['description', 'tags', 'output', 'steps']
292-
step_keys = ['name', 'cmds', 'output']
293+
step_keys = ['name', 'cmds', 'output', 'system']
293294
recipe_description = recipe.get('description')
294295
recipe_tags = recipe.get('tags')
295296
recipe_output = recipe.get('output')
@@ -330,6 +331,7 @@ def validate_recipe(recipe: Dict) -> None:
330331
step_name = step.get('name')
331332
step_output = step.get('output')
332333
step_cmds = step.get('cmds')
334+
step_system = step.get('system')
333335

334336
if not step_name:
335337
raise RuntimeError(f'Recipe step is missing "name" key')
@@ -342,6 +344,12 @@ def validate_recipe(recipe: Dict) -> None:
342344
if step_output:
343345
if type(step_output) is not str:
344346
raise RuntimeError(f'Step "output" key is not of type "str"')
347+
if step_system:
348+
if type(step_system) is not str:
349+
raise RuntimeError(f'Step "system" key is not of type "str"')
350+
if step_system not in ['Linux', 'Windows', 'Darwin']:
351+
raise RuntimeError((f'Unknown "system" key value "{step_system}", '
352+
f'expecting "Linux", "Windows" or "Darwin"'))
345353

346354
for cmd in step_cmds:
347355
if 'exec' in cmd:
@@ -769,6 +777,12 @@ def process_recipe(recipe: Dict) -> None:
769777
"""execute commands for every stage in a recipe"""
770778
for step in recipe['steps']:
771779
step_name = step['name']
780+
step_system = step.get('system')
781+
782+
if step_system and step_system != platform.system():
783+
dbg(f'Skipping step "{step_name}" for "{step_system}"')
784+
continue
785+
772786
dbg(f'Processing step "{step_name}"')
773787
print(f'* {step_name}')
774788
for cmd in step['cmds']:
@@ -1014,6 +1028,7 @@ def create(action: str,
10141028
dbg(f'Recipe variables: {recipe_variables}')
10151029
dbg(f'Project directory: {project_dir}')
10161030
dbg(f'Build directory: {build_dir}')
1031+
dbg(f'System: {platform.system()}')
10171032

10181033
if list_recipes:
10191034
# List recipes command

0 commit comments

Comments
 (0)