Skip to content

Commit a51bd53

Browse files
peter-mitsiscfriedt
authored andcommitted
tests: Update posix common test for Xtensa
Updates the posix common test so that it will pass on Xtensa SMP boards such as intel_adsp_ace15_mtpm. This involves ensuring that a newly created thread does not attempt access/modify the stack of a thread that is currently running on a different CPU. Signed-off-by: Peter Mitsis <[email protected]>
1 parent 5cd2e17 commit a51bd53

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

tests/posix/common/src/mutex.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ static K_THREAD_STACK_DEFINE(stack, STACK_SIZE);
1717

1818
pthread_mutex_t mutex1;
1919
pthread_mutex_t mutex2;
20+
pthread_mutex_t mutex;
2021

2122
void *normal_mutex_entry(void *p1)
2223
{
@@ -213,20 +214,19 @@ static void timespec_add_ms(struct timespec *ts, uint32_t ms)
213214
static void *test_mutex_timedlock_fn(void *arg)
214215
{
215216
struct timespec time_point;
216-
pthread_mutex_t *mutex = (pthread_mutex_t *)arg;
217+
pthread_mutex_t *mtx = (pthread_mutex_t *)arg;
217218

218219
zassume_ok(clock_gettime(CLOCK_MONOTONIC, &time_point));
219220
timespec_add_ms(&time_point, TIMEDLOCK_TIMEOUT_MS);
220221

221-
return INT_TO_POINTER(pthread_mutex_timedlock(mutex, &time_point));
222+
return INT_TO_POINTER(pthread_mutex_timedlock(mtx, &time_point));
222223
}
223224

224225
/** @brief Test to verify @ref pthread_mutex_timedlock returns ETIMEDOUT */
225226
ZTEST(posix_apis, test_mutex_timedlock)
226227
{
227228
void *ret;
228229
pthread_t th;
229-
pthread_t mutex;
230230
pthread_attr_t attr;
231231

232232
zassert_ok(pthread_attr_init(&attr));

tests/posix/common/src/pthread.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ static int barrier_failed;
5353
static int barrier_done[N_THR_E];
5454
static int barrier_return[N_THR_E];
5555

56+
static uint32_t param;
57+
5658
/* First phase bounces execution between two threads using a condition
5759
* variable, continuously testing that no other thread is mucking with
5860
* the protected state. This ends with all threads going back to
@@ -827,15 +829,14 @@ static void *fun(void *arg)
827829
ZTEST(posix_apis, test_pthread_dynamic_stacks)
828830
{
829831
pthread_t th;
830-
uint32_t x = 0;
831832

832833
if (!IS_ENABLED(CONFIG_DYNAMIC_THREAD)) {
833834
ztest_test_skip();
834835
}
835836

836-
zassert_ok(pthread_create(&th, NULL, fun, &x));
837+
zassert_ok(pthread_create(&th, NULL, fun, &param));
837838
zassert_ok(pthread_join(th, NULL));
838-
zassert_equal(BIOS_FOOD, x);
839+
zassert_equal(BIOS_FOOD, param);
839840
}
840841

841842
static void *non_null_retval(void *arg)

0 commit comments

Comments
 (0)