Skip to content

Commit

Permalink
tests: add xtimer_remove
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 committed Aug 25, 2015
1 parent a1dde92 commit b21aca4
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/xtimer_remove/Makefile
@@ -0,0 +1,10 @@
APPLICATION = xtimer_remove
include ../Makefile.tests_common

BOARD ?= native
RIOTBASE ?= $(CURDIR)/../..

FEATURES_REQUIRED += periph_timer
USEMODULE += xtimer

include $(RIOTBASE)/Makefile.include
63 changes: 63 additions & 0 deletions tests/xtimer_remove/main.c
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
*
* 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 timer test application
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*
* @}
*/

#include <stdio.h>

#include "msg.h"
#include "thread.h"
#include "xtimer.h"

#define N (3U)

int main(void)
{
puts("xtimer_remove test application.\n");

kernel_pid_t me = thread_getpid();

for (unsigned int n = 0; n < N; n++) {
printf("Setting %u timers, removing timer %u/%u\n", N, n, N);
xtimer_t timers[N];
msg_t msg[N];
for (unsigned int i = 0; i < N; i++) {
msg[i].type = i;
xtimer_set_msg(&timers[i], 100000*(i+1), &msg[i], me);
}

xtimer_remove(&timers[n]);

unsigned int num = N-1;
while(num--) {
msg_t m;
msg_receive(&m);
if (m.type == n) {
printf("ERROR: msg type=%i unexpected!\n", m.type);
return -1;
}
else {
printf("timer %u triggered.\n", m.type);
}
}
}

printf("test successful.\n");

return 0;
}

0 comments on commit b21aca4

Please sign in to comment.