Merge pull request #12867 from fjmolinas/pr_tests_no_reset_dep

tests: adapt tests so they can use `tests_utils_interactive_sync`
This commit is contained in:
Martine Lenders 2019-12-12 15:47:21 +01:00 committed by GitHub
commit 26a1348a9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 49 additions and 32 deletions

View File

@ -31,8 +31,6 @@ USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
DISABLE_MODULE += test_utils_interactive_sync
# The test requires some setup and to be run as root
# So it cannot currently be run
TEST_ON_CI_BLACKLIST += all

View File

@ -41,8 +41,6 @@ USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
DISABLE_MODULE += test_utils_interactive_sync
# The test requires some setup and to be run as root
# So it cannot currently be run
TEST_ON_CI_BLACKLIST += all

View File

@ -84,11 +84,6 @@ static gnrc_netif_t *eth_netif, *mock_netif;
static ipv6_addr_t *local_addr;
static char mock_netif_stack[THREAD_STACKSIZE_DEFAULT];
static char line_buf[SHELL_DEFAULT_BUFSIZE];
static const shell_command_t shell_commands[] = {
{ "udp", "send data over UDP and listen on UDP ports", udp_cmd },
{ "test", "sends data according to a specified numeric test", shell_test_cmd },
{ NULL, NULL, NULL }
};
static const ipv6_addr_t _src = { .u8 = TEST_SRC };
static const ipv6_addr_t _dst = { .u8 = TEST_DST };
@ -617,6 +612,29 @@ static int shell_test_cmd(int argc, char **argv)
return 0;
}
static int send_test_pkt(int argc, char **argv)
{
(void) argc;
(void) argv;
printf("Sending UDP test packets to port %u\n", TEST_PORT);
for (unsigned i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (ipv6_addr_is_link_local(&eth_netif->ipv6.addrs[i])) {
local_addr = &eth_netif->ipv6.addrs[i];
}
}
return 0;
}
static int unittests(int argc, char** argv)
{
(void) argc;
(void) argv;
run_unittests();
return 0;
}
/* TODO: test if forwarded packet is not fragmented */
static int mock_get_device_type(netdev_t *dev, void *value, size_t max_len)
@ -649,6 +667,14 @@ static int mock_send(netdev_t *dev, const iolist_t *iolist)
return res;
}
static const shell_command_t shell_commands[] = {
{ "udp", "send data over UDP and listen on UDP ports", udp_cmd },
{ "unittests", "Runs unitest", unittests},
{ "test", "sends data according to a specified numeric test", shell_test_cmd },
{ "send-test-pkt", "start sendig UDP test packets to TEST_PORT", send_test_pkt },
{ NULL, NULL, NULL }
};
int main(void)
{
eth_netif = gnrc_netif_iter(NULL);
@ -663,13 +689,6 @@ int main(void)
sizeof(mock_netif_stack),
GNRC_NETIF_PRIO, "mock_netif",
(netdev_t *)&mock_netdev);
run_unittests();
printf("Sending UDP test packets to port %u\n", TEST_PORT);
for (unsigned i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (ipv6_addr_is_link_local(&eth_netif->ipv6.addrs[i])) {
local_addr = &eth_netif->ipv6.addrs[i];
}
}
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
return 0;
}

View File

@ -318,6 +318,7 @@ def test_ipv6_ext_frag_fwd_too_big(child, s, iface, ll_dst):
def testfunc(child):
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)
@ -337,6 +338,7 @@ def testfunc(child):
print("FAILED")
raise e
child.sendline("send-test-pkt")
child.expect(r"Sending UDP test packets to port (\d+)\r\n")
port = int(child.match.group(1))

View File

@ -35,8 +35,6 @@ USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
DISABLE_MODULE += test_utils_interactive_sync
# The test requires some setup and to be run as root
# So it cannot currently be run
TEST_ON_CI_BLACKLIST += all

View File

@ -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) {
@ -255,9 +250,23 @@ static void run_unittests(void)
TESTS_END();
}
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)
{
run_unittests();
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
return 0;
}

View File

@ -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)

View File

@ -28,8 +28,6 @@ USEMODULE += shell_commands
USEMODULE += posix_inet
DISABLE_MODULE += test_utils_interactive_sync
LOW_MEMORY_BOARDS := nucleo-f334r8 msb-430 msb-430h
ifeq ($(BOARD),$(filter $(BOARD),$(LOW_MEMORY_BOARDS)))

View File

@ -37,8 +37,6 @@ USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += od
DISABLE_MODULE += test_utils_interactive_sync
# Export used tap device to environment
export TAPDEV = $(TAP)

View File

@ -63,9 +63,6 @@ def check_cmd(child, cmd, expected):
def testfunc(child):
# check startup message
child.expect('test_shell.')
# loop other defined commands and expected output
for cmd, expected in CMDS:
check_cmd(child, cmd, expected)