diff mbox

validation: add odp_system test

Message ID 1417015419-20842-1-git-send-email-mike.holmes@linaro.org
State Superseded
Headers show

Commit Message

Mike Holmes Nov. 26, 2014, 3:23 p.m. UTC
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 test/validation/.gitignore   |   1 +
 test/validation/Makefile.am  |   4 +-
 test/validation/odp_system.c | 114 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 118 insertions(+), 1 deletion(-)
 create mode 100644 test/validation/odp_system.c

Comments

Maxim Uvarov Nov. 27, 2014, 11:11 a.m. UTC | #1
Needed update this patch.

Maxim.

On 11/26/2014 06:23 PM, Mike Holmes wrote:
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>   test/validation/.gitignore   |   1 +
>   test/validation/Makefile.am  |   4 +-
>   test/validation/odp_system.c | 114 +++++++++++++++++++++++++++++++++++++++++++
>   3 files changed, 118 insertions(+), 1 deletion(-)
>   create mode 100644 test/validation/odp_system.c
>
> diff --git a/test/validation/.gitignore b/test/validation/.gitignore
> index 2917c66..ba204a0 100644
> --- a/test/validation/.gitignore
> +++ b/test/validation/.gitignore
> @@ -3,4 +3,5 @@
>   odp_init
>   odp_queue
>   odp_crypto
> +odp_system
>   CUnit-Memory-Dump.xml
> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
> index 0b831d0..c991900 100644
> --- a/test/validation/Makefile.am
> +++ b/test/validation/Makefile.am
> @@ -6,11 +6,12 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
>   if ODP_CUNIT_ENABLED
>   TESTS = ${bin_PROGRAMS}
>   check_PROGRAMS = ${bin_PROGRAMS}
> -bin_PROGRAMS = odp_init odp_queue odp_crypto
> +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_system
>   odp_init_LDFLAGS = $(AM_LDFLAGS)
>   odp_queue_LDFLAGS = $(AM_LDFLAGS)
>   odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
>   odp_crypto_LDFLAGS = $(AM_LDFLAGS)
> +odp_system_LDFLAGS = $(AM_LDFLAGS)
>   endif
>   
>   dist_odp_init_SOURCES = odp_init.c
> @@ -18,3 +19,4 @@ dist_odp_queue_SOURCES = odp_queue.c
>   dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
>   			  crypto/odp_crypto_test_sync_inp.c \
>   			  odp_crypto.c
> +dist_odp_system_SOURCES = odp_system.c
> diff --git a/test/validation/odp_system.c b/test/validation/odp_system.c
> new file mode 100644
> index 0000000..abcc746
> --- /dev/null
> +++ b/test/validation/odp_system.c
> @@ -0,0 +1,114 @@
> +/* Copyright (c) 2014, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:     BSD-3-Clause
> + */
> +
> +#include "odp.h"
> +#include "CUnit/Basic.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)
> +{
> +	uint64_t cache_size;
> +
> +	cache_size = odp_sys_cache_line_size();
> +	CU_ASSERT(0 < cache_size)
> +}
> +
> +static void test_odp_sys_cpu_model_str(void)
> +{
> +	char model[64];
> +
> +	strcpy(model, odp_sys_cpu_model_str());
> +	CU_ASSERT(strlen(model) > 0)
> +	CU_ASSERT(strlen(model) < 127)
> +}
> +
> +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)
> +}
> +
> +static void test_odp_sys_cpu_hz(void)
> +{
> +	uint64_t hz;
> +
> +	hz = odp_sys_cpu_hz();
> +	CU_ASSERT(0 < hz)
> +}
> +
> +static int init_suite(void)
> +{
> +	printf("\tODP API version: %s\n", odp_version_api_str());
> +	printf("\tODP implementation version: %s\n", odp_version_impl_str());
> +
> +	if (odp_init_global(NULL, NULL)) {
> +		printf("ODP global init failed.\n");
> +		return -1;
> +	}
> +	odp_init_local();
> +
> +	return 0;
> +}
> +
> +static int finalise(void)
> +{
> +	odp_term_local();
> +	odp_term_global();
> +
> +	return 0;
> +}
> +
> +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 suites[] = {
> +		{"odp_system", init_suite, finalise, NULL, NULL,
> +		 test_odp_system},
> +		 CU_SUITE_INFO_NULL,
> +};
> +
> +
> +int main(void)
> +{
> +	int ret;
> +
> +	CU_set_error_action(CUEA_ABORT);
> +
> +	CU_initialize_registry();
> +	CU_register_suites(suites);
> +	CU_basic_set_mode(CU_BRM_VERBOSE);
> +	CU_basic_run_tests();
> +
> +	ret = CU_get_number_of_failure_records();
> +
> +	CU_cleanup_registry();
> +
> +	return ret;
> +}
Ciprian Barbu Nov. 27, 2014, 11:36 a.m. UTC | #2
On Thu, Nov 27, 2014 at 1:11 PM, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
> Needed update this patch.

Something wrong with .gitignore, I removed that from patch and it
applied. But it wouldn't hurt to send an updated version, there may
have been an intermediate patch that was not pushed to upstream yet.

>
> Maxim.
>
>
> On 11/26/2014 06:23 PM, Mike Holmes wrote:
>>
>> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
>> ---
>>   test/validation/.gitignore   |   1 +
>>   test/validation/Makefile.am  |   4 +-
>>   test/validation/odp_system.c | 114
>> +++++++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 118 insertions(+), 1 deletion(-)
>>   create mode 100644 test/validation/odp_system.c
>>
>> diff --git a/test/validation/.gitignore b/test/validation/.gitignore
>> index 2917c66..ba204a0 100644
>> --- a/test/validation/.gitignore
>> +++ b/test/validation/.gitignore
>> @@ -3,4 +3,5 @@
>>   odp_init
>>   odp_queue
>>   odp_crypto
>> +odp_system
>>   CUnit-Memory-Dump.xml
>> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
>> index 0b831d0..c991900 100644
>> --- a/test/validation/Makefile.am
>> +++ b/test/validation/Makefile.am
>> @@ -6,11 +6,12 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
>>   if ODP_CUNIT_ENABLED
>>   TESTS = ${bin_PROGRAMS}
>>   check_PROGRAMS = ${bin_PROGRAMS}
>> -bin_PROGRAMS = odp_init odp_queue odp_crypto
>> +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_system
>>   odp_init_LDFLAGS = $(AM_LDFLAGS)
>>   odp_queue_LDFLAGS = $(AM_LDFLAGS)
>>   odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
>>   odp_crypto_LDFLAGS = $(AM_LDFLAGS)
>> +odp_system_LDFLAGS = $(AM_LDFLAGS)
>>   endif
>>     dist_odp_init_SOURCES = odp_init.c
>> @@ -18,3 +19,4 @@ dist_odp_queue_SOURCES = odp_queue.c
>>   dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
>>                           crypto/odp_crypto_test_sync_inp.c \
>>                           odp_crypto.c
>> +dist_odp_system_SOURCES = odp_system.c
>> diff --git a/test/validation/odp_system.c b/test/validation/odp_system.c
>> new file mode 100644
>> index 0000000..abcc746
>> --- /dev/null
>> +++ b/test/validation/odp_system.c
>> @@ -0,0 +1,114 @@
>> +/* Copyright (c) 2014, Linaro Limited
>> + * All rights reserved.
>> + *
>> + * SPDX-License-Identifier:     BSD-3-Clause
>> + */
>> +
>> +#include "odp.h"
>> +#include "CUnit/Basic.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)
>> +{
>> +       uint64_t cache_size;
>> +
>> +       cache_size = odp_sys_cache_line_size();
>> +       CU_ASSERT(0 < cache_size)
>> +}
>> +
>> +static void test_odp_sys_cpu_model_str(void)
>> +{
>> +       char model[64];
>> +
>> +       strcpy(model, odp_sys_cpu_model_str());
>> +       CU_ASSERT(strlen(model) > 0)
>> +       CU_ASSERT(strlen(model) < 127)
>> +}
>> +
>> +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)
>> +}
>> +
>> +static void test_odp_sys_cpu_hz(void)
>> +{
>> +       uint64_t hz;
>> +
>> +       hz = odp_sys_cpu_hz();
>> +       CU_ASSERT(0 < hz)
>> +}
>> +
>> +static int init_suite(void)
>> +{
>> +       printf("\tODP API version: %s\n", odp_version_api_str());
>> +       printf("\tODP implementation version: %s\n",
>> odp_version_impl_str());
>> +
>> +       if (odp_init_global(NULL, NULL)) {
>> +               printf("ODP global init failed.\n");
>> +               return -1;
>> +       }
>> +       odp_init_local();
>> +
>> +       return 0;
>> +}
>> +
>> +static int finalise(void)
>> +{
>> +       odp_term_local();
>> +       odp_term_global();
>> +
>> +       return 0;
>> +}
>> +
>> +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 suites[] = {
>> +               {"odp_system", init_suite, finalise, NULL, NULL,
>> +                test_odp_system},
>> +                CU_SUITE_INFO_NULL,
>> +};
>> +
>> +
>> +int main(void)
>> +{
>> +       int ret;
>> +
>> +       CU_set_error_action(CUEA_ABORT);
>> +
>> +       CU_initialize_registry();
>> +       CU_register_suites(suites);
>> +       CU_basic_set_mode(CU_BRM_VERBOSE);
>> +       CU_basic_run_tests();
>> +
>> +       ret = CU_get_number_of_failure_records();
>> +
>> +       CU_cleanup_registry();
>> +
>> +       return ret;
>> +}
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/test/validation/.gitignore b/test/validation/.gitignore
index 2917c66..ba204a0 100644
--- a/test/validation/.gitignore
+++ b/test/validation/.gitignore
@@ -3,4 +3,5 @@ 
 odp_init
 odp_queue
 odp_crypto
+odp_system
 CUnit-Memory-Dump.xml
diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 0b831d0..c991900 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -6,11 +6,12 @@  AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
 if ODP_CUNIT_ENABLED
 TESTS = ${bin_PROGRAMS}
 check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init odp_queue odp_crypto
+bin_PROGRAMS = odp_init odp_queue odp_crypto odp_system
 odp_init_LDFLAGS = $(AM_LDFLAGS)
 odp_queue_LDFLAGS = $(AM_LDFLAGS)
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
 odp_crypto_LDFLAGS = $(AM_LDFLAGS)
+odp_system_LDFLAGS = $(AM_LDFLAGS)
 endif
 
 dist_odp_init_SOURCES = odp_init.c
@@ -18,3 +19,4 @@  dist_odp_queue_SOURCES = odp_queue.c
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
 			  crypto/odp_crypto_test_sync_inp.c \
 			  odp_crypto.c
+dist_odp_system_SOURCES = odp_system.c
diff --git a/test/validation/odp_system.c b/test/validation/odp_system.c
new file mode 100644
index 0000000..abcc746
--- /dev/null
+++ b/test/validation/odp_system.c
@@ -0,0 +1,114 @@ 
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include "odp.h"
+#include "CUnit/Basic.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)
+{
+	uint64_t cache_size;
+
+	cache_size = odp_sys_cache_line_size();
+	CU_ASSERT(0 < cache_size)
+}
+
+static void test_odp_sys_cpu_model_str(void)
+{
+	char model[64];
+
+	strcpy(model, odp_sys_cpu_model_str());
+	CU_ASSERT(strlen(model) > 0)
+	CU_ASSERT(strlen(model) < 127)
+}
+
+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)
+}
+
+static void test_odp_sys_cpu_hz(void)
+{
+	uint64_t hz;
+
+	hz = odp_sys_cpu_hz();
+	CU_ASSERT(0 < hz)
+}
+
+static int init_suite(void)
+{
+	printf("\tODP API version: %s\n", odp_version_api_str());
+	printf("\tODP implementation version: %s\n", odp_version_impl_str());
+
+	if (odp_init_global(NULL, NULL)) {
+		printf("ODP global init failed.\n");
+		return -1;
+	}
+	odp_init_local();
+
+	return 0;
+}
+
+static int finalise(void)
+{
+	odp_term_local();
+	odp_term_global();
+
+	return 0;
+}
+
+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 suites[] = {
+		{"odp_system", init_suite, finalise, NULL, NULL,
+		 test_odp_system},
+		 CU_SUITE_INFO_NULL,
+};
+
+
+int main(void)
+{
+	int ret;
+
+	CU_set_error_action(CUEA_ABORT);
+
+	CU_initialize_registry();
+	CU_register_suites(suites);
+	CU_basic_set_mode(CU_BRM_VERBOSE);
+	CU_basic_run_tests();
+
+	ret = CU_get_number_of_failure_records();
+
+	CU_cleanup_registry();
+
+	return ret;
+}