diff mbox

[API-NEXT,PATCHv3,1/2] validation: system: make odp_cpu_hz optional in validation test

Message ID 1454510770-11548-1-git-send-email-maxim.uvarov@linaro.org
State Accepted
Commit 70ee2827864ae5395f2141da3092e2e74f524d92
Headers show

Commit Message

Maxim Uvarov Feb. 3, 2016, 2:46 p.m. UTC
Do not fail if odp_cpu_hz() returns 0, just skip the test.

Suggested-by: Petri Savolainen <petri.savolainen@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 test/validation/system/system.c | 22 ++++++++++++++++++----
 test/validation/system/system.h |  4 ++++
 2 files changed, 22 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/test/validation/system/system.c b/test/validation/system/system.c
index c72590b..942905a 100644
--- a/test/validation/system/system.c
+++ b/test/validation/system/system.c
@@ -214,12 +214,25 @@  void system_test_odp_sys_huge_page_size(void)
 	CU_ASSERT(0 < page);
 }
 
+int system_check_odp_cpu_hz(void)
+{
+	if (odp_cpu_hz() == 0) {
+		fprintf(stderr, "odp_cpu_hz is not supported, skipping\n");
+		return -1;
+	}
+
+	return 0;
+}
+
 void system_test_odp_cpu_hz(void)
 {
-	uint64_t hz;
+	uint64_t hz = odp_cpu_hz();
 
-	hz = odp_cpu_hz();
-	CU_ASSERT(0 < hz);
+	/* Test value sanity: less than 10GHz */
+	CU_ASSERT(hz < 10 * GIGA_HZ);
+
+	/* larger than 1kHz */
+	CU_ASSERT(hz > 1 * KILO_HZ);
 }
 
 void system_test_odp_cpu_hz_id(void)
@@ -270,7 +283,8 @@  odp_testinfo_t system_suite[] = {
 	ODP_TEST_INFO(system_test_odp_cpu_model_str_id),
 	ODP_TEST_INFO(system_test_odp_sys_page_size),
 	ODP_TEST_INFO(system_test_odp_sys_huge_page_size),
-	ODP_TEST_INFO(system_test_odp_cpu_hz),
+	ODP_TEST_INFO_CONDITIONAL(system_test_odp_cpu_hz,
+				  system_check_odp_cpu_hz),
 	ODP_TEST_INFO(system_test_odp_cpu_hz_id),
 	ODP_TEST_INFO(system_test_odp_cpu_hz_max),
 	ODP_TEST_INFO(system_test_odp_cpu_hz_max_id),
diff --git a/test/validation/system/system.h b/test/validation/system/system.h
index c5f3058..a258933 100644
--- a/test/validation/system/system.h
+++ b/test/validation/system/system.h
@@ -9,6 +9,9 @@ 
 
 #include <odp_cunit_common.h>
 
+#define GIGA_HZ 1000000000ULL
+#define KILO_HZ 1000ULL
+
 /* test functions: */
 void system_test_odp_version_numbers(void);
 void system_test_odp_cpu_count(void);
@@ -17,6 +20,7 @@  void system_test_odp_cpu_model_str(void);
 void system_test_odp_cpu_model_str_id(void);
 void system_test_odp_sys_page_size(void);
 void system_test_odp_sys_huge_page_size(void);
+int system_check_odp_cpu_hz(void);
 void system_test_odp_cpu_hz(void);
 void system_test_odp_cpu_hz_id(void);
 void system_test_odp_cpu_hz_max(void);