1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

riotctrl_ctrl: provide helper class for native reset

This commit is contained in:
Martine Lenders 2021-02-10 10:53:52 +01:00
parent 609c9ada34
commit 49ea453df9
No known key found for this signature in database
GPG Key ID: CCD317364F63286F
3 changed files with 32 additions and 0 deletions

View File

30
dist/pythonlibs/riotctrl_ctrl/native.py vendored Normal file
View File

@ -0,0 +1,30 @@
# Copyright (C) 2021 Freie Universität Berlin
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
import riotctrl.ctrl
import psutil
class NativeRIOTCtrl(riotctrl.ctrl.RIOTCtrl):
"""RIOTCtrl abstraction for a native node
This works exactly as a normal RIOTCtrl, with the exception that
`DEBUG_ADAPTER_ID` is set in the environment to the PID of the `native`
process, whenever a terminal is started. This allows for `reset()` to also
work for a the `native` instance.
"""
def _set_debug_adapter_id(self, child):
if child.name().endswith('.elf'):
self.env['DEBUG_ADAPTER_ID'] = str(child.pid)
return True
return False
def start_term(self, *args, **kwargs):
super().start_term(*args, **kwargs)
for child in psutil.Process(pid=self._term_pid()).children():
if self._set_debug_adapter_id(child):
break

View File

@ -0,0 +1,2 @@
psutil
riotctrl