summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxdevctl01
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/psxtests/psxdevctl01')
-rw-r--r--testsuites/psxtests/psxdevctl01/main.c2
-rw-r--r--testsuites/psxtests/psxdevctl01/psxdevctl01.doc8
-rw-r--r--testsuites/psxtests/psxdevctl01/psxdevctl01.scn4
-rw-r--r--testsuites/psxtests/psxdevctl01/test.c26
4 files changed, 38 insertions, 2 deletions
diff --git a/testsuites/psxtests/psxdevctl01/main.c b/testsuites/psxtests/psxdevctl01/main.c
index d74fb6b102..54776e2b24 100644
--- a/testsuites/psxtests/psxdevctl01/main.c
+++ b/testsuites/psxtests/psxdevctl01/main.c
@@ -39,6 +39,8 @@ rtems_task Init(
#define CONFIGURE_MAXIMUM_TASKS 1
+#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 4
+
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
diff --git a/testsuites/psxtests/psxdevctl01/psxdevctl01.doc b/testsuites/psxtests/psxdevctl01/psxdevctl01.doc
index fee22d237d..51f295d2f1 100644
--- a/testsuites/psxtests/psxdevctl01/psxdevctl01.doc
+++ b/testsuites/psxtests/psxdevctl01/psxdevctl01.doc
@@ -19,5 +19,11 @@ 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
++ Ensure that a request is passed through the underlying ioctl() operation
to the console device driver and flagged as an error.
+
++ Ensure that the SOCKCLOSE subcommand is supported by posix_devctl()
+ and returns an error on invalid file descriptors.
+
++ Ensure that the SOCKCLOSE subcommand is supported by posix_devctl()
+ and will close a file descriptor.
diff --git a/testsuites/psxtests/psxdevctl01/psxdevctl01.scn b/testsuites/psxtests/psxdevctl01/psxdevctl01.scn
index 1df1d7e6e8..440046300d 100644
--- a/testsuites/psxtests/psxdevctl01/psxdevctl01.scn
+++ b/testsuites/psxtests/psxdevctl01/psxdevctl01.scn
@@ -1,4 +1,6 @@
*** BEGIN OF TEST PSXDEVCTL 1 ***
posix_devctl() FIONBIO on stdin return dev_info -- EBADF
-posix_devctl() FIONBIO on stdin return dev_info -- EBADF
+posix_devctl() FIONBIO on stdin NULL dev_info -- EBADF
+posix_devctl() SOCKCLOSE on invalid file descriptor -- EBADF
+posix_devctl() SOCKCLOSE on valid file descriptor -- OK
*** END OF TEST PSXDEVCTL 1 ***
diff --git a/testsuites/psxtests/psxdevctl01/test.c b/testsuites/psxtests/psxdevctl01/test.c
index ed22ba8410..b45725cb58 100644
--- a/testsuites/psxtests/psxdevctl01/test.c
+++ b/testsuites/psxtests/psxdevctl01/test.c
@@ -76,6 +76,32 @@ int main(
rtems_test_assert( status == -1 );
rtems_test_assert( errno == EBADF );
+ puts( "posix_devctl() SOCKCLOSE on invalid file descriptor -- EBADF" );
+ fd = 21;
+ dcmd = SOCKCLOSE;
+ 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 );
+
+ /*
+ * Create a file, open it, and close it via posix_devctl().
+ * Then verify it is really closed.
+ */
+ puts( "posix_devctl() SOCKCLOSE on valid file descriptor -- OK" );
+ fd = open("tmp_for_close", O_CREAT | O_RDWR, S_IRWXU );
+ rtems_test_assert( fd != -1 );
+
+ dcmd = SOCKCLOSE;
+ dev_data_ptr = NULL;
+ nbyte = 0;
+ status = posix_devctl( fd, dcmd, dev_data_ptr, nbyte, NULL );
+ rtems_test_assert( status == 0 );
+
+ status = close( fd );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EBADF );
TEST_END();
exit(0);
}