tests/kernel: Coherence: no shared data on stacks

A fairly common idiom in our test code is to put test-local data
structures onto the stack, even when they are to be used from another
thread.  But stacks are incoherent memory on some platforms, which
means that such things may not get a consistent view of memory between
threads.

Just make these things static.  A few of these spots were causing test
failures on intel_adsp_cavs15.  More were found by inspection while
hunting for mistakes.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2021-02-09 13:49:38 -08:00 committed by Anas Nashif
parent 1ba7414029
commit 015b4f7303
6 changed files with 12 additions and 12 deletions

View file

@ -76,7 +76,7 @@ void test_timeout_order(void)
k_timer_start(&timer[ii], K_MSEC(100), K_NO_WAIT);
}
struct k_poll_event poll_events[NUM_TIMEOUTS];
static struct k_poll_event poll_events[NUM_TIMEOUTS];
for (ii = 0; ii < NUM_TIMEOUTS; ii++) {
k_poll_event_init(&poll_events[ii], K_POLL_TYPE_SEM_AVAILABLE,

View file

@ -22,7 +22,7 @@
*/
void test_lifo_get_fail(void *p1, void *p2, void *p3)
{
struct k_lifo lifo;
static struct k_lifo lifo;
k_lifo_init(&lifo);
/**TESTPOINT: lifo get returns NULL*/

View file

@ -27,7 +27,7 @@ static enum mmsg_type {
static void msg_sender(struct k_mbox *pmbox, k_timeout_t timeout)
{
struct k_mbox_msg mmsg;
static struct k_mbox_msg mmsg;
(void)memset(&mmsg, 0, sizeof(mmsg));
@ -53,8 +53,8 @@ static void msg_sender(struct k_mbox *pmbox, k_timeout_t timeout)
static void msg_receiver(struct k_mbox *pmbox, k_tid_t thd_id,
k_timeout_t timeout)
{
struct k_mbox_msg mmsg;
char rxdata[MAIL_LEN];
static struct k_mbox_msg mmsg;
static char rxdata[MAIL_LEN];
switch (info_type) {
case PUT_GET_NULL:

View file

@ -159,7 +159,7 @@ static void msgq_isr(struct k_msgq *pmsgq)
static void thread_entry_get_data(void *p1, void *p2, void *p3)
{
uint32_t rx_buf[MSGQ_LEN];
static uint32_t rx_buf[MSGQ_LEN];
int i = 0;
while (k_msgq_get(p1, &rx_buf[i], K_NO_WAIT) != 0) {
@ -201,7 +201,7 @@ static void msgq_thread_data_passing(struct k_msgq *pmsgq)
static void get_empty_entry(void *p1, void *p2, void *p3)
{
int ret;
uint32_t rx_buf[MSGQ_LEN];
static uint32_t rx_buf[MSGQ_LEN];
/* make sure there is no message in the queue */
ret = k_msgq_peek(p1, rx_buf);
@ -324,7 +324,7 @@ void test_msgq_user_thread_overflow(void)
*/
void test_msgq_isr(void)
{
struct k_msgq stack_msgq;
static struct k_msgq stack_msgq;
/**TESTPOINT: init via k_msgq_init*/
k_msgq_init(&stack_msgq, tbuffer, MSG_SIZE, MSGQ_LEN);

View file

@ -385,7 +385,7 @@ void test_queue_poll_race(void)
void test_multiple_queues(void)
{
/*define multiple queues*/
struct k_queue queues[QUEUE_NUM];
static struct k_queue queues[QUEUE_NUM];
for (int i = 0; i < QUEUE_NUM; i++) {
k_queue_init(&queues[i]);

View file

@ -21,7 +21,7 @@ static struct k_thread tdata;
*/
void test_queue_get_fail(void)
{
struct k_queue queue;
static struct k_queue queue;
k_queue_init(&queue);
/**TESTPOINT: queue get returns NULL*/
@ -54,7 +54,7 @@ static void tThread_entry(void *p1, void *p2, void *p3)
void test_queue_append_list_error(void)
{
qdata_t data_l[2];
struct k_queue queue;
static struct k_queue queue;
qdata_t *head = NULL, *tail = &data_l[1];
k_queue_init(&queue);
@ -97,7 +97,7 @@ void test_queue_append_list_error(void)
void test_queue_merge_list_error(void)
{
qdata_t data_sl[2];
struct k_queue queue;
static struct k_queue queue;
sys_slist_t slist;
k_queue_init(&queue);