Browse Source

tests: msg_send_receive: fix "sent ptr goes out of scope" bug

pr/spi.typo
Kaspar Schleiser 7 years ago
parent
commit
e8927388d3
  1. 16
      tests/msg_send_receive/main.c

16
tests/msg_send_receive/main.c

@ -37,23 +37,26 @@ static char thread2_stack[THREAD2_STACKSIZE];
static kernel_pid_t thread1_pid, thread2_pid;
static int counter1 = 0;
static int counter2 = 0;
static void *thread1(void *args)
{
(void)args;
msg_t msg_req, msg_resp;
int counter = 0, success = 1;
int success = 1;
msg_resp.content.ptr = NULL;
msg_req.content.ptr = &counter;
msg_req.content.ptr = &counter1;
for (int i = 0; i < TEST_EXECUTION_NUM; i++) {
msg_send_receive(&msg_req, &msg_resp, thread2_pid);
if ((NULL == msg_resp.content.ptr) ||
(&counter != ((int *) msg_req.content.ptr)) ||
(counter != (*(int *) msg_resp.content.ptr)) ||
(counter != (*(int *) msg_req.content.ptr))) {
(&counter1 != ((int *) msg_req.content.ptr)) ||
(counter1 != (*(int *) msg_resp.content.ptr)) ||
(counter1 != (*(int *) msg_req.content.ptr))) {
success = 0;
break;
}
@ -74,9 +77,8 @@ static void *thread2(void *args)
(void)args;
msg_t msg_req, msg_resp;
int counter = 0;
msg_resp.content.ptr = &counter;
msg_resp.content.ptr = &counter2;
for (int i = 0; i < TEST_EXECUTION_NUM; i++) {
msg_receive(&msg_req);

Loading…
Cancel
Save