@@ -20,4 +20,5 @@ dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
dist_odp_schedule_SOURCES = odp_schedule.c common/odp_cunit_common.c
dist_odp_buffer_SOURCES = buffer/odp_buffer_pool_test.c \
+ buffer/odp_buffer_test.c \
odp_buffer.c common/odp_cunit_common.c
new file mode 100644
@@ -0,0 +1,52 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "odp_buffer_tests.h"
+
+static odp_buffer_pool_t raw_pool;
+static odp_buffer_t raw_buffer = ODP_BUFFER_INVALID;
+static const size_t raw_buffer_size = 1500;
+
+int buffer_testsuite_init(void)
+{
+ odp_buffer_pool_param_t params = {
+ .buf_size = raw_buffer_size,
+ .buf_align = ODP_CACHE_LINE_SIZE,
+ .num_bufs = 100,
+ .buf_type = ODP_BUFFER_TYPE_RAW,
+ };
+
+ raw_pool = odp_buffer_pool_create("raw_pool", ODP_SHM_INVALID, ¶ms);
+ if (raw_pool == ODP_BUFFER_POOL_INVALID)
+ return -1;
+ raw_buffer = odp_buffer_alloc(raw_pool);
+ if (raw_buffer == ODP_BUFFER_INVALID)
+ return -1;
+ return 0;
+}
+
+int buffer_testsuite_finalize(void)
+{
+ odp_buffer_free(raw_buffer);
+ if (odp_buffer_pool_destroy(raw_pool) != 0)
+ return -1;
+ return 0;
+}
+
+static void buffer_management_basic(void)
+{
+ CU_ASSERT(odp_buffer_is_valid(raw_buffer) == 1);
+ CU_ASSERT(odp_buffer_pool(raw_buffer) != ODP_BUFFER_POOL_INVALID);
+ CU_ASSERT(odp_buffer_type(raw_buffer) == ODP_BUFFER_TYPE_RAW);
+ CU_ASSERT(odp_buffer_size(raw_buffer) >= raw_buffer_size);
+ CU_ASSERT(odp_buffer_addr(raw_buffer) != NULL);
+ odp_buffer_print(raw_buffer);
+}
+
+CU_TestInfo buffer_tests[] = {
+ _CU_TEST_INFO(buffer_management_basic),
+ CU_TEST_INFO_NULL,
+};
@@ -15,6 +15,10 @@
#define _CU_TEST_INFO(test_func) {#test_func, test_func}
extern CU_TestInfo buffer_pool_tests[];
+extern CU_TestInfo buffer_tests[];
+
+extern int buffer_testsuite_init(void);
+extern int buffer_testsuite_finalize(void);
odp_buffer_pool_t pool_create(int buf_num, int buf_size, int buf_type);
@@ -10,5 +10,10 @@ CU_SuiteInfo odp_testsuites[] = {
{ .pName = "buffer Pool tests",
.pTests = buffer_pool_tests,
},
+ { .pName = "buffer tests",
+ .pTests = buffer_tests,
+ .pInitFunc = buffer_testsuite_init,
+ .pCleanupFunc = buffer_testsuite_finalize,
+ },
CU_SUITE_INFO_NULL,
};
Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org> --- test/validation/Makefile.am | 1 + test/validation/buffer/odp_buffer_test.c | 52 +++++++++++++++++++++++++++++++ test/validation/buffer/odp_buffer_tests.h | 4 +++ test/validation/odp_buffer.c | 5 +++ 4 files changed, 62 insertions(+) create mode 100644 test/validation/buffer/odp_buffer_test.c