diff mbox

[v2] validation: add odp_system test

Message ID 1418416829-23031-1-git-send-email-mike.holmes@linaro.org
State Changes Requested
Headers show

Commit Message

Mike Holmes Dec. 12, 2014, 8:40 p.m. UTC
Add tests for ODP system_info interface

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---

This api has poor documentaion, these testis attempt to do something sensible
against linux-generic in its present form.

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

Comments

Mike Holmes Dec. 15, 2014, 4:46 p.m. UTC | #1
On 15 December 2014 at 01:35, Jerin Jacob <jerin.jacob@caviumnetworks.com>
wrote:
>
> On Fri, Dec 12, 2014 at 03:40:29PM -0500, Mike Holmes wrote:
> > Add tests for ODP system_info interface
> >
> > Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> > ---
> >
> > This api has poor documentaion, these testis attempt to do something
> sensible
> > against linux-generic in its present form.
> >
> >  test/validation/.gitignore   |  1 +
> >  test/validation/Makefile.am  |  4 ++-
> >  test/validation/odp_system.c | 73
> ++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 77 insertions(+), 1 deletion(-)
> >  create mode 100644 test/validation/odp_system.c
> >
> > 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..dfad677
> > --- /dev/null
> > +++ b/test/validation/odp_system.c
> > @@ -0,0 +1,73 @@
> > +/* 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);
>
> May be we can add one more assert here,
> CU_ASSERT(ODP_CACHE_LINE_SIZE == cache_size)
>
>
Will fix, linux-generic already does this check already, I will take
another pass at trying to get the documentation for these functions to
describe their behaviour. Presumably all implementations to perform this
check at init time ?


> > +}
> > +
> > +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,
> > +};
> > --
> > 2.1.0
> >
> >
> > _______________________________________________
> > 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 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..dfad677
--- /dev/null
+++ b/test/validation/odp_system.c
@@ -0,0 +1,73 @@ 
+/* 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);
+}
+
+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,
+};