Skip to content

Commit

Permalink
tests/gnrc_rpl_srh: run unittests through shell
Browse files Browse the repository at this point in the history
Using the shell to run unittests allows not needing
to wait for a string at the start of the test which
makes the test independent having the application reset
after the terminal is open.
  • Loading branch information
fjmolinas committed Dec 12, 2019
1 parent 5bf1a22 commit eb9d27d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions tests/gnrc_rpl_srh/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ static int _ipreg(int argc, char **argv)
return 0;
}

static const shell_command_t shell_commands[] = {
{ "ip", "Registers pktdump to protocol number 59 (no next header)", _ipreg },
{ NULL, NULL, NULL }
};

static void run_unittests(void)
{
EMB_UNIT_TESTFIXTURES(fixtures) {
Expand All @@ -255,9 +250,23 @@ static void run_unittests(void)
TESTS_END();
}

int main(void)
static int _unittests(int argc, char** argv)
{
(void) argc;
(void) argv;

run_unittests();
return 0;
}

static const shell_command_t shell_commands[] = {
{ "ip", "Registers pktdump to protocol number 59 (no next header)", _ipreg },
{ "unittests", "Runs unitest", _unittests},
{ NULL, NULL, NULL }
};

int main(void)
{
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
return 0;
}
2 changes: 1 addition & 1 deletion tests/gnrc_rpl_srh/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def test_time_exc(child, iface, hw_dst, ll_dst, ll_src):
def testfunc(child):
global sniffer
tap = get_bridge(os.environ["TAP"])

child.sendline("unittests")
child.expect(r"OK \((\d+) tests\)") # wait for and check result of unittests
print("." * int(child.match.group(1)), end="", flush=True)
lladdr_src = get_host_lladdr(tap)
Expand Down

0 comments on commit eb9d27d

Please sign in to comment.