tests: msg_send_receive: fix "sent ptr goes out of scope" bug
This commit is contained in:
parent
5c373776b3
commit
e8927388d3
@ -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…
x
Reference in New Issue
Block a user