ntfc 0.0.2__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ntfc-0.0.2/src/ntfc.egg-info → ntfc-0.0.3}/PKG-INFO +4 -2
- {ntfc-0.0.2 → ntfc-0.0.3}/README.md +1 -1
- {ntfc-0.0.2 → ntfc-0.0.3}/pyproject.toml +6 -1
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/builder.py +130 -10
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/core.py +61 -42
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/coreconfig.py +117 -20
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/cores.py +15 -12
- ntfc-0.0.3/src/ntfc/debug/config.py +413 -0
- ntfc-0.0.3/src/ntfc/debug/coredump/base.py +96 -0
- ntfc-0.0.3/src/ntfc/debug/coredump/fastboot_handler.py +94 -0
- ntfc-0.0.3/src/ntfc/debug/coredump/gdb_handler.py +149 -0
- ntfc-0.0.3/src/ntfc/debug/coredump/local_file_handler.py +102 -0
- ntfc-0.0.3/src/ntfc/debug/coredump/manager.py +129 -0
- ntfc-0.0.3/src/ntfc/debug/coredump/syslog_handler.py +210 -0
- ntfc-0.0.3/src/ntfc/debug/coredump/ymodem_handler.py +157 -0
- ntfc-0.0.3/src/ntfc/debug/gdb/controller.py +456 -0
- ntfc-0.0.3/src/ntfc/debug/gdb/plugin/autobp.py +509 -0
- ntfc-0.0.3/src/ntfc/debug/gdb/plugin/gdbprefix.py +55 -0
- ntfc-0.0.3/src/ntfc/debug/gdb/plugin/init.py +57 -0
- ntfc-0.0.3/src/ntfc/debug/getdebug.py +283 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/device/common.py +37 -2
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/device/getos.py +9 -1
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/device/host.py +50 -3
- ntfc-0.0.3/src/ntfc/device/linux.py +87 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/device/nuttx.py +7 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/device/qemu.py +1 -19
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/device/serial.py +13 -7
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/device/sim.py +1 -23
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/envconfig.py +13 -7
- ntfc-0.0.3/src/ntfc/lib/elf/app_bindir.py +137 -0
- ntfc-0.0.3/src/ntfc/lib/fastboot/controller.py +124 -0
- ntfc-0.0.3/src/ntfc/lib/ymodem/controller.py +107 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/multi.py +13 -6
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/productconfig.py +35 -1
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/pytest/configure.py +27 -3
- ntfc-0.0.3/src/ntfc/pytest/coredump_plugin.py +137 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/pytest/mypytest.py +45 -12
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/testfilter.py +2 -2
- {ntfc-0.0.2 → ntfc-0.0.3/src/ntfc.egg-info}/PKG-INFO +4 -2
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc.egg-info/SOURCES.txt +18 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc.egg-info/requires.txt +3 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_builder.py +283 -6
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_core.py +112 -2
- ntfc-0.0.3/tests/test_coreconfig.py +262 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_cores.py +51 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_envconfig.py +19 -2
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_filtertest.py +1 -1
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_multi.py +16 -4
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_productconfig.py +73 -0
- ntfc-0.0.2/tests/test_coreconfig.py +0 -114
- {ntfc-0.0.2 → ntfc-0.0.3}/LICENSE +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/setup.cfg +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/__init__.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/__main__.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/cli/clitypes.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/cli/environment.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/cli/main.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/command_builder.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/commands/cmd_build.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/commands/cmd_collect.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/commands/cmd_test.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/device/cmds.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/device/getdev.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/device/heartbeat.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/device/oscommon.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/device/state.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/ext_commands.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/lib/elf/elf_parser.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/lib/performance/perf_data_process.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/lib/performance/sqllite_lib.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/log/handler.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/log/logger.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/log/manager.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/log/report.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/log/templates/module_report.html +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/log.yaml +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/parallel.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/parsers/base.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/parsers/cmocka.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/parsers/custom.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/parsers/gtest.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/plugins_loader.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/product.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/products.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/pytest/collected.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/pytest/collecteditem.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/pytest/collector.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/pytest/formatters.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/pytest/gtest_plugin.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/pytest/parsers.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/pytest/runner.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/pytest/signal_plugin.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc/type_defs.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc.egg-info/dependency_links.txt +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc.egg-info/entry_points.txt +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/src/ntfc.egg-info/top_level.txt +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_command_builder.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_heartbeat.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_parallel.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_product.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_products.py +0 -0
- {ntfc-0.0.2 → ntfc-0.0.3}/tests/test_vtfc.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ntfc
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: NTFC for NuttX
|
|
5
5
|
Keywords: ntfc
|
|
6
6
|
Classifier: Topic :: Software Development :: Embedded Systems
|
|
@@ -24,6 +24,8 @@ Requires-Dist: requests
|
|
|
24
24
|
Requires-Dist: pillow
|
|
25
25
|
Requires-Dist: prettytable
|
|
26
26
|
Requires-Dist: pytz
|
|
27
|
+
Provides-Extra: coredump
|
|
28
|
+
Requires-Dist: lzf; extra == "coredump"
|
|
27
29
|
Dynamic: license-file
|
|
28
30
|
|
|
29
31
|
# NTFC
|
|
@@ -133,7 +135,7 @@ and [Documentation/usage](Documentation/usage.rst) for detailed usage informatio
|
|
|
133
135
|
|
|
134
136
|
Currently available test case repositories:
|
|
135
137
|
|
|
136
|
-
- https://github.com/
|
|
138
|
+
- https://github.com/apache/nuttx-ntfc-testing - NuttX RTOS
|
|
137
139
|
functionality tests
|
|
138
140
|
|
|
139
141
|
For guidance on writing your own test cases, see
|
|
@@ -105,7 +105,7 @@ and [Documentation/usage](Documentation/usage.rst) for detailed usage informatio
|
|
|
105
105
|
|
|
106
106
|
Currently available test case repositories:
|
|
107
107
|
|
|
108
|
-
- https://github.com/
|
|
108
|
+
- https://github.com/apache/nuttx-ntfc-testing - NuttX RTOS
|
|
109
109
|
functionality tests
|
|
110
110
|
|
|
111
111
|
For guidance on writing your own test cases, see
|
|
@@ -23,7 +23,7 @@ build-backend = 'setuptools.build_meta'
|
|
|
23
23
|
|
|
24
24
|
[project]
|
|
25
25
|
name = "ntfc"
|
|
26
|
-
version = "0.0.
|
|
26
|
+
version = "0.0.3"
|
|
27
27
|
description = "NTFC for NuttX"
|
|
28
28
|
readme = "README.md"
|
|
29
29
|
requires-python = ">=3.10"
|
|
@@ -53,6 +53,11 @@ keywords = [
|
|
|
53
53
|
"ntfc",
|
|
54
54
|
]
|
|
55
55
|
|
|
56
|
+
[project.optional-dependencies]
|
|
57
|
+
coredump = [
|
|
58
|
+
"lzf",
|
|
59
|
+
]
|
|
60
|
+
|
|
56
61
|
[project.scripts]
|
|
57
62
|
ntfc = "ntfc.cli.main:main"
|
|
58
63
|
|
|
@@ -24,6 +24,7 @@ import os
|
|
|
24
24
|
import re
|
|
25
25
|
import shutil
|
|
26
26
|
import subprocess
|
|
27
|
+
from functools import partial
|
|
27
28
|
from pathlib import Path
|
|
28
29
|
from typing import Any, Dict, List, Optional
|
|
29
30
|
|
|
@@ -39,6 +40,10 @@ class NuttXBuilder:
|
|
|
39
40
|
|
|
40
41
|
IMAGE_BIN_STR = "$IMAGE_BIN"
|
|
41
42
|
IMAGE_HEX_STR = "$IMAGE_HEX"
|
|
43
|
+
IMAGE_ELF_STR = "$IMAGE_ELF"
|
|
44
|
+
APPS_BINDIR_STR = "$APPS_BINDIR"
|
|
45
|
+
APPS_IMG_STR = "$APPS_IMG"
|
|
46
|
+
APPS_IMG_NAME = "apps.romfs.img"
|
|
42
47
|
_KCONFIG_DISABLED_RE = re.compile(
|
|
43
48
|
r"^#\s+(CONFIG_[A-Za-z0-9_]+)\s+is not set"
|
|
44
49
|
)
|
|
@@ -100,6 +105,12 @@ class NuttXBuilder:
|
|
|
100
105
|
{str(key): str(val) for key, val in custom_defines.items()}
|
|
101
106
|
)
|
|
102
107
|
|
|
108
|
+
apps_dir = self._cfg_values.get("config", {}).get("apps_dir")
|
|
109
|
+
if apps_dir:
|
|
110
|
+
defines["NUTTX_APPS_DIR"] = os.path.abspath(
|
|
111
|
+
os.path.expanduser(os.path.expandvars(str(apps_dir)))
|
|
112
|
+
)
|
|
113
|
+
|
|
103
114
|
return defines
|
|
104
115
|
|
|
105
116
|
def _get_kconfig_overrides(
|
|
@@ -341,13 +352,26 @@ class NuttXBuilder:
|
|
|
341
352
|
"--build",
|
|
342
353
|
str(build_path),
|
|
343
354
|
]
|
|
344
|
-
|
|
345
355
|
run_env = os.environ.copy()
|
|
346
356
|
if env:
|
|
347
357
|
run_env.update(env) # pragma: no cover
|
|
348
358
|
|
|
349
359
|
self._run_command(cmd, env=run_env)
|
|
350
360
|
|
|
361
|
+
def _run_build_target(
|
|
362
|
+
self,
|
|
363
|
+
build: str,
|
|
364
|
+
target: str,
|
|
365
|
+
env: Optional[Dict[str, str]] = None,
|
|
366
|
+
) -> None:
|
|
367
|
+
"""Run one named CMake build target."""
|
|
368
|
+
cmd = ["cmake", "--build", str(Path(build)), "--target", target]
|
|
369
|
+
run_env = os.environ.copy()
|
|
370
|
+
if env:
|
|
371
|
+
run_env.update(env)
|
|
372
|
+
|
|
373
|
+
self._run_command(cmd, env=run_env)
|
|
374
|
+
|
|
351
375
|
def _build_core(
|
|
352
376
|
self, core: str, cores: Dict[str, Any], product: str
|
|
353
377
|
) -> None:
|
|
@@ -371,13 +395,24 @@ class NuttXBuilder:
|
|
|
371
395
|
if not cfg_cwd: # pragma: no cover
|
|
372
396
|
raise BuilderConfigError("not found cwd in YAML configuration")
|
|
373
397
|
|
|
398
|
+
cfg_build_dir = os.path.expanduser(
|
|
399
|
+
os.path.expandvars(str(cfg_build_dir))
|
|
400
|
+
)
|
|
374
401
|
build_path = os.path.join(cfg_build_dir, build_dir)
|
|
375
402
|
build_cfg = cores[core]["defconfig"]
|
|
376
403
|
logger.info(
|
|
377
404
|
f"build image " f"conf: {build_cfg}, out: {build_path}"
|
|
378
405
|
)
|
|
379
406
|
|
|
380
|
-
|
|
407
|
+
cfg_cwd = os.path.expanduser(os.path.expandvars(str(cfg_cwd)))
|
|
408
|
+
configured_nuttx_dir = self._cfg_values["config"].get("nuttx_dir")
|
|
409
|
+
nuttx_dir = (
|
|
410
|
+
os.path.expanduser(
|
|
411
|
+
os.path.expandvars(str(configured_nuttx_dir))
|
|
412
|
+
)
|
|
413
|
+
if configured_nuttx_dir
|
|
414
|
+
else os.path.join(cfg_cwd, "nuttx")
|
|
415
|
+
)
|
|
381
416
|
nuttx_elf_path = os.path.join(build_path, "nuttx")
|
|
382
417
|
nuttx_conf_path = os.path.join(build_path, ".config")
|
|
383
418
|
|
|
@@ -396,8 +431,8 @@ class NuttXBuilder:
|
|
|
396
431
|
if not already_build or self._rebuild: # pragma: no cover
|
|
397
432
|
self._log_kconfig_overrides(kv_overrides)
|
|
398
433
|
|
|
399
|
-
|
|
400
|
-
|
|
434
|
+
configure = partial(
|
|
435
|
+
self._run_cmake,
|
|
401
436
|
source=nuttx_dir,
|
|
402
437
|
build=build_path,
|
|
403
438
|
generator="Ninja",
|
|
@@ -405,11 +440,28 @@ class NuttXBuilder:
|
|
|
405
440
|
env=build_env,
|
|
406
441
|
)
|
|
407
442
|
|
|
443
|
+
# configure build
|
|
444
|
+
configure()
|
|
445
|
+
|
|
408
446
|
# apply Kconfig overrides to generated .config before build
|
|
409
447
|
self._apply_kconfig_overrides(
|
|
410
448
|
nuttx_conf_path, kv_overrides, cfg_cwd
|
|
411
449
|
)
|
|
412
450
|
|
|
451
|
+
if kv_overrides:
|
|
452
|
+
# fill in defaults of suboptions the overrides
|
|
453
|
+
# unlocked (e.g. *_PROGNAME): applications are
|
|
454
|
+
# silently dropped at configure when these are
|
|
455
|
+
# missing from .config
|
|
456
|
+
self._run_build_target(
|
|
457
|
+
build_path, "olddefconfig", env=build_env
|
|
458
|
+
)
|
|
459
|
+
|
|
460
|
+
# application targets are registered at configure
|
|
461
|
+
# time from .config: configure again so overrides
|
|
462
|
+
# that enable new applications take effect
|
|
463
|
+
configure()
|
|
464
|
+
|
|
413
465
|
# build
|
|
414
466
|
self._run_build(build_path, env=build_env)
|
|
415
467
|
|
|
@@ -417,6 +469,79 @@ class NuttXBuilder:
|
|
|
417
469
|
cores[core]["elf_path"] = nuttx_elf_path
|
|
418
470
|
cores[core]["conf_path"] = nuttx_conf_path
|
|
419
471
|
|
|
472
|
+
if self._is_kernel_config(nuttx_conf_path):
|
|
473
|
+
# kernel-mode: applications are installed to <build>/bin
|
|
474
|
+
# and hostfs mounts resolve relative to the process cwd
|
|
475
|
+
cores[core].setdefault(
|
|
476
|
+
"app_bindir", os.path.join(build_path, "bin")
|
|
477
|
+
)
|
|
478
|
+
cores[core].setdefault("exec_cwd", build_path)
|
|
479
|
+
|
|
480
|
+
self._make_apps_image(cores[core], build_path)
|
|
481
|
+
|
|
482
|
+
def _make_apps_image(
|
|
483
|
+
self, core_cfg: Dict[str, Any], build_path: str
|
|
484
|
+
) -> None:
|
|
485
|
+
"""Generate a filesystem image with application binaries.
|
|
486
|
+
|
|
487
|
+
Enabled with the per-core ``apps_image`` option; the image path
|
|
488
|
+
is registered as ``apps_img`` for the ``$APPS_IMG`` flash
|
|
489
|
+
placeholder.
|
|
490
|
+
"""
|
|
491
|
+
img_cfg = core_cfg.get("apps_image", None)
|
|
492
|
+
if not img_cfg:
|
|
493
|
+
return
|
|
494
|
+
|
|
495
|
+
if not isinstance(img_cfg, dict):
|
|
496
|
+
raise BuilderConfigError("apps_image must be a mapping")
|
|
497
|
+
|
|
498
|
+
img_type = img_cfg.get("type", "romfs")
|
|
499
|
+
if img_type != "romfs":
|
|
500
|
+
raise BuilderConfigError(
|
|
501
|
+
f"unsupported apps_image type: {img_type}"
|
|
502
|
+
)
|
|
503
|
+
|
|
504
|
+
bindir = core_cfg.get("app_bindir", None)
|
|
505
|
+
if not bindir:
|
|
506
|
+
raise BuilderConfigError(
|
|
507
|
+
"apps_image requires app_bindir (kernel-mode build)"
|
|
508
|
+
)
|
|
509
|
+
|
|
510
|
+
tool = shutil.which("genromfs")
|
|
511
|
+
if not tool:
|
|
512
|
+
raise BuilderConfigError("genromfs not found in PATH")
|
|
513
|
+
|
|
514
|
+
img_path = os.path.join(build_path, self.APPS_IMG_NAME)
|
|
515
|
+
self._run_command([tool, "-f", img_path, "-d", bindir], env=None)
|
|
516
|
+
core_cfg["apps_img"] = img_path
|
|
517
|
+
|
|
518
|
+
def _expand_flash_cmd(
|
|
519
|
+
self, flash_cmd: str, core_cfg: Dict[str, Any]
|
|
520
|
+
) -> str:
|
|
521
|
+
"""Expand image placeholders in a flash command."""
|
|
522
|
+
parent = Path(core_cfg["elf_path"]).parent
|
|
523
|
+
values = {
|
|
524
|
+
self.IMAGE_BIN_STR: str(parent / "nuttx.bin"),
|
|
525
|
+
self.IMAGE_HEX_STR: str(parent / "nuttx.hex"),
|
|
526
|
+
self.IMAGE_ELF_STR: core_cfg["elf_path"],
|
|
527
|
+
self.APPS_BINDIR_STR: core_cfg.get("app_bindir", ""),
|
|
528
|
+
self.APPS_IMG_STR: core_cfg.get("apps_img", ""),
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
for placeholder, value in values.items():
|
|
532
|
+
flash_cmd = flash_cmd.replace(placeholder, value)
|
|
533
|
+
|
|
534
|
+
return flash_cmd
|
|
535
|
+
|
|
536
|
+
@staticmethod
|
|
537
|
+
def _is_kernel_config(conf_path: str) -> bool:
|
|
538
|
+
"""Check if a generated .config selects a kernel build."""
|
|
539
|
+
if not os.path.isfile(conf_path):
|
|
540
|
+
return False
|
|
541
|
+
|
|
542
|
+
with open(conf_path, "r", encoding="utf-8") as f:
|
|
543
|
+
return any(line.strip() == "CONFIG_BUILD_KERNEL=y" for line in f)
|
|
544
|
+
|
|
420
545
|
def _reboot_core(
|
|
421
546
|
self, core: str, cores: Dict[str, Any]
|
|
422
547
|
) -> None: # pragma: no cover
|
|
@@ -433,12 +558,7 @@ class NuttXBuilder:
|
|
|
433
558
|
"""Flash single core image."""
|
|
434
559
|
flash_cmd = cores[core].get("flash", None)
|
|
435
560
|
if flash_cmd:
|
|
436
|
-
|
|
437
|
-
image_hex = str(img_path.parent) + "/nuttx.hex"
|
|
438
|
-
image_bin = str(img_path.parent) + "/nuttx.bin"
|
|
439
|
-
|
|
440
|
-
flash_cmd = flash_cmd.replace(self.IMAGE_BIN_STR, image_bin)
|
|
441
|
-
flash_cmd = flash_cmd.replace(self.IMAGE_HEX_STR, image_hex)
|
|
561
|
+
flash_cmd = self._expand_flash_cmd(flash_cmd, cores[core])
|
|
442
562
|
|
|
443
563
|
cmd = flash_cmd.split()
|
|
444
564
|
|
|
@@ -35,6 +35,7 @@ from typing import (
|
|
|
35
35
|
from ntfc.command_builder import CommandBuilder
|
|
36
36
|
from ntfc.coreconfig import CoreConfig
|
|
37
37
|
from ntfc.device.common import CmdReturn, CmdStatus
|
|
38
|
+
from ntfc.lib.elf.app_bindir import match_command, symbol_patterns
|
|
38
39
|
from ntfc.log.logger import logger
|
|
39
40
|
|
|
40
41
|
if TYPE_CHECKING:
|
|
@@ -72,6 +73,8 @@ class CoreStatus(_Enum):
|
|
|
72
73
|
class ProductCore:
|
|
73
74
|
"""This class implements product core under test."""
|
|
74
75
|
|
|
76
|
+
_PATH_NAME_RE = re.compile(r"[A-Za-z0-9_.+-]+")
|
|
77
|
+
|
|
75
78
|
def __init__(
|
|
76
79
|
self,
|
|
77
80
|
device: "DeviceCommon",
|
|
@@ -99,6 +102,7 @@ class ProductCore:
|
|
|
99
102
|
list(ignored_cores) if ignored_cores is not None else ["dsp"]
|
|
100
103
|
)
|
|
101
104
|
self._builder = CommandBuilder(device.prompt, device.no_cmd)
|
|
105
|
+
self._runtime_cmds: Optional[List[str]] = None
|
|
102
106
|
|
|
103
107
|
self._prompt = device.prompt
|
|
104
108
|
self._main_prompt = self._prompt
|
|
@@ -334,7 +338,7 @@ class ProductCore:
|
|
|
334
338
|
|
|
335
339
|
def init(self) -> None:
|
|
336
340
|
"""Finish product initialization."""
|
|
337
|
-
cores = self.get_core_info()
|
|
341
|
+
cores = self.get_core_info() if self._conf.os == "nuttx" else ()
|
|
338
342
|
self._core0 = cores[0] if cores else "core0"
|
|
339
343
|
self._cur_core = self._core0
|
|
340
344
|
self._cores = cores if cores else ("core0",)
|
|
@@ -527,67 +531,82 @@ class ProductCore:
|
|
|
527
531
|
"""Start device."""
|
|
528
532
|
self._device.start()
|
|
529
533
|
|
|
534
|
+
def _check_cmd_runtime(self, cmd_pattern: str) -> bool:
|
|
535
|
+
"""Check a command against the target PATH listing.
|
|
536
|
+
|
|
537
|
+
The listing is fetched once from the running target and cached;
|
|
538
|
+
a failed listing is not cached so it is retried on next use.
|
|
539
|
+
"""
|
|
540
|
+
if self._runtime_cmds is None:
|
|
541
|
+
result = self.sendCommandReadUntilPattern(
|
|
542
|
+
f"ls {self._conf.path_initial}", timeout=5
|
|
543
|
+
)
|
|
544
|
+
if result.status != CmdStatus.SUCCESS:
|
|
545
|
+
return False
|
|
546
|
+
|
|
547
|
+
output_lower = result.output.lower()
|
|
548
|
+
no_cmd = str(self._device.no_cmd).lower()
|
|
549
|
+
if no_cmd in output_lower or any(
|
|
550
|
+
line.lstrip().lower().startswith("ls:")
|
|
551
|
+
for line in result.output.splitlines()
|
|
552
|
+
):
|
|
553
|
+
return False
|
|
554
|
+
|
|
555
|
+
# drop the command echo line; path headers and the prompt
|
|
556
|
+
# do not match the name pattern
|
|
557
|
+
tokens = " ".join(result.output.splitlines()[1:]).split()
|
|
558
|
+
self._runtime_cmds = [
|
|
559
|
+
token
|
|
560
|
+
for token in tokens
|
|
561
|
+
if self._PATH_NAME_RE.fullmatch(token)
|
|
562
|
+
]
|
|
563
|
+
|
|
564
|
+
return match_command(cmd_pattern, self._runtime_cmds)
|
|
565
|
+
|
|
530
566
|
def check_cmd(self, cmd_pattern: str) -> bool:
|
|
531
|
-
"""Check if a command pattern is available
|
|
567
|
+
"""Check if a command pattern is available on the core.
|
|
532
568
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
alternative command patterns separated by '|'.
|
|
569
|
+
Commands are resolved from the application binaries, the running
|
|
570
|
+
target, the device ELF parser or the shell help output, in that
|
|
571
|
+
order.
|
|
537
572
|
|
|
538
|
-
:param cmd_pattern: Command pattern
|
|
539
|
-
|
|
540
|
-
(e.g., 'test1|test2')
|
|
573
|
+
:param cmd_pattern: Command pattern, may contain alternatives
|
|
574
|
+
separated by '|' (e.g. 'test1|test2')
|
|
541
575
|
:return: True if the command pattern is found, False otherwise
|
|
542
|
-
|
|
543
|
-
Note:
|
|
544
|
-
- Requires ELF parser to be available in device
|
|
545
|
-
- Supports alternative patterns with '|'
|
|
546
|
-
- Used to validate core capabilities before executing
|
|
547
576
|
"""
|
|
548
|
-
#
|
|
577
|
+
# Kernel-mode: resolve against the application binary directory
|
|
578
|
+
# so runtime checks agree with collection-time filtering
|
|
579
|
+
if self._conf.has_app_bindir:
|
|
580
|
+
return self._conf.cmd_check(cmd_pattern)
|
|
581
|
+
|
|
582
|
+
if self._conf.is_kernel_build:
|
|
583
|
+
# prebuilt image without host binaries: discover the
|
|
584
|
+
# command set once from the running target
|
|
585
|
+
return self._check_cmd_runtime(cmd_pattern)
|
|
586
|
+
|
|
587
|
+
# Devices that expose their own ELF parser resolve the command
|
|
588
|
+
# from its symbols
|
|
549
589
|
if hasattr(self._device, "elf_parser") and self._device.elf_parser:
|
|
550
590
|
logger.debug(f"Checking command pattern: {cmd_pattern}")
|
|
551
591
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
cmd_pattern.split("|") if "|" in cmd_pattern else [cmd_pattern]
|
|
555
|
-
)
|
|
556
|
-
|
|
557
|
-
for pattern in alternatives:
|
|
558
|
-
# For cmocka tests, append _main to symbol name
|
|
559
|
-
symbol_pattern_str: str = (
|
|
560
|
-
f"{pattern}_main" if "cmocka" in pattern else pattern
|
|
561
|
-
)
|
|
562
|
-
|
|
563
|
-
# Support regex wildcards
|
|
564
|
-
if ".*" in symbol_pattern_str:
|
|
565
|
-
symbol_pattern = re.compile(symbol_pattern_str)
|
|
566
|
-
else:
|
|
567
|
-
tmp = symbol_pattern_str
|
|
568
|
-
symbol_pattern = tmp # type: ignore[assignment]
|
|
569
|
-
|
|
570
|
-
if self._device.elf_parser.has_symbol(symbol_pattern):
|
|
592
|
+
for symbol in symbol_patterns(cmd_pattern):
|
|
593
|
+
if self._device.elf_parser.has_symbol(symbol):
|
|
571
594
|
return True
|
|
572
595
|
|
|
573
596
|
return False
|
|
574
597
|
|
|
575
|
-
# Fallback:
|
|
598
|
+
# Fallback: check the command against the shell help output
|
|
576
599
|
logger.warning(
|
|
577
600
|
"ELF parser not available, trying command check for: "
|
|
578
601
|
f"{cmd_pattern}"
|
|
579
602
|
)
|
|
580
603
|
|
|
581
|
-
# Send 'help' command to check if command exists
|
|
582
604
|
result = self.sendCommandReadUntilPattern("help", timeout=5)
|
|
583
605
|
|
|
584
606
|
if result.status == CmdStatus.SUCCESS:
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
cmd_pattern.split("|")
|
|
607
|
+
return any(
|
|
608
|
+
pattern.lower() in result.output.lower()
|
|
609
|
+
for pattern in cmd_pattern.split("|")
|
|
588
610
|
)
|
|
589
|
-
for pattern in alternatives:
|
|
590
|
-
if pattern.lower() in result.output.lower():
|
|
591
|
-
return True
|
|
592
611
|
|
|
593
612
|
return False
|
|
@@ -20,8 +20,11 @@
|
|
|
20
20
|
|
|
21
21
|
"""Product core configuration handler."""
|
|
22
22
|
|
|
23
|
+
import os
|
|
24
|
+
from functools import cached_property
|
|
23
25
|
from typing import Any, Dict, Optional, Union
|
|
24
26
|
|
|
27
|
+
from ntfc.lib.elf.app_bindir import AppBinDir, symbol_patterns
|
|
25
28
|
from ntfc.lib.elf.elf_parser import ElfParser
|
|
26
29
|
|
|
27
30
|
|
|
@@ -41,10 +44,29 @@ class CoreConfig:
|
|
|
41
44
|
self._load_core_config()
|
|
42
45
|
|
|
43
46
|
elf_path = self._config.get("elf_path", None)
|
|
44
|
-
if elf_path:
|
|
47
|
+
if elf_path and self.os == "nuttx":
|
|
45
48
|
# load ELF
|
|
46
49
|
self._elf = ElfParser(elf_path)
|
|
47
50
|
|
|
51
|
+
@staticmethod
|
|
52
|
+
def _parse_config_value(val: str) -> Union[bool, str, int]:
|
|
53
|
+
"""Parse a single Kconfig option value."""
|
|
54
|
+
if val == "y":
|
|
55
|
+
return True
|
|
56
|
+
if val == "n":
|
|
57
|
+
return False
|
|
58
|
+
if val.startswith('"') and val.endswith('"'):
|
|
59
|
+
# quoted strings first: they may contain hex digits
|
|
60
|
+
return val[1:-1]
|
|
61
|
+
if val.startswith("0x"):
|
|
62
|
+
try:
|
|
63
|
+
return int(val, 16)
|
|
64
|
+
except ValueError:
|
|
65
|
+
return val
|
|
66
|
+
if val.isdigit():
|
|
67
|
+
return int(val)
|
|
68
|
+
return val
|
|
69
|
+
|
|
48
70
|
def _load_core_config(self) -> None:
|
|
49
71
|
"""Load core configuration."""
|
|
50
72
|
with open(self._config["conf_path"], "r", encoding="utf-8") as f:
|
|
@@ -59,33 +81,31 @@ class CoreConfig:
|
|
|
59
81
|
# no '=' found — skip malformed line
|
|
60
82
|
continue
|
|
61
83
|
|
|
62
|
-
|
|
63
|
-
val_parsed: Union[bool, str, int]
|
|
64
|
-
if val == "y":
|
|
65
|
-
val_parsed = True
|
|
66
|
-
elif val == "n":
|
|
67
|
-
val_parsed = False
|
|
68
|
-
elif "0x" in val:
|
|
69
|
-
val_parsed = int(val.rstrip(), 16)
|
|
70
|
-
elif val.isdigit():
|
|
71
|
-
val_parsed = int(val)
|
|
72
|
-
elif val.startswith('"') and val.endswith('"'):
|
|
73
|
-
val_parsed = val[1:-1]
|
|
74
|
-
else:
|
|
75
|
-
val_parsed = val
|
|
76
|
-
|
|
77
|
-
self._kv_values[name] = val_parsed
|
|
84
|
+
self._kv_values[name] = self._parse_config_value(val)
|
|
78
85
|
|
|
79
86
|
@property
|
|
80
87
|
def uptime(self) -> Any:
|
|
81
88
|
"""Return core uptime."""
|
|
82
89
|
return self._config.get("uptime", 3)
|
|
83
90
|
|
|
91
|
+
@property
|
|
92
|
+
def read_poll_interval(self) -> float:
|
|
93
|
+
"""Return console polling interval in seconds."""
|
|
94
|
+
value = float(self._config.get("read_poll_interval", 0.1))
|
|
95
|
+
if value <= 0:
|
|
96
|
+
raise ValueError("read_poll_interval must be positive")
|
|
97
|
+
return value
|
|
98
|
+
|
|
84
99
|
@property
|
|
85
100
|
def device(self) -> Any:
|
|
86
101
|
"""Return core device."""
|
|
87
102
|
return self._config.get("device", None)
|
|
88
103
|
|
|
104
|
+
@property
|
|
105
|
+
def os(self) -> str:
|
|
106
|
+
"""Return target operating system name."""
|
|
107
|
+
return str(self._config.get("os", "nuttx")).lower()
|
|
108
|
+
|
|
89
109
|
@property
|
|
90
110
|
def name(self) -> Any:
|
|
91
111
|
"""Return core name."""
|
|
@@ -134,6 +154,52 @@ class CoreConfig:
|
|
|
134
154
|
"""Return core poweroff command."""
|
|
135
155
|
return self._config.get("poweroff", "")
|
|
136
156
|
|
|
157
|
+
@property
|
|
158
|
+
def flash_only(self) -> bool:
|
|
159
|
+
"""Return whether this core is build/flash-only.
|
|
160
|
+
|
|
161
|
+
Flash-only cores are still built/flashed by NTFC, but are skipped for
|
|
162
|
+
runtime test orchestration: no boot checks, no log collection, no test
|
|
163
|
+
requirements validation, and no command execution against them.
|
|
164
|
+
"""
|
|
165
|
+
return bool(self._config.get("flash_only", False))
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
def is_kernel_build(self) -> bool:
|
|
169
|
+
"""Return True when the core .config has CONFIG_BUILD_KERNEL=y."""
|
|
170
|
+
return self.kv_check("CONFIG_BUILD_KERNEL") is True
|
|
171
|
+
|
|
172
|
+
@property
|
|
173
|
+
def exec_cwd(self) -> Optional[str]:
|
|
174
|
+
"""Return working directory for spawned sim/qemu processes.
|
|
175
|
+
|
|
176
|
+
Kernel-mode hostfs mounts resolve relative to this directory.
|
|
177
|
+
"""
|
|
178
|
+
return self._config.get("exec_cwd", None)
|
|
179
|
+
|
|
180
|
+
@property
|
|
181
|
+
def boot_timeout(self) -> int:
|
|
182
|
+
"""Return seconds to wait for the first shell prompt after start."""
|
|
183
|
+
return int(self._config.get("boot_timeout", 5))
|
|
184
|
+
|
|
185
|
+
@property
|
|
186
|
+
def app_bindir(self) -> Optional[str]:
|
|
187
|
+
"""Return directory with kernel-mode application binaries.
|
|
188
|
+
|
|
189
|
+
Defaults to the bin/ directory next to the NuttX ELF.
|
|
190
|
+
"""
|
|
191
|
+
bindir = self._config.get("app_bindir", None)
|
|
192
|
+
if bindir:
|
|
193
|
+
return str(bindir)
|
|
194
|
+
if self.is_kernel_build and self.elf_path:
|
|
195
|
+
return os.path.join(os.path.dirname(self.elf_path), "bin")
|
|
196
|
+
return None
|
|
197
|
+
|
|
198
|
+
@property
|
|
199
|
+
def line_buffered(self) -> bool:
|
|
200
|
+
"""Return whether commands are sent in one transport write."""
|
|
201
|
+
return bool(self._config.get("line_buffered", False))
|
|
202
|
+
|
|
137
203
|
def kv_check(self, cfg: str) -> Any:
|
|
138
204
|
"""Check Kconfig option and return its value.
|
|
139
205
|
|
|
@@ -147,10 +213,41 @@ class CoreConfig:
|
|
|
147
213
|
|
|
148
214
|
return self._kv_values.get(cfg, False)
|
|
149
215
|
|
|
216
|
+
@cached_property
|
|
217
|
+
def _appbin(self) -> Optional[AppBinDir]:
|
|
218
|
+
"""Return the installed kernel-mode application binaries."""
|
|
219
|
+
bindir = self.app_bindir
|
|
220
|
+
if not bindir or not os.path.isdir(bindir):
|
|
221
|
+
return None
|
|
222
|
+
|
|
223
|
+
return AppBinDir(bindir)
|
|
224
|
+
|
|
225
|
+
@property
|
|
226
|
+
def has_app_bindir(self) -> bool:
|
|
227
|
+
"""Return True when kernel-mode application binaries are found."""
|
|
228
|
+
return self._appbin is not None
|
|
229
|
+
|
|
230
|
+
@property
|
|
231
|
+
def path_initial(self) -> str:
|
|
232
|
+
"""Return the initial target PATH, see CONFIG_PATH_INITIAL."""
|
|
233
|
+
return str(self.kv_check("CONFIG_PATH_INITIAL") or "/system/bin")
|
|
234
|
+
|
|
150
235
|
def cmd_check(self, cmd: str, core: int = 0) -> bool:
|
|
151
|
-
"""Check if command is available in binary.
|
|
236
|
+
"""Check if command is available in binary.
|
|
237
|
+
|
|
238
|
+
Kernel-mode cores resolve commands against the application binary
|
|
239
|
+
directory; otherwise the symbol must exist in the core ELF.
|
|
240
|
+
"""
|
|
241
|
+
if self._appbin:
|
|
242
|
+
if self._appbin.has_command(cmd):
|
|
243
|
+
return True
|
|
244
|
+
# not an application: NSH builtins and test entry points
|
|
245
|
+
# are symbols inside the application binaries
|
|
246
|
+
return self._appbin.has_symbol(cmd)
|
|
247
|
+
|
|
152
248
|
if not self._elf:
|
|
153
249
|
raise AttributeError("no elf data")
|
|
154
250
|
|
|
155
|
-
|
|
156
|
-
|
|
251
|
+
return any(
|
|
252
|
+
self._elf.has_symbol(symbol) for symbol in symbol_patterns(cmd)
|
|
253
|
+
)
|
|
@@ -63,24 +63,27 @@ class CoresHandler:
|
|
|
63
63
|
self._conf = conf
|
|
64
64
|
self._cores: List[ProductCore] = []
|
|
65
65
|
|
|
66
|
-
# For SMP mode, only create one device instance from
|
|
67
|
-
# For AMP mode, create separate device instances for
|
|
66
|
+
# For SMP mode, only create one device instance from the first active
|
|
67
|
+
# core. For AMP mode, create separate device instances for active
|
|
68
|
+
# cores.
|
|
68
69
|
ignored = conf.ignored_cores
|
|
70
|
+
active_cores = conf.active_core_indices
|
|
69
71
|
if conf.is_smp:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
if not active_cores:
|
|
73
|
+
return
|
|
74
|
+
|
|
75
|
+
first_core = active_cores[0]
|
|
76
|
+
dev = get_device(conf.cfg_core(first_core))
|
|
77
|
+
self._cores.append(
|
|
78
|
+
ProductCore(dev, conf.cfg_core(first_core), ignored)
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
for core in active_cores[1:]:
|
|
78
82
|
self._cores.append(
|
|
79
83
|
ProductCore(dev, conf.cfg_core(core), ignored)
|
|
80
84
|
)
|
|
81
85
|
else:
|
|
82
|
-
|
|
83
|
-
for core in range(conf.cores_num):
|
|
86
|
+
for core in active_cores:
|
|
84
87
|
dev = get_device(conf.cfg_core(core))
|
|
85
88
|
self._cores.append(
|
|
86
89
|
ProductCore(dev, conf.cfg_core(core), ignored)
|