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

tests: add test_utils_interactive_sync when possible

- Define test_utils_interactive_sync as DEFAULT_MODULE in Makefile.tests_common
- For tests disabling autoinit, add test_utils_interactive_sync to main
- Add DISABLE_MODULE += test_utils_interactive_sync for tests requiring
  sudo,  `tests/shell`, `tests/minimal` and `tests/stdin`
- Add shell_commands to tests/periph_wdt and tests/struct_tm_utility to
  pull `r` and `s` commands
- Remove includes and usage in `tests/main.c` for tests that where
  already using test_utils_interactive_sync
This commit is contained in:
Francisco Molina 2019-10-10 01:10:41 +02:00
parent eb9cb198a0
commit 416c048737
51 changed files with 122 additions and 28 deletions

View File

@ -1,4 +1,7 @@
APPLICATION ?= tests_$(notdir $(patsubst %/,%,$(CURDIR)))
DEFAULT_MODULE += test_utils_interactive_sync
ifneq (,$(filter tests_driver_%,$(APPLICATION)))
BOARD ?= samr21-xpro
endif

View File

@ -22,6 +22,8 @@
#include <string.h>
#include <inttypes.h>
#include "test_utils/interactive_sync.h"
#include "xtimer.h"
#include "fmt.h"
@ -63,6 +65,8 @@ int main(void)
bloom_init(&bloom, BLOOM_BITS, bf, hashes, BLOOM_HASHF);
test_utils_interactive_sync();
printf("Testing Bloom filter.\n\n");
printf("m: %" PRIu32 " k: %" PRIu32 "\n\n", (uint32_t) bloom.m,
(uint32_t) bloom.k);

View File

@ -24,7 +24,6 @@
#include "cond.h"
#include "mutex.h"
#include "thread.h"
#include "test_utils/interactive_sync.h"
#define THREAD_NUMOF (5U)
#define THREAD_FIRSTGROUP_NUMOF (3U)
@ -63,8 +62,6 @@ int main(void)
puts("Condition variable order test");
puts("Please refer to the README.md for more information\n");
test_utils_interactive_sync();
mutex_init(&testlock);
cond_init(&testcond);

View File

@ -10,8 +10,6 @@
import os
import sys
from testrunner import test_utils_interactive_sync
thread_prio = {
3: 6,
4: 4,
@ -23,7 +21,6 @@ first_group_size = 3
def testfunc(child):
test_utils_interactive_sync(child)
for k in thread_prio.keys():
child.expect_exact("T{} (prio {}): waiting on condition variable now"

View File

@ -9,6 +9,7 @@
#include "embUnit.h"
#include "tests-cpp_ctors.h"
#include "thread.h" /* For thread_getpid() */
#include "test_utils/interactive_sync.h"
long tests_cpp_ctors_global_value(void);
long tests_cpp_ctors_static_value(void);
@ -58,6 +59,8 @@ Test *tests_cpp_ctors_tests(void)
int main(void)
{
test_utils_interactive_sync();
TESTS_START();
TESTS_RUN(tests_cpp_ctors_tests());
TESTS_END();

View File

@ -5,7 +5,6 @@ from testrunner import run
def testfunc(child):
child.expect("All up, running the shell now")
child.sendline("ifconfig")
child.expect(r"Iface\s+(\d+)\s+HWaddr:")

View File

@ -23,6 +23,8 @@
#include <stdio.h>
#include <math.h>
#include "test_utils/interactive_sync.h"
#include "board.h"
/* as default we run the test 100k times */
@ -34,6 +36,8 @@
int main(void)
{
test_utils_interactive_sync();
double x = 1234567.0 / 1024.0;
puts("Testing floating point arithmetic...\n");

View File

@ -35,6 +35,8 @@ 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

@ -44,6 +44,8 @@ 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

@ -39,6 +39,8 @@ 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

@ -25,6 +25,8 @@
#include "net/gnrc/sixlowpan/frag/rb.h"
#include "xtimer.h"
#include "test_utils/interactive_sync.h"
#define TEST_NETIF_HDR_SRC { 0xb3, 0x47, 0x60, 0x49, \
0x78, 0xfe, 0x95, 0x48 }
#define TEST_NETIF_HDR_DST { 0xa4, 0xf2, 0xd2, 0xc9, \
@ -627,6 +629,8 @@ static void run_unittests(void)
int main(void)
{
test_utils_interactive_sync();
/* no auto-init, so xtimer needs to be initialized manually*/
xtimer_init();
/* netreg requires queue, but queue size one should be enough for us */

View File

@ -32,6 +32,8 @@ 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

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

View File

@ -12,7 +12,6 @@ from testrunner import run
def testfunc(child):
# check startup message
child.expect('Shell-based test application for heap functions.')
child.sendline('heap')
ret = child.expect([r'heap: \d+ \(used \d+, free \d+\) \[bytes\]', 'heap statistics are not supported'])
if ret == 1:

View File

@ -20,6 +20,8 @@ ifneq ($(BOARD),native)
TESTS=
endif
DISABLE_MODULE += test_utils_interactive_sync
# test fails on murdock and on my machine due to the process exiting directly
TEST_ON_CI_BLACKLIST += all

View File

@ -22,6 +22,8 @@
#include <stdint.h>
#include <stdio.h>
#include "test_utils/interactive_sync.h"
#include "net/sock/ip.h"
#include "xtimer.h"
@ -1081,6 +1083,8 @@ int main(void)
{
uint8_t code = 0;
test_utils_interactive_sync();
#ifdef SO_REUSE
code |= 1;
#endif

View File

@ -33,6 +33,8 @@
#include "constants.h"
#include "stack.h"
#include "test_utils/interactive_sync.h"
#define _TEST_BUFFER_SIZE (128)
#define _QUEUE_SIZE (1)
@ -958,6 +960,8 @@ static void test_tcp_write6__success(void)
int main(void)
{
test_utils_interactive_sync();
uint8_t code = 0;
#ifdef SO_REUSE

View File

@ -28,6 +28,8 @@
#include "constants.h"
#include "stack.h"
#include "test_utils/interactive_sync.h"
#define _TEST_BUFFER_SIZE (128)
static uint8_t _test_buffer[_TEST_BUFFER_SIZE];
@ -1317,6 +1319,8 @@ static void test_sock_udp_send6__no_sock(void)
int main(void)
{
test_utils_interactive_sync();
uint8_t code = 0;
#ifdef SO_REUSE

View File

@ -4,5 +4,6 @@ include ../Makefile.tests_common
CFLAGS += -DNDEBUG -DLOG_LEVEL=LOG_NONE
DISABLE_MODULE += auto_init
DISABLE_MODULE += test_utils_interactive_sync
include $(RIOTBASE)/Makefile.include

View File

@ -25,6 +25,7 @@
#include "log.h"
#include "msg.h"
#include "test_utils/interactive_sync.h"
#define MSG_QUEUE_LENGTH (8)
@ -32,11 +33,14 @@ msg_t msg_queue[MSG_QUEUE_LENGTH];
int main(void)
{
test_utils_interactive_sync();
msg_t msges[MSG_QUEUE_LENGTH];
msg_init_queue(msg_queue, MSG_QUEUE_LENGTH);
puts("[START]");
/* add message to own queue */
for (int idx = 0; idx < MSG_QUEUE_LENGTH; ++idx) {
msges[idx].type = idx;

View File

@ -22,6 +22,8 @@
#include "thread.h"
#include "mutex.h"
#include "test_utils/interactive_sync.h"
static mutex_t mutex = MUTEX_INIT;
static volatile int indicator;
static kernel_pid_t main_pid;
@ -47,6 +49,8 @@ static void *second_thread(void *arg)
int main(void)
{
test_utils_interactive_sync();
uint32_t count = 0;
uint32_t kcount = 0;

View File

@ -28,6 +28,8 @@
#include "thread.h"
#include "utlist.h"
#include "test_utils/interactive_sync.h"
#define _EXP_LENGTH (64)
#define _MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT + THREAD_EXTRA_STACKSIZE_PRINTF)
@ -249,6 +251,8 @@ static int test_set_addr(void)
int main(void)
{
test_utils_interactive_sync();
/* initialization */
gnrc_pktbuf_init();
msg_init_queue(_main_msg_queue, _MAIN_MSG_QUEUE_SIZE);

View File

@ -6,7 +6,6 @@ from testrunner import run
def testfunc(child):
child.expect_exact("All up, running the shell now")
child.expect_exact(">")
time.sleep(1) # Wait 1s to let some time for the interface to be fully ready
child.sendline("ifconfig")

View File

@ -29,6 +29,8 @@
#include "periph_conf.h"
#include "periph/rtt.h"
#include "test_utils/interactive_sync.h"
#define TICKS_TO_WAIT (5 * RTT_FREQUENCY)
static volatile uint32_t last;
@ -46,6 +48,8 @@ void cb(void *arg)
int main(void)
{
test_utils_interactive_sync();
puts("\nRIOT RTT low-level driver test");
puts("This test will display 'Hello' every 5 seconds\n");

View File

@ -5,5 +5,6 @@ FEATURES_REQUIRED += periph_wdt
USEMODULE += xtimer
USEMODULE += shell
USEMODULE += shell_commands
include $(RIOTBASE)/Makefile.include

View File

@ -2,6 +2,5 @@ include ../Makefile.tests_common
USEPKG += libfixmath
USEMODULE += libfixmath
USEMODULE += test_utils_interactive_sync
include $(RIOTBASE)/Makefile.include

View File

@ -33,7 +33,6 @@
#include "kernel_defines.h"
#include "fix16.h"
#include "test_utils/interactive_sync.h"
#ifndef M_PI
# define M_PI 3.14159265359
@ -238,9 +237,6 @@ static void unary_ops(void)
int main(void)
{
/* Sync to prevent flooding of buffer */
test_utils_interactive_sync();
puts("Unary.");
unary_ops();

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys
from testrunner import run, test_utils_interactive_sync
from testrunner import run
def expect_unary(child):
@ -46,7 +46,6 @@ def expect_binary(child):
def testfunc(child):
test_utils_interactive_sync(child)
child.expect_exact('Unary.')
expect_unary(child)
child.expect_exact('Binary.')

View File

@ -32,6 +32,8 @@
#include "thread.h"
#include "xtimer.h"
#include "test_utils/interactive_sync.h"
#define SEMAPHORE_MSG_QUEUE_SIZE (8)
#define SEMAPHORE_TEST_THREADS (5)
static char test1_thread_stack[THREAD_STACKSIZE_MAIN];
@ -292,6 +294,8 @@ void test4(void)
int main(void)
{
test_utils_interactive_sync();
msg_init_queue(main_msg_queue, SEMAPHORE_MSG_QUEUE_SIZE);
xtimer_init();
puts("######################### TEST1:");

View File

@ -2,6 +2,4 @@ include ../Makefile.tests_common
USEMODULE += posix_time
USEMODULE += test_utils_interactive_sync
include $(RIOTBASE)/Makefile.include

View File

@ -26,11 +26,9 @@
#include <stdio.h>
#include <unistd.h>
#include "test_utils/interactive_sync.h"
int main(void)
{
test_utils_interactive_sync();
puts("5 x usleep(i++ * 500000)");
for (unsigned i = 0; i < 5; i++) {
useconds_t us = i * 500000u;

View File

@ -10,7 +10,7 @@
import sys
import time
from testrunner import run, test_utils_interactive_sync
from testrunner import run
US_PER_SEC = 1000000
EXTERNAL_JITTER = 0.15
@ -22,7 +22,6 @@ class InvalidTimeout(Exception):
def testfunc(child):
try:
test_utils_interactive_sync(child)
start_test = time.time()
child.expect_exact("5 x usleep(i++ * 500000)")
for i in range(5):

View File

@ -27,6 +27,8 @@
#include <thread.h>
#include <xtimer.h>
#include "test_utils/interactive_sync.h"
#define NB_THREADS (5U)
static char stacks[NB_THREADS][THREAD_STACKSIZE_DEFAULT];
@ -54,6 +56,8 @@ static void *_thread_fn(void *arg)
int main(void)
{
test_utils_interactive_sync();
for (unsigned i = 0; i < NB_THREADS; ++i) {
pids[i] = thread_create(stacks[i], sizeof(stacks[i]),
THREAD_PRIORITY_MAIN - 1,

View File

@ -10,6 +10,7 @@ USEMODULE += ps
RIOT_TERMINAL ?= socat
DISABLE_MODULE += auto_init
DISABLE_MODULE += test_utils_interactive_sync
# chronos is missing a getchar implementation
BOARD_BLACKLIST += chronos

View File

@ -31,6 +31,8 @@
#include "msg.h"
#include "od.h"
#include "test_utils/interactive_sync.h"
#define MSG_QUEUE_SIZE (8)
#define MSG_TYPE_ISR (0x3456)
#define RECVBUF_SIZE (IEEE802154_FRAME_LEN_MAX)
@ -104,6 +106,8 @@ static void test_recv(void)
int main(void)
{
test_utils_interactive_sync();
puts("Socket ZEP device driver test");
msg_init_queue(_msg_queue, MSG_QUEUE_SIZE);
_main_pid = sched_active_pid;

View File

@ -2,4 +2,6 @@ include ../Makefile.tests_common
USEMODULE += stdin
DISABLE_MODULE += test_utils_interactive_sync
include $(RIOTBASE)/Makefile.include

View File

@ -3,6 +3,7 @@ include ../Makefile.tests_common
DISABLE_MODULE += auto_init
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += timex
# The MSP-430 toolchain lacks sscanf:

View File

@ -21,6 +21,8 @@
#include <stdio.h>
#include "thread.h"
#include "test_utils/interactive_sync.h"
char t2_stack[THREAD_STACKSIZE_MAIN];
void *second_thread(void *arg)
@ -32,6 +34,8 @@ void *second_thread(void *arg)
int main(void)
{
test_utils_interactive_sync();
(void) thread_create(
t2_stack, sizeof(t2_stack),
THREAD_PRIORITY_MAIN - 1,

View File

@ -25,6 +25,8 @@
#include "thread.h"
#include "mutex.h"
#include "test_utils/interactive_sync.h"
#ifndef PROBLEM
#define PROBLEM 12
#endif
@ -64,6 +66,8 @@ int main(void)
kernel_pid_t ths;
uint32_t factorial = 1;
test_utils_interactive_sync();
printf("[START] compute %d! (factorial).\n", PROBLEM);
for (int i = 0; i < PROBLEM; ++i) {

View File

@ -22,6 +22,8 @@
#include "thread.h"
#include "test_utils/interactive_sync.h"
char second_thread_stack[THREAD_STACKSIZE_MAIN];
char third_thread_stack[THREAD_STACKSIZE_MAIN];
@ -78,6 +80,7 @@ void *second_thread(void *arg)
int main(void)
{
test_utils_interactive_sync();
puts("main: starting");
if ((thread_create(

View File

@ -27,6 +27,8 @@
#include "thread.h"
#include "kernel_types.h"
#include "test_utils/interactive_sync.h"
/* One stack for all threads. DON'T TRY THIS AT HOME!! */
static char dummy_stack[THREAD_STACKSIZE_IDLE];
@ -37,6 +39,8 @@ static void *thread_func(void *arg)
int main(void)
{
test_utils_interactive_sync();
kernel_pid_t thr_id = KERNEL_PID_UNDEF;
unsigned thr_cnt = 0;

View File

@ -24,6 +24,8 @@
#include "thread.h"
#include "msg.h"
#include "test_utils/interactive_sync.h"
char t1_stack[THREAD_STACKSIZE_MAIN];
char t2_stack[THREAD_STACKSIZE_MAIN];
char t3_stack[THREAD_STACKSIZE_MAIN];
@ -85,6 +87,8 @@ void *thread3(void *arg)
int main(void)
{
test_utils_interactive_sync();
p_main = sched_active_pid;
p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,

View File

@ -27,6 +27,8 @@
#include "thread.h"
#include "msg.h"
#include "test_utils/interactive_sync.h"
#define CANARY_TYPE (0x21fd)
#define TIMER_FREQ (1000000LU)
@ -79,6 +81,8 @@ static void *_thread(void *arg)
int main(void)
{
test_utils_interactive_sync();
kernel_pid_t pid;
timer_init(TIMER_DEV(0), TIMER_FREQ, _timer, NULL);

View File

@ -25,6 +25,8 @@
#include "thread.h"
#include "msg.h"
#include "test_utils/interactive_sync.h"
char t1_stack[THREAD_STACKSIZE_MAIN];
kernel_pid_t p_send = KERNEL_PID_UNDEF, p_recv = KERNEL_PID_UNDEF;
@ -54,6 +56,8 @@ void *sender_thread(void *arg)
int main(void)
{
test_utils_interactive_sync();
msg_t msg;
p_recv = sched_active_pid;

View File

@ -25,6 +25,8 @@
#include "thread.h"
#include "msg.h"
#include "test_utils/interactive_sync.h"
char t1_stack[THREAD_STACKSIZE_MAIN];
kernel_pid_t p_send = KERNEL_PID_UNDEF, p_recv = KERNEL_PID_UNDEF;
@ -54,6 +56,8 @@ void *thread1(void *arg)
int main(void)
{
test_utils_interactive_sync();
msg_t msg;
p_recv = sched_active_pid;

View File

@ -25,6 +25,8 @@
#include "thread.h"
#include "msg.h"
#include "test_utils/interactive_sync.h"
char t1_stack[THREAD_STACKSIZE_MAIN];
char t2_stack[THREAD_STACKSIZE_MAIN];
char t3_stack[THREAD_STACKSIZE_MAIN];
@ -51,6 +53,8 @@ void *sub_thread(void *arg)
int main(void)
{
test_utils_interactive_sync();
puts("START");
msg_t msg;

View File

@ -26,6 +26,8 @@
#include "sched.h"
#include "thread.h"
#include "test_utils/interactive_sync.h"
char iqr_check_stack[THREAD_STACKSIZE_DEFAULT];
static volatile uint8_t irq_occurred;
@ -65,6 +67,8 @@ static void _spin(void)
int main(void)
{
test_utils_interactive_sync();
puts("Context swap race condition test application");
kernel_pid_t pid;

View File

@ -11,6 +11,8 @@
#include "embUnit.h"
#include "xtimer.h"
#include "test_utils/interactive_sync.h"
#define UNCURRY(FUN, ARGS) FUN(ARGS)
#define RUN_TEST_SUITES(...) MAP(RUN_TEST_SUITE, __VA_ARGS__)
#define RUN_TEST_SUITE(TEST_SUITE) \
@ -21,6 +23,8 @@
int main(void)
{
test_utils_interactive_sync();
#ifdef MODULE_XTIMER
/* auto_init is disabled, but some modules depends on this module being initialized */
xtimer_init();

View File

@ -5,8 +5,6 @@ USEMODULE += xtimer
# This test randomly fails on `native` so disable it from CI
TEST_ON_CI_BLACKLIST += native
USEMODULE += test_utils_interactive_sync
# Port and pin configuration for probing with oscilloscope
# Port number should be found in port enum e.g in cpu/include/periph_cpu.h
#FEATURES_REQUIRED += periph_gpio

View File

@ -27,7 +27,6 @@
#include "xtimer.h"
#include "timex.h"
#include "test_utils/interactive_sync.h"
#define RUNS (5U)
#define SLEEP_TIMES_NUMOF ARRAY_SIZE(sleep_times)
@ -62,7 +61,6 @@ int main(void)
printf("Running test %u times with %u distinct sleep times\n", RUNS,
(unsigned)SLEEP_TIMES_NUMOF);
test_utils_interactive_sync();
start_test = xtimer_now_usec();
for (unsigned m = 0; m < RUNS; m++) {
for (unsigned n = 0;

View File

@ -11,7 +11,7 @@
import sys
import time
from testrunner import run, test_utils_interactive_sync
from testrunner import run
US_PER_SEC = 1000000
@ -28,7 +28,6 @@ def testfunc(child):
RUNS = int(child.match.group(1))
SLEEP_TIMES_NUMOF = int(child.match.group(2))
try:
test_utils_interactive_sync(child)
start_test = time.time()
for m in range(RUNS):
for n in range(SLEEP_TIMES_NUMOF):