Skip to content
Snippets Groups Projects
Commit 6099d82d authored by Peter Kietzmann's avatar Peter Kietzmann
Browse files

Merge pull request #2824 from LudwigOrtmann/pr/tests-cleanup

tests: remove some pointless test applications
parents 279fd091 2fd7f77e
No related branches found
No related tags found
No related merge requests found
APPLICATION = disable_module
include ../Makefile.tests_common
DISABLE_MODULE += auto_init
include $(RIOTBASE)/Makefile.include
/*
* Copyright (C) 2014 René Kijewski <rene.kijewski@fu-berlin.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Test whether DISABLE_MODULE works.
*
* @author René Kijewski <rene.kijewski@fu-berlin.de>
*
* @}
*/
#include <stdio.h>
int main(void)
{
puts("Start.");
# ifdef MODULE_AUTO_INIT
puts("-ERROR: MODULE_AUTO_INIT present!");
# else
puts("+OK: MODULE_AUTO_INIT absent.");
# endif
puts("Done.");
return 0;
}
APPLICATION = ipc_pingpong
include ../Makefile.tests_common
BOARD_INSUFFICIENT_RAM := stm32f0discovery
DISABLE_MODULE += auto_init
include $(RIOTBASE)/Makefile.include
/*
* Copyright (C) 2013 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief IPC pingpong test
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author René Kijewski <rene.kijewski@fu-berlin.de>
*
* @}
*/
#include <stdio.h>
#include "thread.h"
#include "msg.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
#define LIMIT 1000
static char stacks[3][KERNEL_CONF_STACKSIZE_MAIN];
static kernel_pid_t pids[3];
static void *first_thread(void *arg)
{
(void) arg;
puts("1st starting.");
for (unsigned i = 0; i < LIMIT; ++i) {
msg_t m;
m.content.value = i;
msg_send_receive(&m, &m, pids[1]);
DEBUG("%u: Got msg with content %i\n", i, m.content.value);
if (m.content.value != i + 1) {
puts("ERROR. 1st");
return NULL;
}
}
puts("1st done.");
return NULL;
}
static void *second_thread(void *arg)
{
(void) arg;
puts("2nd starting.");
while (1) {
msg_t m1;
msg_receive(&m1);
DEBUG("2nd: got msg from %" PRIkernel_pid ": %i\n", m1.sender_pid, m1.content.value);
msg_t m2;
m2.content.value = m1.content.value + 1;
msg_send_receive(&m2, &m2, pids[2]);
if (m2.content.value != m1.content.value) {
puts("ERROR. 2nd");
return NULL;
}
++m1.content.value;
msg_reply(&m1, &m1);
if (m1.content.value == LIMIT) {
break;
}
}
puts("2nd done.");
return NULL;
}
static void *third_thread(void *arg)
{
(void) arg;
puts("3rd starting.");
while (1) {
msg_t m;
msg_receive(&m);
DEBUG("3rd: got msg from %" PRIkernel_pid ": %i\n", m.sender_pid, m.content.value);
--m.content.value;
msg_reply(&m, &m);
if (m.content.value == LIMIT - 1) {
break;
}
}
puts("3rd done.");
return NULL;
}
int main(void)
{
puts("Main thread start.");
pids[0] = thread_create(stacks[0], sizeof(stacks[0]),
PRIORITY_MAIN - 1, CREATE_WOUT_YIELD | CREATE_STACKTEST,
first_thread, NULL, "1st");
pids[1] = thread_create(stacks[1], sizeof(stacks[1]),
PRIORITY_MAIN - 2, CREATE_WOUT_YIELD | CREATE_STACKTEST,
second_thread, NULL, "2nd");
pids[2] = thread_create(stacks[2], sizeof(stacks[2]),
PRIORITY_MAIN - 3, CREATE_WOUT_YIELD | CREATE_STACKTEST,
third_thread, NULL, "3nd");
puts("Main thread done.");
return 0;
}
#!/usr/bin/env expect
set pid [spawn make term]
puts "-*- Spawened $pid -*-\n"
set result 0
set timeout 5
if { $result == 0 } {
expect {
"Main thread start." {}
timeout { set result 1 }
}
}
set timeout 1
if { $result == 0 } {
expect {
"Main thread done." {}
timeout { set result 1 }
}
}
if { $result == 0 } {
expect {
"3rd starting." {}
timeout { set result 1 }
}
}
if { $result == 0 } {
expect {
"2nd starting." {}
timeout { set result 1 }
}
}
if { $result == 0 } {
expect {
"1st starting." {}
timeout { set result 1 }
}
}
set timeout 10
if { $result == 0 } {
expect {
"3rd done." {}
timeout { set result 1 }
}
}
set timeout 1
if { $result == 0 } {
expect {
"2nd done." {}
timeout { set result 1 }
}
}
if { $result == 0 } {
expect {
"1st done." {}
timeout { set result 1 }
}
}
if { $result == 0 } {
puts "\n-*- Test successful! -*-\n"
} else {
puts "\n-*- TEST HAD ERRORS! -*-\n"
}
spawn kill -15 $pid
sleep 1
spawn kill -9 $pid
wait
close
exit $result
APPLICATION = queue_fairness
include ../Makefile.tests_common
BOARD_INSUFFICIENT_RAM := mbed_lpc1768 stm32f0discovery pca10000 pca10005
USEMODULE += vtimer
DISABLE_MODULE += auto_init
include $(RIOTBASE)/Makefile.include
/*
* Copyright (C) 2014 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
* @file
* @brief Test if the queue used for messaging is fair.
* @author René Kijewski <rene.kijewski@fu-berlin.de>
* @}
*/
#include <stdio.h>
#include "msg.h"
#include "sched.h"
#include "thread.h"
#include "vtimer.h"
#define STACK_SIZE (KERNEL_CONF_STACKSIZE_DEFAULT + KERNEL_CONF_STACKSIZE_MAIN)
#define NUM_CHILDREN (3)
#define NUM_ITERATIONS (10)
static char stacks[NUM_CHILDREN][STACK_SIZE];
static kernel_pid_t pids[NUM_CHILDREN];
static char names[NUM_CHILDREN][8];
static kernel_pid_t parent_pid = KERNEL_PID_UNDEF;
static void *child_fun(void *arg)
{
printf("Start of %s.\n", (char*) arg);
for (int i = 0; i < NUM_ITERATIONS; ++i) {
msg_t m;
m.type = i + 1;
m.content.ptr = (char*) arg;
msg_send(&m, parent_pid);
}
printf("End of %s.\n", (char*) arg);
return NULL;
}
int main(void)
{
puts("Start.");
parent_pid = sched_active_pid;
for (int i = 0; i < NUM_CHILDREN; ++i) {
snprintf(names[i], sizeof(names[i]), "child%2u", i + 1);
pids[i] = thread_create(stacks[i],
sizeof(stacks[i]),
PRIORITY_MAIN + 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST,
child_fun,
names[i],
names[i]);
}
int last_iteration = 0;
for (int i = 0; i < NUM_ITERATIONS * NUM_CHILDREN; ++i) {
msg_t m;
msg_receive(&m);
int cur_iteration = (int) m.type;
char *child = (char *) m.content.ptr;
printf("Received message from %s, iteration %d / %u: %s\n",
child, cur_iteration, NUM_ITERATIONS,
cur_iteration >= last_iteration ? "okay" : "ERROR");
last_iteration = cur_iteration;
vtimer_usleep(25 * 1000);
}
puts("Done.");
return 0;
}
#!/usr/bin/env expect
set timeout 5
set pid [spawn make term]
puts "-*- Spawened $pid -*-\n"
set result 0
expect {
"Start." {}
timeout {
set result 1
}
}
while { $result == 0 } {
set result 1
expect {
"Received message" {
expect {
": okay" { set result 0 }
": ERROR" { set result 1 }
timeout { break }
}
}
"Done." {
set result 0
break
}
timeout { break }
}
}
if { $result == 0 } {
puts "\n-*- Test successful! -*-\n"
} else {
puts "\n-*- TEST HAD ERRORS! -*-\n"
}
spawn kill -15 $pid
sleep 1
spawn kill -9 $pid
wait
close
exit $result
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment