From 3951d4da6fc4885dd450e5257d7273ab6a392492 Mon Sep 17 00:00:00 2001 From: Ryan Long Date: Mon, 23 Aug 2021 12:43:23 -0400 Subject: pxcdevctl: Adjust for standard psxdevctl is supposed to return the value in errno. Before, it was returning -1 and setting errno. Changed the tests to reflect these changes. Added code from RRADE's posix_devctl.c. Closes #4506 --- testsuites/psxtests/psxdevctl01/test.c | 69 ++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 23 deletions(-) (limited to 'testsuites/psxtests') diff --git a/testsuites/psxtests/psxdevctl01/test.c b/testsuites/psxtests/psxdevctl01/test.c index b45725cb58..2fe7df1834 100644 --- a/testsuites/psxtests/psxdevctl01/test.c +++ b/testsuites/psxtests/psxdevctl01/test.c @@ -53,37 +53,16 @@ int main( 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 ); - puts( "posix_devctl() SOCKCLOSE on invalid file descriptor -- EBADF" ); - fd = 21; + fd = -1; 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 ); + rtems_test_assert( status == EBADF ); /* * Create a file, open it, and close it via posix_devctl(). @@ -102,6 +81,50 @@ int main( status = close( fd ); rtems_test_assert( status == -1 ); rtems_test_assert( errno == EBADF ); + + puts( "posix_devctl() FIONBIO with invalid nbyte -- EINVAL" ); + fd = 0; + dcmd = FIONBIO; + dev_data_ptr = NULL; + nbyte = 0; + status = posix_devctl( fd, dcmd, dev_data_ptr, nbyte, NULL ); + rtems_test_assert( status == EINVAL ); + + puts( "posix_devctl() FIONBIO with invalid file descriptor -- EBADF" ); + fd = -1; + dcmd = FIONBIO; + dev_data_ptr = NULL; + nbyte = sizeof(int); + status = posix_devctl( fd, dcmd, dev_data_ptr, nbyte, NULL ); + rtems_test_assert( status == EBADF ); + + puts( "posix_devctl() FIONBIO flag not zero -- 0" ); + fd = 0; + dcmd = FIONBIO; + dev_data = 1; + dev_data_ptr = &dev_data; + nbyte = sizeof(int); + status = posix_devctl( fd, dcmd, dev_data_ptr, nbyte, NULL ); + rtems_test_assert( status == 0 ); + + puts( "posix_devctl() FIONBIO flag is zero -- 0" ); + fd = 0; + dcmd = FIONBIO; + dev_data = 0; + dev_data_ptr = &dev_data; + nbyte = sizeof(int); + status = posix_devctl( fd, dcmd, dev_data_ptr, nbyte, NULL ); + rtems_test_assert( status == 0 ); + + puts( "posix_devctl() dcmd not valid value -- EBADF" ); + fd = 0; + dcmd = 1; + dev_data = 0; + dev_data_ptr = &dev_data; + nbyte = sizeof(int); + status = posix_devctl( fd, dcmd, dev_data_ptr, nbyte, NULL ); + rtems_test_assert( status == EBADF ); + TEST_END(); exit(0); } -- cgit v1.2.3