@@ -22,6 +22,8 @@
#define STRESS_SIZE 32 /* power of 2 and <=256 */
#define STRESS_RANDOM_SZ 5
#define STRESS_ITERATION 5000
+#define MAX_SIZE_TESTED (100 * 1000000UL)
+#define MAX_ALIGN_TESTED (1024 * 1024)
typedef enum {
STRESS_FREE, /* entry is free and can be allocated */
@@ -212,6 +214,57 @@ void shmem_test_basic(void)
CU_ASSERT(0 == odp_shm_free(shm));
}
+/*
+ * maximum size reservation
+ */
+static void shmem_test_max_reserve(void)
+{
+ odp_shm_capability_t capa;
+ odp_shm_t shm;
+ uint64_t size, align;
+ uint8_t *data;
+ uint64_t i;
+
+ memset(&capa, 0, sizeof(odp_shm_capability_t));
+ CU_ASSERT_FATAL(odp_shm_capability(&capa) == 0);
+
+ CU_ASSERT(capa.max_blocks > 0);
+
+ size = capa.max_size;
+ align = capa.max_align;
+
+ /* Assuming that system has at least MAX_SIZE_TESTED bytes available */
+ if (capa.max_size == 0 || capa.max_size > MAX_SIZE_TESTED)
+ size = MAX_SIZE_TESTED;
+
+ if (capa.max_align == 0 || capa.max_align > MAX_ALIGN_TESTED)
+ align = MAX_ALIGN_TESTED;
+
+ printf("\n size: %" PRIu64 "\n", size);
+ printf(" align: %" PRIu64 "\n", align);
+
+ shm = odp_shm_reserve("test_max_reserve", size, align, 0);
+ CU_ASSERT(shm != ODP_SHM_INVALID);
+
+ data = odp_shm_addr(shm);
+ CU_ASSERT(data != NULL);
+
+ if (data) {
+ memset(data, 0xde, size);
+ for (i = 0; i < size; i++) {
+ if (data[i] != 0xde) {
+ printf(" data error i:%" PRIu64 ", data %x"
+ "\n", i, data[i]);
+ CU_FAIL("Data error");
+ break;
+ }
+ }
+ }
+
+ if (shm != ODP_SHM_INVALID)
+ CU_ASSERT(odp_shm_free(shm) == 0);
+}
+
/*
* thread part for the shmem_test_reserve_after_fork
*/
@@ -769,6 +822,7 @@ void shmem_test_stress(void)
odp_testinfo_t shmem_suite[] = {
ODP_TEST_INFO(shmem_test_basic),
+ ODP_TEST_INFO(shmem_test_max_reserve),
ODP_TEST_INFO(shmem_test_reserve_after_fork),
ODP_TEST_INFO(shmem_test_singleva_after_fork),
ODP_TEST_INFO(shmem_test_stress),