diff options
Diffstat (limited to 'test/validation/api/shmem/shmem.c')
-rw-r--r-- | test/validation/api/shmem/shmem.c | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/test/validation/api/shmem/shmem.c b/test/validation/api/shmem/shmem.c index 9e91dab35..51a6b316e 100644 --- a/test/validation/api/shmem/shmem.c +++ b/test/validation/api/shmem/shmem.c @@ -1,8 +1,6 @@ -/* Copyright (c) 2014-2018, Linaro Limited - * Copyright (c) 2019-2021, Nokia - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2014-2018 Linaro Limited + * Copyright (c) 2019-2021 Nokia */ #include <odp_api.h> @@ -261,6 +259,20 @@ static void shmem_test_reserve(void) CU_ASSERT(odp_shm_free(shm) == 0); } +static void shmem_test_reserve_long_name(void) +{ + odp_shm_t shm; + char name[ODP_SHM_NAME_LEN]; + + memset(name, 'a', sizeof(name)); + name[sizeof(name) - 1] = 0; + + shm = odp_shm_reserve(name, MEDIUM_MEM, ALIGN_SIZE, 0); + CU_ASSERT_FATAL(shm != ODP_SHM_INVALID); + CU_ASSERT_FATAL(shm == odp_shm_lookup(name)); + CU_ASSERT(odp_shm_free(shm) == 0); +} + static void shmem_test_info(void) { odp_shm_t shm; @@ -610,7 +622,7 @@ static int run_test_reserve_after_fork(void *arg ODP_UNUSED) CU_ASSERT(ODP_SHM_INVALID != shm); glob_data->shm[thr_index] = shm; pattern_small = odp_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(pattern_small); + CU_ASSERT(pattern_small != NULL); for (i = 0; i < SMALL_MEM; i++) pattern_small->data[i] = i; break; @@ -620,7 +632,7 @@ static int run_test_reserve_after_fork(void *arg ODP_UNUSED) CU_ASSERT(ODP_SHM_INVALID != shm); glob_data->shm[thr_index] = shm; pattern_medium = odp_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(pattern_medium); + CU_ASSERT(pattern_medium != NULL); for (i = 0; i < MEDIUM_MEM; i++) pattern_medium->data[i] = (i << 2); break; @@ -630,7 +642,7 @@ static int run_test_reserve_after_fork(void *arg ODP_UNUSED) CU_ASSERT(ODP_SHM_INVALID != shm); glob_data->shm[thr_index] = shm; pattern_big = odp_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(pattern_big); + CU_ASSERT(pattern_big != NULL); for (i = 0; i < BIG_MEM; i++) pattern_big->data[i] = (i >> 2); break; @@ -663,7 +675,7 @@ static void shmem_test_reserve_after_fork(void) shm = odp_shm_reserve(MEM_NAME, sizeof(shared_test_data_t), 0, 0); CU_ASSERT(ODP_SHM_INVALID != shm); glob_data = odp_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(glob_data); + CU_ASSERT(glob_data != NULL); num = odp_cpumask_default_worker(NULL, 0); if (num > MAX_WORKERS) @@ -690,21 +702,21 @@ static void shmem_test_reserve_after_fork(void) case 0: pattern_small = odp_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT_PTR_NOT_NULL(pattern_small); + CU_ASSERT(pattern_small != NULL); for (i = 0; i < SMALL_MEM; i++) CU_ASSERT(pattern_small->data[i] == i); break; case 1: pattern_medium = odp_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT_PTR_NOT_NULL(pattern_medium); + CU_ASSERT(pattern_medium != NULL); for (i = 0; i < MEDIUM_MEM; i++) CU_ASSERT(pattern_medium->data[i] == (i << 2)); break; case 2: pattern_big = odp_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT_PTR_NOT_NULL(pattern_big); + CU_ASSERT(pattern_big != NULL); for (i = 0; i < BIG_MEM; i++) CU_ASSERT(pattern_big->data[i] == (i >> 2)); break; @@ -774,7 +786,7 @@ static int run_test_singleva_after_fork(void *arg ODP_UNUSED) CU_ASSERT_FATAL(ODP_SHM_INVALID != shm); glob_data->shm[thr_index] = shm; pattern_small = odp_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(pattern_small); + CU_ASSERT(pattern_small != NULL); glob_data->address[thr_index] = (void *)pattern_small; for (i = 0; i < SMALL_MEM; i++) pattern_small->data[i] = i; @@ -786,7 +798,7 @@ static int run_test_singleva_after_fork(void *arg ODP_UNUSED) CU_ASSERT_FATAL(ODP_SHM_INVALID != shm); glob_data->shm[thr_index] = shm; pattern_medium = odp_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(pattern_medium); + CU_ASSERT(pattern_medium != NULL); glob_data->address[thr_index] = (void *)pattern_medium; for (i = 0; i < MEDIUM_MEM; i++) pattern_medium->data[i] = (i << 2); @@ -798,7 +810,7 @@ static int run_test_singleva_after_fork(void *arg ODP_UNUSED) CU_ASSERT_FATAL(ODP_SHM_INVALID != shm); glob_data->shm[thr_index] = shm; pattern_big = odp_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(pattern_big); + CU_ASSERT(pattern_big != NULL); glob_data->address[thr_index] = (void *)pattern_big; for (i = 0; i < BIG_MEM; i++) pattern_big->data[i] = (i >> 2); @@ -855,7 +867,7 @@ static void shmem_test_singleva_after_fork(void) 0, 0); CU_ASSERT(ODP_SHM_INVALID != shm); glob_data = odp_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(glob_data); + CU_ASSERT(glob_data != NULL); num = odp_cpumask_default_worker(NULL, 3); if (num > MAX_WORKERS) @@ -885,21 +897,21 @@ static void shmem_test_singleva_after_fork(void) case 0: pattern_small = odp_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT_PTR_NOT_NULL_FATAL(pattern_small); + CU_ASSERT_FATAL(pattern_small != NULL); for (i = 0; i < SMALL_MEM; i++) CU_ASSERT(pattern_small->data[i] == i); break; case 1: pattern_medium = odp_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT_PTR_NOT_NULL_FATAL(pattern_medium); + CU_ASSERT_FATAL(pattern_medium != NULL); for (i = 0; i < MEDIUM_MEM; i++) CU_ASSERT(pattern_medium->data[i] == (i << 2)); break; case 2: pattern_big = odp_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT_PTR_NOT_NULL_FATAL(pattern_big); + CU_ASSERT_FATAL(pattern_big != NULL); for (i = 0; i < BIG_MEM; i++) CU_ASSERT(pattern_big->data[i] == (i >> 2)); break; @@ -950,7 +962,7 @@ static int run_test_stress(void *arg ODP_UNUSED) shm = odp_shm_lookup(MEM_NAME); glob_data = odp_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(glob_data); + CU_ASSERT(glob_data != NULL); /* wait for general GO! */ odp_barrier_wait(&glob_data->test_barrier1); @@ -1000,7 +1012,7 @@ static int run_test_stress(void *arg ODP_UNUSED) } address = odp_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(address); + CU_ASSERT(address != NULL); glob_data->stress[index].address = address; glob_data->stress[index].flags = flags; glob_data->stress[index].size = size; @@ -1035,7 +1047,7 @@ static int run_test_stress(void *arg ODP_UNUSED) != 0); address = odp_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(address); + CU_ASSERT(address != NULL); align = glob_data->stress[index].align; if (align) { @@ -1091,7 +1103,7 @@ static void shmem_test_stress(void) 0, 0); CU_ASSERT(ODP_SHM_INVALID != globshm); glob_data = odp_shm_addr(globshm); - CU_ASSERT_PTR_NOT_NULL(glob_data); + CU_ASSERT(glob_data != NULL); num = odp_cpumask_default_worker(NULL, 0); if (num > MAX_WORKERS) @@ -1139,6 +1151,7 @@ static int shm_suite_init(void) odp_testinfo_t shmem_suite[] = { ODP_TEST_INFO(shmem_test_capability), ODP_TEST_INFO(shmem_test_reserve), + ODP_TEST_INFO(shmem_test_reserve_long_name), ODP_TEST_INFO(shmem_test_info), ODP_TEST_INFO_CONDITIONAL(shmem_test_flag_hp, shmem_check_flag_hp), ODP_TEST_INFO_CONDITIONAL(shmem_test_flag_no_hp, shmem_check_flag_no_hp), |