Skip to content

Commit

Permalink
squash! riotnode: add node implementation and tests
Browse files Browse the repository at this point in the history
Add test for the local echo issue.
  • Loading branch information
cladmi committed Feb 5, 2019
1 parent 68bee37 commit f386f39
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions dist/pythonlibs/riotnode/riotnode/tests/node_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ def test_running_error_cases(app_pidfile_env):
# Exiting the context manager should not crash when node is killed


def test_expect_not_matching_stdin(app_pidfile_env):
"""Test that expect does not match stdin."""
env = {'BOARD': 'board', 'APPLICATION': './hello.py'}
env.update(app_pidfile_env)

node = riotnode.node.RIOTNode(APPLICATIONS_DIR, env)
node.TERM_STARTED_DELAY = 1

with node.run_term(logfile=sys.stdout) as child:
child.expect_exact('Starting RIOT node')
child.expect_exact('Hello World')

# Exception is 'exc_info.value' and pattern is in 'exc.value'
msg = "This should not be matched as it is on stdin"
child.sendline(msg)
matched = child.expect_exact([pexpect.TIMEOUT, msg], timeout=1)
assert matched == 0


def test_expect_value(app_pidfile_env):
"""Test that expect value is being changed to the pattern."""
env = {'BOARD': 'board', 'APPLICATION': './echo.py'}
Expand Down
17 changes: 17 additions & 0 deletions dist/pythonlibs/riotnode/riotnode/tests/utils/application/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#! /usr/bin/env python3
"""Firmware implementing a simpleechoing line inputs."""

import sys
import signal


def main():
"""Print some header and echo the output."""
print('Starting RIOT node')
print('Hello World')
while True:
signal.pause()


if __name__ == '__main__':
sys.exit(main())

0 comments on commit f386f39

Please sign in to comment.