a752c7ab
elopes
add first test an...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/*
* Copyright (C) 2015 Nick van IJzendoorn <nijzendoorn@engineering-spirit.nl>
* 2017 HAW Hamburg
*
* 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 Thread test application
*
* @author Nick van IJzendoorn <nijzendoorn@engineering-spirit.nl>
* @author Sebastian Meiling <s@mlng.net>
*
* @}
*/
#include <stdio.h>
#include <inttypes.h>
#include "log.h"
#include "msg.h"
#define MSG_QUEUE_LENGTH (8)
msg_t msg_queue[MSG_QUEUE_LENGTH];
int main(void)
{
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;
msg_send_to_self(msges + idx);
LOG_INFO("+ add msg: %d\n", idx);
if (msg_avail() != (idx) + 1) {
puts("[FAILED]");
return 1;
}
}
/* receive available messages in queue */
for (int idx = msg_avail(); idx > 0; --idx) {
msg_t msg;
msg_receive(&msg);
LOG_INFO("- got msg: %d\n", (MSG_QUEUE_LENGTH - idx));
if (msg.type != (MSG_QUEUE_LENGTH - idx) || msg_avail() != idx - 1) {
puts("[FAILED]");
return 1;
}
}
puts("[SUCCESS]");
return 0;
}
|