diff options
author | Joel Sherrill <joel@rtems.org> | 2016-12-05 21:06:40 -0600 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2017-01-11 09:45:32 -0600 |
commit | ef362818dff3e7dc437d90133424e9c9f0608a02 (patch) | |
tree | c6800ad8c9bcd8d9a894c48ea533c38d9eb3a962 /testsuites | |
parent | posix: Fix alarm() in SMP configurations (diff) | |
download | rtems-ef362818dff3e7dc437d90133424e9c9f0608a02.tar.bz2 |
Add support for posix_devctl()
Diffstat (limited to '')
-rw-r--r-- | testsuites/psxtests/Makefile.am | 3 | ||||
-rw-r--r-- | testsuites/psxtests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/psxtests/psxdevctl01/Makefile.am | 23 | ||||
-rw-r--r-- | testsuites/psxtests/psxdevctl01/main.c | 50 | ||||
-rw-r--r-- | testsuites/psxtests/psxdevctl01/psxdevctl01.doc | 23 | ||||
-rw-r--r-- | testsuites/psxtests/psxdevctl01/psxdevctl01.scn | 4 | ||||
-rw-r--r-- | testsuites/psxtests/psxdevctl01/test.c | 81 | ||||
-rw-r--r-- | testsuites/psxtests/psxhdrs/Makefile.am | 3 | ||||
-rw-r--r-- | testsuites/psxtests/psxhdrs/devctl/posix_devctl.c | 37 |
9 files changed, 225 insertions, 0 deletions
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index 0ff5cb300e..40faa61a4f 100644 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -27,6 +27,9 @@ _SUBDIRS += psxfile01 psxfile02 psxfilelock01 psxgetrusage01 psxid01 \ psximfs01 psximfs02 psxreaddir psxstat psxmount psx13 psxchroot01 \ psxpasswd01 psxpasswd02 psxpipe01 psxtimes01 psxfchx01 +## POSIX Devctl tests +_SUBDIRS += psxdevctl01 + ## POSIX Keys are always available _SUBDIRS += psxkey01 psxkey02 psxkey03 psxkey04 \ psxkey05 psxkey06 psxkey08 psxkey09 psxkey10 diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac index 29f9a192fa..6b12e4903a 100644 --- a/testsuites/psxtests/configure.ac +++ b/testsuites/psxtests/configure.ac @@ -147,6 +147,7 @@ psxconcurrency01/Makefile psxcond01/Makefile psxcond02/Makefile psxconfig01/Makefile +psxdevctl01/Makefile psxeintr_join/Makefile psxenosys/Makefile psxfatal01/Makefile 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 <bsp.h> +#include <pmacros.h> + +/* 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 <rtems/confdefs.h> +/* 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 <errno.h> +#include <sys/ioctl.h> +#include <stdlib.h> + +#include <devctl.h> + +#include <unistd.h> +#include <fcntl.h> + +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); +} diff --git a/testsuites/psxtests/psxhdrs/Makefile.am b/testsuites/psxtests/psxhdrs/Makefile.am index 82fb315b19..e902500b9d 100644 --- a/testsuites/psxtests/psxhdrs/Makefile.am +++ b/testsuites/psxtests/psxhdrs/Makefile.am @@ -1,6 +1,9 @@ noinst_LIBRARIES = lib.a lib_a_SOURCES = +# methods in <devctl.h> +lib_a_SOURCES += devctl/posix_devctl.c + # methods in <pthread.h> lib_a_SOURCES += pthread/pthread_attr_destroy.c lib_a_SOURCES += pthread/pthread_attr_getdetachstate.c diff --git a/testsuites/psxtests/psxhdrs/devctl/posix_devctl.c b/testsuites/psxtests/psxhdrs/devctl/posix_devctl.c new file mode 100644 index 0000000000..3a40c7869a --- /dev/null +++ b/testsuites/psxtests/psxhdrs/devctl/posix_devctl.c @@ -0,0 +1,37 @@ +/* + * 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 _POSIX_26_C_SOURCE + +#include <devctl.h> + +int test( void ); + +int test( void ) +{ + int result; + int fd; + int dcmd; + void *dev_data_ptr; + size_t nbyte; + int dev_info; + + fd = -1; + dcmd = 0; + dev_data_ptr = NULL; + nbyte = 0; + + result = posix_devctl(fd, dcmd, dev_data_ptr, nbyte, &dev_info); + + return result; +} |