From 58c5a9b59ee083506b3030e823539636a932a3b8 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Sat, 7 Aug 2010 00:24:48 +0000 Subject: 2010-08-06 Bharath Suri PR 1654/testing * deviceio01/init.c, deviceio01/deviceio01.doc, deviceio01/deviceio01.scn, deviceio01/test_driver.c, deviceio01/test_driver.h, deviceio01/Makefile.am: New test added. * Makefile.am, configure.ac: Changes to added above test. * tar02/init.c, tar02/tar02.scn: New test case added: IMFS_dump(). --- testsuites/libtests/deviceio01/.cvsignore | 2 + testsuites/libtests/deviceio01/Makefile.am | 24 ++++ testsuites/libtests/deviceio01/deviceio01.doc | 28 ++++ testsuites/libtests/deviceio01/deviceio01.scn | 7 + testsuites/libtests/deviceio01/init.c | 78 +++++++++++ testsuites/libtests/deviceio01/test_driver.c | 190 ++++++++++++++++++++++++++ testsuites/libtests/deviceio01/test_driver.h | 64 +++++++++ 7 files changed, 393 insertions(+) create mode 100644 testsuites/libtests/deviceio01/.cvsignore create mode 100644 testsuites/libtests/deviceio01/Makefile.am create mode 100644 testsuites/libtests/deviceio01/deviceio01.doc create mode 100644 testsuites/libtests/deviceio01/deviceio01.scn create mode 100644 testsuites/libtests/deviceio01/init.c create mode 100644 testsuites/libtests/deviceio01/test_driver.c create mode 100644 testsuites/libtests/deviceio01/test_driver.h (limited to 'testsuites/libtests/deviceio01') diff --git a/testsuites/libtests/deviceio01/.cvsignore b/testsuites/libtests/deviceio01/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/libtests/deviceio01/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/libtests/deviceio01/Makefile.am b/testsuites/libtests/deviceio01/Makefile.am new file mode 100644 index 0000000000..1f8c7281c8 --- /dev/null +++ b/testsuites/libtests/deviceio01/Makefile.am @@ -0,0 +1,24 @@ +## +## $Id$ +## + +rtems_tests_PROGRAMS = deviceio01 +deviceio01_SOURCES = init.c test_driver.c + +dist_rtems_tests_DATA = deviceio01.scn +dist_rtems_tests_DATA += deviceio01.doc + +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)/../support/include + +LINK_OBJS = $(deviceio01_OBJECTS) $(deviceio01_LDADD) +LINK_LIBS = $(deviceio01_LDLIBS) + +deviceio01$(EXEEXT): $(deviceio01_OBJECTS) $(deviceio01_DEPENDENCIES) + @rm -f deviceio01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/libtests/deviceio01/deviceio01.doc b/testsuites/libtests/deviceio01/deviceio01.doc new file mode 100644 index 0000000000..0769865d13 --- /dev/null +++ b/testsuites/libtests/deviceio01/deviceio01.doc @@ -0,0 +1,28 @@ +# +# $Id$ +# +# COPYRIGHT (c) 1989-2010. +# 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.com/license/LICENSE. +# + +This file describes the directives and concepts tested by this test set. + +test set name: devfs04 + +directives: + ++ device_read ++ device_write ++ device_ioctl + +concepts: + ++ Custom driver for a device /dev/test lets us exercise the error +paths in the read / write routines for devFS. These are invoked using +the system calls read() and write(). + ++ Mostly hits the error paths in the above mentioned routines diff --git a/testsuites/libtests/deviceio01/deviceio01.scn b/testsuites/libtests/deviceio01/deviceio01.scn new file mode 100644 index 0000000000..6c39feb7c1 --- /dev/null +++ b/testsuites/libtests/deviceio01/deviceio01.scn @@ -0,0 +1,7 @@ +*** TEST DEVICEIO - 01 *** +Init - attempt to open the /dev/test WR mode -- OK +Init - attempt to write to /dev/test - expect ENOSYS +Init - attempt to open the /dev/test RD mode -- OK +Init - attempt to read from /dev/test - expect ENOSYS +Init - attempt ioctl on the device - expect ENOSYS +*** END OF TEST DEVICEIO - 01 *** diff --git a/testsuites/libtests/deviceio01/init.c b/testsuites/libtests/deviceio01/init.c new file mode 100644 index 0000000000..f1ff982429 --- /dev/null +++ b/testsuites/libtests/deviceio01/init.c @@ -0,0 +1,78 @@ +/* + * COPYRIGHT (c) 1989-2010. + * 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.com/license/LICENSE. + * + * $Id$ + */ + +#include +#include "test_support.h" +#include +#include +#include +#include +#include +#include +#include "test_driver.h" +#include + +rtems_task Init( + rtems_task_argument argument +) +{ + int status; + int fdr = 0, fdw = 0; + char buf[10]; + + puts( "\n\n*** TEST DEVICEIO - 01 ***" ); + + puts( "Init - attempt to open the /dev/test WR mode -- OK" ); + fdw = open( "/dev/test", O_WRONLY ); + rtems_test_assert( fdw != -1 ); + + puts( "Init - attempt to write to /dev/test - expect ENOSYS" ); + status = write( fdw, "data", 10 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == ENOSYS ); + + puts( "Init - attempt to open the /dev/test RD mode -- OK" ); + fdr = open( "/dev/test", O_RDONLY ); + rtems_test_assert( fdr != -1 ); + + puts( "Init - attempt to read from /dev/test - expect ENOSYS" ); + status = read( fdr, buf, 10 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == ENOSYS ); + + puts( "Init - attempt ioctl on the device - expect ENOSYS" ); + status = ioctl( fdr, -1 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == ENOSYS ); + + puts( "*** END OF TEST DEVICEIO - 01 ***" ); + rtems_test_exit(0); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_EXTRA_DRIVERS TEST_DRIVER_TABLE_ENTRY + +/* include an extra slot for registering the termios one dynamically */ +#define CONFIGURE_MAXIMUM_DRIVERS 3 + +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5 + +#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM + +#define CONFIGURE_INIT +#include +/* end of file */ diff --git a/testsuites/libtests/deviceio01/test_driver.c b/testsuites/libtests/deviceio01/test_driver.c new file mode 100644 index 0000000000..b02852cb1e --- /dev/null +++ b/testsuites/libtests/deviceio01/test_driver.c @@ -0,0 +1,190 @@ +/* + * COPYRIGHT (c) 1989-2010. + * 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "test_driver.h" +#include +#include +/* + * The test driver routines are mostly derived from the null driver routines. + */ +uint32_t TEST_major; +static char initialized; + +/* testDriver_initialize + * + * This routine is the test device driver init routine. + * + * Input parameters: + * major - device major number + * minor - device minor number + * pargp - pointer to parameter block + * + * Output parameters: + * rval - RTEMS_SUCCESSFUL + */ +rtems_device_driver testDriver_initialize( + rtems_device_major_number major, + rtems_device_minor_number minor __attribute__((unused)), + void *pargp __attribute__((unused)) +) +{ + rtems_device_driver status; + + if ( !initialized ) { + initialized = 1; + + status = rtems_io_register_name( + "/dev/test", + major, + (rtems_device_minor_number) 0 + ); + + if (status != RTEMS_SUCCESSFUL) + rtems_fatal_error_occurred(status); + + TEST_major = major; + } + + return RTEMS_SUCCESSFUL; +} + +/* testDriver_open + * + * This routine is the test device driver open routine. + * + * Input parameters: + * major - device major number + * minor - device minor number + * pargb - pointer to open parameter block + * + * Output parameters: + * rval - RTEMS_SUCCESSFUL + */ +rtems_device_driver testDriver_open( + rtems_device_major_number major __attribute__((unused)), + rtems_device_minor_number minor __attribute__((unused)), + void *pargp __attribute__((unused)) +) +{ + return RTEMS_SUCCESSFUL; +} + +/* testDriver_close + * + * This routine is the test device driver close routine. + * + * Input parameters: + * major - device major number + * minor - device minor number + * pargb - pointer to close parameter block + * + * Output parameters: + * rval - RTEMS_SUCCESSFUL + */ +rtems_device_driver testDriver_close( + rtems_device_major_number major __attribute__((unused)), + rtems_device_minor_number minor __attribute__((unused)), + void *pargp __attribute__((unused)) +) +{ + return RTEMS_SUCCESSFUL; +} + +/* testDriver_read + * + * This routine is the test device driver read routine. + * + * Input parameters: + * major - device major number + * minor - device minor number + * pargp - pointer to read parameter block + * + * Output parameters: + * rval - RTEMS_SUCCESSFUL + */ +rtems_device_driver testDriver_read( + rtems_device_major_number major __attribute__((unused)), + rtems_device_minor_number minor __attribute__((unused)), + void *pargp +) +{ + rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *) pargp; + + if ( rw_args ) { + if( rw_args->count == 5 ) + rw_args->bytes_moved = 0; + else { + rw_args->bytes_moved = 0; + return RTEMS_NOT_IMPLEMENTED; + } + } + + return RTEMS_SUCCESSFUL; +} + +/* testDriver_write + * + * This routine is the test device driver write routine. + * + * Input parameters: + * major - device major number + * minor - device minor number + * pargp - pointer to write parameter block + * + * Output parameters: + * rval - RTEMS_SUCCESSFUL + */ +rtems_device_driver testDriver_write( + rtems_device_major_number major __attribute__((unused)), + rtems_device_minor_number minor __attribute__((unused)), + void *pargp +) +{ + rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *) pargp; + + if ( rw_args ) { + if( rw_args->count == 5 ) + return null_write( 0, 0, pargp ); + else { + rw_args->bytes_moved = 0; + return RTEMS_NOT_IMPLEMENTED; + } + } + + return RTEMS_SUCCESSFUL; +} + +/* testDriver_control + * + * This routine is the test device driver control routine. + * + * Input parameters: + * major - device major number + * minor - device minor number + * pargp - pointer to cntrl parameter block + * + * Output parameters: + * rval - RTEMS_SUCCESSFUL + */ + +rtems_device_driver testDriver_control( + rtems_device_major_number major __attribute__((unused)), + rtems_device_minor_number minor __attribute__((unused)), + void *pargp __attribute__((unused)) +) +{ + return RTEMS_NOT_IMPLEMENTED; +} diff --git a/testsuites/libtests/deviceio01/test_driver.h b/testsuites/libtests/deviceio01/test_driver.h new file mode 100644 index 0000000000..999e60c3cc --- /dev/null +++ b/testsuites/libtests/deviceio01/test_driver.h @@ -0,0 +1,64 @@ +/* + * COPYRIGHT (c) 1989-2010. + * 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef __TEST_DRIVER_h +#define __TEST_DRIVER_h + +#ifdef __cplusplus +extern "C" { +#endif + +#define TEST_DRIVER_TABLE_ENTRY \ + { testDriver_initialize, testDriver_open, testDriver_close, testDriver_read, \ + testDriver_write, testDriver_control } + +rtems_device_driver testDriver_initialize( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +rtems_device_driver testDriver_open( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +rtems_device_driver testDriver_close( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +rtems_device_driver testDriver_read( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +rtems_device_driver testDriver_write( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +rtems_device_driver testDriver_control( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ -- cgit v1.2.3