diff mbox

[2/2] valididation: errno: add sunnyday test

Message ID 1424711740-21699-2-git-send-email-mike.holmes@linaro.org
State New
Headers show

Commit Message

Mike Holmes Feb. 23, 2015, 5:15 p.m. UTC
Call the public APIs for errno in a sunny day configuration.

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 test/validation/.gitignore  |  1 +
 test/validation/Makefile.am |  5 +++--
 test/validation/odp_errno.c | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 2 deletions(-)
 create mode 100644 test/validation/odp_errno.c

Comments

Mike Holmes Feb. 24, 2015, 1:33 p.m. UTC | #1
I though that for "0" we might standardize, obviously the errors may vary.

But if there is no consistency at all, then we will have to just leave it
with very weak checking OR starting implementing OS specific tests.

For now I will just make the testing  very weak.


On 24 February 2015 at 08:07, Savolainen, Petri (Nokia - FI/Espoo) <
petri.savolainen@nokia.com> wrote:

>
>
> > -----Original Message-----
> > From: ext Mike Holmes [mailto:mike.holmes@linaro.org]
> > Sent: Monday, February 23, 2015 7:16 PM
> > To: lng-odp@lists.linaro.org
> > Cc: petri.savolainen@linaro.org; Mike Holmes
> > Subject: [PATCH 2/2] valididation: errno: add sunnyday test
> >
> > Call the public APIs for errno in a sunny day configuration.
> >
> > Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> > ---
> >  test/validation/.gitignore  |  1 +
> >  test/validation/Makefile.am |  5 +++--
> >  test/validation/odp_errno.c | 32 ++++++++++++++++++++++++++++++++
> >  3 files changed, 36 insertions(+), 2 deletions(-)
> >  create mode 100644 test/validation/odp_errno.c
> >
> > diff --git a/test/validation/.gitignore b/test/validation/.gitignore
> > index 197b094..9c2ff37 100644
> > --- a/test/validation/.gitignore
> > +++ b/test/validation/.gitignore
> > @@ -14,3 +14,4 @@ odp_buffer
> >  odp_timer
> >  odp_time
> >  odp_synchronizers
> > +odp_errno
> > diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
> > index f9d7d7a..f808aba 100644
> > --- a/test/validation/Makefile.am
> > +++ b/test/validation/Makefile.am
> > @@ -6,17 +6,18 @@ AM_LDFLAGS += -static
> >  TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform}
> >
> >  if test_vald
> > -TESTS = odp_init odp_init_abort odp_init_log odp_queue odp_crypto
> odp_shm
> > odp_schedule odp_pktio_run odp_buffer odp_system odp_timer odp_time
> > odp_synchronizers odp_classification
> > +TESTS = odp_init odp_init_abort odp_init_log odp_queue odp_crypto
> odp_shm
> > odp_schedule odp_pktio_run odp_buffer odp_system odp_timer odp_time
> > odp_synchronizers odp_classification odp_errno
> >  endif
> >
> >  dist_bin_SCRIPTS = $(srcdir)/odp_pktio_run
> >
> > -bin_PROGRAMS = odp_init odp_init_abort odp_init_log odp_queue odp_crypto
> > odp_shm odp_schedule odp_pktio odp_buffer odp_system odp_timer odp_time
> > odp_synchronizers odp_classification
> > +bin_PROGRAMS = odp_init odp_init_abort odp_init_log odp_queue odp_crypto
> > odp_shm odp_schedule odp_pktio  odp_buffer odp_system odp_timer odp_time
> > odp_synchronizers odp_classification odp_errno
> >  odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
> >  odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer
> >  odp_classification_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/classification
> >
> >  dist_odp_init_SOURCES = odp_init.c
> > +dist_odp_errno_SOURCES = odp_errno.c common/odp_cunit_common.c
> >  dist_odp_init_abort_SOURCES = odp_init_abort.c
> >  dist_odp_pktio_SOURCES = odp_pktio.c common/odp_cunit_common.c
> >  dist_odp_queue_SOURCES = odp_queue.c common/odp_cunit_common.c
> > diff --git a/test/validation/odp_errno.c b/test/validation/odp_errno.c
> > new file mode 100644
> > index 0000000..4e292e6
> > --- /dev/null
> > +++ b/test/validation/odp_errno.c
> > @@ -0,0 +1,32 @@
> > +/* Copyright (c) 2015, Linaro Limited
> > + * All rights reserved.
> > + *
> > + * SPDX-License-Identifier:     BSD-3-Clause
> > + */
> > +
> > +#include <odp.h>
> > +#include "odp_cunit_common.h"
> > +
> > +#define ERR_STR_LEN 128
> > +static void test_odp_errno_sunny_day(void)
> > +{
> > +     int my_errno;
> > +     char my_error_string[ERR_STR_LEN];
> > +     odp_errno_zero();
> > +     my_errno = odp_errno();
> > +     CU_ASSERT_TRUE(my_errno == 0);
> > +     odp_errno_print("odp_errno");
> > +
> > +     strncpy(my_error_string, odp_errno_str(my_errno), ERR_STR_LEN-1);
> > +     CU_ASSERT_STRING_EQUAL(my_error_string, "Success");
>
> The content of error message string is implementation specific. So, cannot
> expect that string is always "Success".
>
> -Petri
>
> > +}
> > +
> > +CU_TestInfo test_odp_errno[] = {
> > +     {"sunny day", test_odp_errno_sunny_day},
> > +     CU_TEST_INFO_NULL,
> > +};
> > +
> > +CU_SuiteInfo odp_testsuites[] = {
> > +     {"Errno", NULL, NULL, NULL, NULL, test_odp_errno},
> > +     CU_SUITE_INFO_NULL,
> > +};
> > --
> > 2.1.0
>
>
diff mbox

Patch

diff --git a/test/validation/.gitignore b/test/validation/.gitignore
index 197b094..9c2ff37 100644
--- a/test/validation/.gitignore
+++ b/test/validation/.gitignore
@@ -14,3 +14,4 @@  odp_buffer
 odp_timer
 odp_time
 odp_synchronizers
+odp_errno
diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index f9d7d7a..f808aba 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -6,17 +6,18 @@  AM_LDFLAGS += -static
 TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform}
 
 if test_vald
-TESTS = odp_init odp_init_abort odp_init_log odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run odp_buffer odp_system odp_timer odp_time odp_synchronizers odp_classification
+TESTS = odp_init odp_init_abort odp_init_log odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run odp_buffer odp_system odp_timer odp_time odp_synchronizers odp_classification odp_errno
 endif
 
 dist_bin_SCRIPTS = $(srcdir)/odp_pktio_run
 
-bin_PROGRAMS = odp_init odp_init_abort odp_init_log odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system odp_timer odp_time odp_synchronizers odp_classification
+bin_PROGRAMS = odp_init odp_init_abort odp_init_log odp_queue odp_crypto odp_shm odp_schedule odp_pktio  odp_buffer odp_system odp_timer odp_time odp_synchronizers odp_classification odp_errno
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
 odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer
 odp_classification_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/classification
 
 dist_odp_init_SOURCES = odp_init.c
+dist_odp_errno_SOURCES = odp_errno.c common/odp_cunit_common.c
 dist_odp_init_abort_SOURCES = odp_init_abort.c
 dist_odp_pktio_SOURCES = odp_pktio.c common/odp_cunit_common.c
 dist_odp_queue_SOURCES = odp_queue.c common/odp_cunit_common.c
diff --git a/test/validation/odp_errno.c b/test/validation/odp_errno.c
new file mode 100644
index 0000000..4e292e6
--- /dev/null
+++ b/test/validation/odp_errno.c
@@ -0,0 +1,32 @@ 
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <odp.h>
+#include "odp_cunit_common.h"
+
+#define ERR_STR_LEN 128
+static void test_odp_errno_sunny_day(void)
+{
+	int my_errno;
+	char my_error_string[ERR_STR_LEN];
+	odp_errno_zero();
+	my_errno = odp_errno();
+	CU_ASSERT_TRUE(my_errno == 0);
+	odp_errno_print("odp_errno");
+
+	strncpy(my_error_string, odp_errno_str(my_errno), ERR_STR_LEN-1);
+	CU_ASSERT_STRING_EQUAL(my_error_string, "Success");
+}
+
+CU_TestInfo test_odp_errno[] = {
+	{"sunny day", test_odp_errno_sunny_day},
+	CU_TEST_INFO_NULL,
+};
+
+CU_SuiteInfo odp_testsuites[] = {
+	{"Errno", NULL, NULL, NULL, NULL, test_odp_errno},
+	CU_SUITE_INFO_NULL,
+};