summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests
diff options
context:
space:
mode:
authorRyan Long <ryan.long@oarcorp.com>2021-08-23 12:43:23 -0400
committerJoel Sherrill <joel@rtems.org>2021-09-20 13:31:25 -0500
commit3951d4da6fc4885dd450e5257d7273ab6a392492 (patch)
tree7d764039952c2a270170a4dbfcf2402992ddc675 /testsuites/psxtests
parentpowerpc/motorola_powerpc: Map LibBSD bus space to the PCI base address (diff)
downloadrtems-3951d4da6fc4885dd450e5257d7273ab6a392492.tar.bz2
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
Diffstat (limited to 'testsuites/psxtests')
-rw-r--r--testsuites/psxtests/psxdevctl01/test.c69
1 files changed, 46 insertions, 23 deletions
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);
}