From ef362818dff3e7dc437d90133424e9c9f0608a02 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 5 Dec 2016 21:06:40 -0600 Subject: Add support for posix_devctl() --- testsuites/psxtests/psxdevctl01/Makefile.am | 23 +++++++ testsuites/psxtests/psxdevctl01/main.c | 50 +++++++++++++++ testsuites/psxtests/psxdevctl01/psxdevctl01.doc | 23 +++++++ testsuites/psxtests/psxdevctl01/psxdevctl01.scn | 4 ++ testsuites/psxtests/psxdevctl01/test.c | 81 +++++++++++++++++++++++++ 5 files changed, 181 insertions(+) create mode 100644 testsuites/psxtests/psxdevctl01/Makefile.am create mode 100644 testsuites/psxtests/psxdevctl01/main.c create mode 100644 testsuites/psxtests/psxdevctl01/psxdevctl01.doc create mode 100644 testsuites/psxtests/psxdevctl01/psxdevctl01.scn create mode 100644 testsuites/psxtests/psxdevctl01/test.c (limited to 'testsuites/psxtests/psxdevctl01') diff --git a/testsuites/psxtests/psxdevctl01/Makefile.am b/testsuites/psxtests/psxdevctl01/Makefile.am new file mode 100644 index 0000000000..3bc9bdc988 --- /dev/null +++ b/testsuites/psxtests/psxdevctl01/Makefile.am @@ -0,0 +1,23 @@ + +rtems_tests_PROGRAMS = psxdevctl01 +psxdevctl01_SOURCES = main.c test.c ../include/pmacros.h + +dist_rtems_tests_DATA = psxdevctl01.scn + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + + +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(psxdevctl01_OBJECTS) +LINK_LIBS = $(psxdevctl01_LDLIBS) + +psxdevctl01$(EXEEXT): $(psxdevctl01_OBJECTS) \ + $(psxdevctl01_DEPENDENCIES) + @rm -f psxdevctl01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtests/psxdevctl01/main.c b/testsuites/psxtests/psxdevctl01/main.c new file mode 100644 index 0000000000..2228551f1d --- /dev/null +++ b/testsuites/psxtests/psxdevctl01/main.c @@ -0,0 +1,50 @@ +/** + * @file + * + * Test program wrapper for POSIX Devctl + */ + +/* + * COPYRIGHT (c) 2016. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#define CONFIGURE_INIT + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +/* forward declarations to avoid warnings */ +rtems_task Init(rtems_task_argument ignored); +void test_main(void); + +rtems_task Init( + rtems_task_argument ignored +) +{ + test_main(); + rtems_test_exit( 0 ); +} + +/* configuration information */ +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 1 + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include +/* end of file */ diff --git a/testsuites/psxtests/psxdevctl01/psxdevctl01.doc b/testsuites/psxtests/psxdevctl01/psxdevctl01.doc new file mode 100644 index 0000000000..fee22d237d --- /dev/null +++ b/testsuites/psxtests/psxdevctl01/psxdevctl01.doc @@ -0,0 +1,23 @@ +# COPYRIGHT (c) 2016. +# On-Line Applications Research Corporation (OAR). +# +# The license and distribution terms for this file may be +# found in the file LICENSE in this distribution or at +# http://www.rtems.org/license/LICENSE. +# + +This file describes the directives and concepts tested by this test set. + +test set name: psxdevctl01 + +directives: + + posix_devctl + +concepts: + ++ Ensure that proper error values result when passing different combinations of + arguments to posix_devctl(). + ++ Ensure that a requestn is passed through the underlying ioctl() operation + to the console device driver and flagged as an error. diff --git a/testsuites/psxtests/psxdevctl01/psxdevctl01.scn b/testsuites/psxtests/psxdevctl01/psxdevctl01.scn new file mode 100644 index 0000000000..1df1d7e6e8 --- /dev/null +++ b/testsuites/psxtests/psxdevctl01/psxdevctl01.scn @@ -0,0 +1,4 @@ +*** BEGIN OF TEST PSXDEVCTL 1 *** +posix_devctl() FIONBIO on stdin return dev_info -- EBADF +posix_devctl() FIONBIO on stdin return dev_info -- EBADF +*** END OF TEST PSXDEVCTL 1 *** diff --git a/testsuites/psxtests/psxdevctl01/test.c b/testsuites/psxtests/psxdevctl01/test.c new file mode 100644 index 0000000000..423e8c50b8 --- /dev/null +++ b/testsuites/psxtests/psxdevctl01/test.c @@ -0,0 +1,81 @@ +/** + * @file + * + * This test exercises the posix_devctl() method. + */ + +/* + * COPYRIGHT (c) 2016. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define TESTS_USE_PRINTK +#define _POSIX_26_C_SOURCE +#include "tmacros.h" +#include +#include +#include + +#include + +#include +#include + +const char rtems_test_name[] = "PSXDEVCTL 1"; + +/* forward declarations to avoid warnings */ +int test_main(void); + +/* + * main entry point to the test + */ + +#if defined(__rtems__) +int test_main(void) +#else +int main( + int argc, + char **argv +) +#endif +{ + int status; + int fd; + int dcmd; + int dev_data; + void *dev_data_ptr; + size_t nbyte; + int dev_info; + + TEST_BEGIN(); + + puts( "posix_devctl() FIONBIO on stdin return dev_info -- EBADF" ); + fd = 0; + dcmd = FIONBIO; + dev_data_ptr = &dev_data; + nbyte = sizeof(dev_data); + status = posix_devctl( fd, dcmd, dev_data_ptr, nbyte, &dev_info ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EBADF ); + rtems_test_assert( dev_info == 0 ); + + puts( "posix_devctl() FIONBIO on stdin NULL dev_info -- EBADF" ); + fd = 0; + dcmd = FIONBIO; + dev_data_ptr = NULL; + nbyte = 0; + status = posix_devctl( fd, dcmd, dev_data_ptr, nbyte, NULL ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EBADF ); + + TEST_END(); + exit(0); +} -- cgit v1.2.3