[toranj] allow verbose mode (on all nodes) to be enabled using env variable (#5078)

This commit adds additional mechanism in `toranj` to enable verbose
mode on all nodes by setting the env variable `TORANJ_VERBOSE` (this is
in addition to existing mechanism where verbose mode can be enabled
per node from a test script). When `TORANJ_VERBOSE` env is used to
enable verbose mode, it also enables OT logging on all nodes (OT logs
are collected in the `wpantund-logs<node_index>.log` files along with
`wpantund` logs). This commit also updates the `toranj/README.md` to
describe the new mechanism.
This commit is contained in:
Abtin Keshavarzian
2020-06-10 06:33:56 -07:00
committed by GitHub
parent 4d1197a34a
commit 4f85283fb3
2 changed files with 5 additions and 4 deletions
+2 -2
View File
@@ -306,13 +306,13 @@ Every `wpan.Node()` instance will save its corresponding `wpantund` logs. By def
When `start.sh` script is used to run all test-cases, if any test fails, to help with debugging of the issue, the last 30 lines of `wpantund` logs of every node involved in the test-case is dumped to `stdout`.
A `wpan.Node()` instance can also provide additional logs and info as the test-cases are run (verbose mode). By default this is disabled. It can be enabled for a node instance when it is created:
A `wpan.Node()` instance can also provide additional logs and info as the test-cases are run (verbose mode). It can be enabled for a node instance when it is created:
```python
node = wpan.Node(verbose=True) # `node` instance will provide extra logs.
```
Alternatively, `wpan.Node._VERBOSE` settings can be changed to enable verbose logging for all nodes.
Alternatively, `wpan.Node._VERBOSE` settings can be changed to enable verbose logging for all nodes. The default value of `wpan.Node._VERBOSE` is determined from environment variable `TORANJ_VERBOSE` (verbose mode is enabled when env variable is set to any of `1`, `True`, `Yes`, `Y`, `On` (case-insensitive)), otherwise it is disabled. When `TORANJ_VERBOSE` is enabled, the OpenThread logging is also enabled (and collected in `wpantund-log<node_index>.log`files) on all nodes.
Here is example of small test script and its corresponding log output with `verbose` mode enabled:
+3 -2
View File
@@ -281,7 +281,8 @@ class Node(object):
""" A wpantund OT NCP instance """
# defines the default verbosity setting (can be changed per `Node`)
_VERBOSE = False
_VERBOSE = os.getenv('TORANJ_VERBOSE',
'no').lower() in ['true', '1', 't', 'y', 'yes', 'on']
_SPEED_UP_FACTOR = 1 # defines the default time speed up factor
# path to `wpantund`, `wpanctl`, `ot-ncp-ftd`,`ot-ncp` and `ot-rcp`
@@ -687,7 +688,7 @@ class Node(object):
# class methods
@classmethod
def init_all_nodes(cls, disable_logs=True, wait_time=15):
def init_all_nodes(cls, disable_logs=not _VERBOSE, wait_time=15):
"""Issues a `wpanctl.leave` on all `Node` objects and waits for them to be ready"""
random.seed(123456)
time.sleep(0.5)