diff mbox

[v3] validation: add odp_system test

Message ID 1418662370-23461-1-git-send-email-mike.holmes@linaro.org
State Accepted
Headers show

Commit Message

Mike Holmes Dec. 15, 2014, 4:52 p.m. UTC
add tests for ODP system_info interface

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
Add check from Jerin.

 test/validation/.gitignore   |  1 +
 test/validation/Makefile.am  |  4 ++-
 test/validation/odp_system.c | 74 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100644 test/validation/odp_system.c
diff mbox

Patch

diff --git a/test/validation/.gitignore b/test/validation/.gitignore
index 32834ae..a388488 100644
--- a/test/validation/.gitignore
+++ b/test/validation/.gitignore
@@ -5,3 +5,4 @@  odp_queue
 odp_crypto
 odp_schedule
 odp_shm
+odp_system
diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index d0b5426..98376b9 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -6,7 +6,7 @@  AM_LDFLAGS += -static
 if ODP_CUNIT_ENABLED
 TESTS = ${bin_PROGRAMS}
 check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule
+bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_system
 odp_init_LDFLAGS = $(AM_LDFLAGS)
 odp_queue_LDFLAGS = $(AM_LDFLAGS)
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
@@ -15,6 +15,7 @@  odp_shm_CFLAGS = $(AM_CFLAGS)
 odp_shm_LDFLAGS = $(AM_LDFLAGS)
 odp_schedule_CFLAGS = $(AM_CFLAGS)
 odp_schedule_LDFLAGS = $(AM_LDFLAGS)
+odp_system_LDFLAGS = $(AM_LDFLAGS)
 endif
 
 dist_odp_init_SOURCES = odp_init.c
@@ -25,6 +26,7 @@  dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
 			  odp_crypto.c common/odp_cunit_common.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_system_SOURCES = odp_system.c common/odp_cunit_common.c
 
 #For Linux generic the unimplemented crypto API functions break the
 #regression TODO: https://bugs.linaro.org/show_bug.cgi?id=975
diff --git a/test/validation/odp_system.c b/test/validation/odp_system.c
new file mode 100644
index 0000000..605145b
--- /dev/null
+++ b/test/validation/odp_system.c
@@ -0,0 +1,74 @@ 
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include "odp.h"
+#include "odp_cunit_common.h"
+
+static void test_odp_sys_core_count(void)
+{
+	int cores;
+
+	cores = odp_sys_core_count();
+	CU_ASSERT(0 < cores);
+}
+
+static void test_odp_sys_cache_line_size(void)
+{
+	int cache_size;
+
+	cache_size = odp_sys_cache_line_size();
+	CU_ASSERT(0 < cache_size);
+	CU_ASSERT(ODP_CACHE_LINE_SIZE == cache_size);
+}
+
+static void test_odp_sys_cpu_model_str(void)
+{
+	char model[128];
+
+	snprintf(model, 128, "%s", odp_sys_cpu_model_str());
+	CU_ASSERT(strlen(model) <= 127);
+	CU_ASSERT_PTR_NOT_NULL(odp_sys_cpu_model_str());
+}
+
+static void test_odp_sys_page_size(void)
+{
+	uint64_t page;
+
+	page = odp_sys_page_size();
+	CU_ASSERT(0 < page);
+}
+
+static void test_odp_sys_huge_page_size(void)
+{
+	uint64_t page;
+
+	page = odp_sys_huge_page_size();
+	CU_ASSERT(0 < page || 0 == page);
+}
+
+static void test_odp_sys_cpu_hz(void)
+{
+	uint64_t hz;
+
+	hz = odp_sys_cpu_hz();
+	CU_ASSERT(0 < hz);
+}
+
+CU_TestInfo test_odp_system[] = {
+	{"odp_sys_core_count",  test_odp_sys_core_count},
+	{"odp_sys_cache_line_size",  test_odp_sys_cache_line_size},
+	{"odp_sys_cpu_model_str",  test_odp_sys_cpu_model_str},
+	{"odp_sys_page_size",  test_odp_sys_page_size},
+	{"odp_sys_huge_page_size",  test_odp_sys_huge_page_size},
+	{"odp_sys_cpu_hz",  test_odp_sys_cpu_hz},
+	CU_TEST_INFO_NULL,
+};
+
+CU_SuiteInfo odp_testsuites[] = {
+		{"System Info", NULL, NULL, NULL, NULL,
+		 test_odp_system},
+		 CU_SUITE_INFO_NULL,
+};