Skip to content

Commit

Permalink
tests: msg_send_receive: fix "sent ptr goes out of scope" bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 committed Jul 27, 2016
1 parent 5c37377 commit 123c042
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/msg_send_receive/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,25 @@ 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;
}
Expand All @@ -74,9 +76,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);
Expand Down

0 comments on commit 123c042

Please sign in to comment.