summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-07-09 11:15:53 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-07-09 12:07:49 +0200
commit32fc6a349014cbc9324721d4cda79bfdc08283b3 (patch)
treebe31cc0826fa4856013d46b3a82f681cf69e14ea
parenttermios: PR2153: New low-level device API (diff)
downloadrtems-32fc6a349014cbc9324721d4cda79bfdc08283b3.tar.bz2
termios: PR1279: Use set attributes status
-rw-r--r--cpukit/libcsupport/src/termios.c6
-rw-r--r--testsuites/libtests/termios01/init.c63
2 files changed, 67 insertions, 2 deletions
diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c
index afc466e888..b70060dd85 100644
--- a/cpukit/libcsupport/src/termios.c
+++ b/cpukit/libcsupport/src/termios.c
@@ -889,8 +889,10 @@ rtems_termios_ioctl (void *arg)
}
}
}
- if (tty->handler.set_attributes)
- (*tty->handler.set_attributes)(tty, &tty->termios);
+ if (tty->handler.set_attributes) {
+ sc = (*tty->handler.set_attributes)(tty, &tty->termios) ?
+ RTEMS_SUCCESSFUL : RTEMS_IO_ERROR;
+ }
break;
case RTEMS_IO_TCDRAIN:
diff --git a/testsuites/libtests/termios01/init.c b/testsuites/libtests/termios01/init.c
index 8c3ed92a9c..5010c38a05 100644
--- a/testsuites/libtests/termios01/init.c
+++ b/testsuites/libtests/termios01/init.c
@@ -605,6 +605,68 @@ static void test_device_install_remove(void)
rtems_test_assert( rtems_resource_snapshot_check( &snapshot ) );
}
+static bool set_attributes_error(
+ rtems_termios_tty *tty,
+ const struct termios *term
+)
+{
+ bool *done = rtems_termios_get_device_context( tty );
+
+ (void) term;
+
+ *done = true;
+
+ return false;
+}
+
+static void test_set_attributes_error(void)
+{
+ static const rtems_termios_device_handler handler = {
+ .set_attributes = set_attributes_error
+ };
+ static const rtems_device_major_number major = 123456789;
+ static const rtems_device_minor_number minor = 0xdeadbeef;
+ static const char dev[] = "/foobar";
+
+ rtems_resource_snapshot snapshot;
+ rtems_status_code sc;
+ rtems_libio_t iop;
+ rtems_libio_open_close_args_t oc_args;
+ rtems_libio_ioctl_args_t io_args;
+ struct termios term;
+ bool done = false;
+
+ rtems_resource_snapshot_take( &snapshot );
+
+ sc = rtems_termios_device_install( &dev[0], major, minor, &handler, &done );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+
+ memset( &iop, 0, sizeof( iop ) );
+ memset( &oc_args, 0, sizeof( oc_args ) );
+ oc_args.iop = &iop;
+
+ sc = rtems_termios_device_open( major, minor, &oc_args );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+
+ memset( &io_args, 0, sizeof( io_args ) );
+ io_args.iop = &iop;
+ io_args.command = RTEMS_IO_SET_ATTRIBUTES;
+ io_args.buffer = &term;
+
+ rtems_test_assert( !done );
+ sc = rtems_termios_ioctl( &io_args );
+ rtems_test_assert( sc == RTEMS_IO_ERROR );
+ rtems_test_assert( done );
+
+ sc = rtems_termios_device_close( &oc_args );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+
+ sc = rtems_termios_device_remove( &dev[0], major, minor );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+
+ rtems_test_assert( rtems_resource_snapshot_check( &snapshot ) );
+}
+
static rtems_task Init(
rtems_task_argument ignored
)
@@ -759,6 +821,7 @@ static rtems_task Init(
puts( "" );
test_device_install_remove();
+ test_set_attributes_error();
TEST_END();
rtems_test_exit(0);