From 99e6fb5244c6c99341fed54bbc4cfbd2fcc4d8f5 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Sat, 7 Aug 2010 00:22:46 +0000 Subject: 2010-08-06 Bharath Suri PR 1654/testing * psx13/test.c, psx13/psx13.scn: Test case to improve testing of dup2 routine. * psxfile01/test.c, psxfile01/psxfile01.scn: New test to improve testing of fcntl routine. * psximfs01/init.c, psximfs01/psximfs01.scn: Improve testing of imfs routines. * psximfs02/init.c, psximfs02/psximfs02.scn: Improve coverage of imfs routines. * psxpasswd02/init.c, psxpasswd02/psxpasswd02.scn: New tests to improve coverage of getpwent.c. --- testsuites/psxtests/ChangeLog | 14 +++++++++++++ testsuites/psxtests/psx13/psx13.scn | 3 +-- testsuites/psxtests/psx13/test.c | 6 ++++-- testsuites/psxtests/psxfile01/psxfile01.scn | 10 +++++----- testsuites/psxtests/psxfile01/test.c | 6 +++++- testsuites/psxtests/psximfs01/init.c | 10 +++++++++- testsuites/psxtests/psximfs01/psximfs01.scn | 2 ++ testsuites/psxtests/psximfs02/init.c | 16 +++++++++++++++ testsuites/psxtests/psximfs02/psximfs02.scn | 7 +++++-- testsuites/psxtests/psxpasswd02/init.c | 26 +++++++++++++++++++++++++ testsuites/psxtests/psxpasswd02/psxpasswd02.scn | 2 ++ 11 files changed, 89 insertions(+), 13 deletions(-) (limited to 'testsuites/psxtests') diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog index 29e3d9b8d0..87ba141db7 100644 --- a/testsuites/psxtests/ChangeLog +++ b/testsuites/psxtests/ChangeLog @@ -1,3 +1,17 @@ +2010-08-06 Bharath Suri + + PR 1654/testing + * psx13/test.c, psx13/psx13.scn: Test case to improve testing of + dup2 routine. + * psxfile01/test.c, psxfile01/psxfile01.scn: New test to improve + testing of fcntl routine. + * psximfs01/init.c, psximfs01/psximfs01.scn: Improve testing of + imfs routines. + * psximfs02/init.c, psximfs02/psximfs02.scn: Improve coverage of + imfs routines. + * psxpasswd02/init.c, psxpasswd02/psxpasswd02.scn: New tests to + improve coverage of getpwent.c. + 2010-08-06 Ralf Corsépius PR 1652/GCC: diff --git a/testsuites/psxtests/psx13/psx13.scn b/testsuites/psxtests/psx13/psx13.scn index 0194805536..428a9316a7 100644 --- a/testsuites/psxtests/psx13/psx13.scn +++ b/testsuites/psxtests/psx13/psx13.scn @@ -1,10 +1,9 @@ - *** POSIX TEST 13 *** Files initialized successfully. Testing device_lseek()... Failed!!! Testing dup()............ Failed!!! -Testing dup2()........... Failed!!! +Testing dup2()........... Success. Testing fdatasync()...... Success. Testing umask().......... Success. Testing utime().......... Success. diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index cc8b09e710..cda50fe1ab 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -142,7 +142,7 @@ int DeviceLSeekTest (void) else retval = FALSE; - /* assert (retval == TRUE);*/ + close( fd ); /* assert (retval == TRUE);*/ return (retval); } @@ -187,6 +187,8 @@ int DupTest(void) else retval = FALSE; + close( fd1 ); + close( fd2 ); /* assert (retval == TRUE);*/ return (retval); @@ -257,7 +259,7 @@ int Dup2Test(void) } close (fd1); - + close (fd2); /* assert (retval == TRUE);*/ return (retval); diff --git a/testsuites/psxtests/psxfile01/psxfile01.scn b/testsuites/psxtests/psxfile01/psxfile01.scn index 3fc7522b86..06542ae317 100644 --- a/testsuites/psxtests/psxfile01/psxfile01.scn +++ b/testsuites/psxtests/psxfile01/psxfile01.scn @@ -1,10 +1,9 @@ - *** FILE TEST 1 *** *************** Dump of Entire IMFS *************** / ....dev/ ........console (device 0, 0) -*************** End of Dump *************** +*************** End of Dump *************** stat of /dev/console ....st_dev (0xfffe:0x0) ....st_ino 3 may vary by small amount @@ -55,6 +54,7 @@ Exercise the reentrant version _link_r -- Expect ENOENT Unlink /tmp/bha using the reentrant version -- OK mknod with bad type - expect EINVAL open /tmp/bha in write only mode -- OK +attempt fcntl on opened file -- OK attempt to read from /tmp/bha - expect EINVAL closing and unlinking /tmp/bha open /tmp/bha in read only mode -- OK @@ -192,7 +192,7 @@ This is call 5 to fprintf ........j (file 130) ....imfs/ ........hidden_on_mount/ -*************** End of Dump *************** +*************** End of Dump *************** truncate /tmp/j to length of 40 ....st_dev (0xfffe:0x0) ....st_ino 17 may vary by small amount @@ -221,7 +221,7 @@ truncate /tmp/j to length of 40 ........j (file 40) ....imfs/ ........hidden_on_mount/ -*************** End of Dump *************** +*************** End of Dump *************** truncate /tmp/j to length of 0 truncate /tmp to length of 0 should fail with EISDIR @@ -242,7 +242,7 @@ truncate /tmp to length of 0 should fail with EISDIR ........j (file 0) ....imfs/ ........hidden_on_mount/ -*************** End of Dump *************** +*************** End of Dump *************** Writing First File Writing Second File (0)this is a test line diff --git a/testsuites/psxtests/psxfile01/test.c b/testsuites/psxtests/psxfile01/test.c index aa194dccd1..352ac084fb 100644 --- a/testsuites/psxtests/psxfile01/test.c +++ b/testsuites/psxtests/psxfile01/test.c @@ -374,7 +374,11 @@ int main( puts( "open /tmp/bha in write only mode -- OK" ); fd = open( "/tmp/bha", O_CREAT | O_WRONLY, S_IRWXU|S_IRWXG|S_IRWXO ); rtems_test_assert( fd != -1 ); - + + puts( "attempt fcntl on opened file -- OK" ); + status = fcntl( fd, F_SETFD, 0 ); + rtems_test_assert( status == 0 ); + puts( "attempt to read from /tmp/bha - expect EINVAL" ); status = read( fd, buffer, 10 ); rtems_test_assert( status == -1 ); diff --git a/testsuites/psxtests/psximfs01/init.c b/testsuites/psxtests/psximfs01/init.c index a70cd8371b..8ca65bb0c7 100644 --- a/testsuites/psxtests/psximfs01/init.c +++ b/testsuites/psxtests/psximfs01/init.c @@ -147,7 +147,6 @@ void extend_helper(void) position = lseek( TestFd, 0, SEEK_END ); printf( "Seek to end .. returned %d\n", (int) position ); - rtems_test_assert( position == 1 ); /* * test case to ftruncate a file to a length > its size @@ -179,6 +178,7 @@ void extend_helper(void) rc, strerror( errno ) ); + break; } else { break; @@ -216,6 +216,8 @@ rtems_task Init( int i; void *alloc_ptr = (void *)0; Heap_Information_block Info; + int position = 0; + int status = 0; puts( "\n\n*** TEST IMFS 01 ***" ); @@ -248,6 +250,12 @@ rtems_task Init( */ free(alloc_ptr); + extend_helper(); + position = lseek( TestFd , 0, SEEK_END ); + status = lseek( TestFd, position+2, SEEK_SET ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == ENOSPC ); + close_it(); unlink_it(); diff --git a/testsuites/psxtests/psximfs01/psximfs01.scn b/testsuites/psxtests/psximfs01/psximfs01.scn index 0b516f8f25..5ae790a56d 100644 --- a/testsuites/psxtests/psximfs01/psximfs01.scn +++ b/testsuites/psxtests/psximfs01/psximfs01.scn @@ -14,6 +14,8 @@ Seek to end .. returned 1280 lseek/ftruncate loop.. Seek to end .. returned 1 lseek/ftruncate loop.. +Seek to end .. returned 1295 +lseek/ftruncate loop.. close(biggie) - OK unlink(biggie) - OK *** END OF TEST IMFS 01 *** diff --git a/testsuites/psxtests/psximfs02/init.c b/testsuites/psxtests/psximfs02/init.c index 132e546c86..7482fbc528 100644 --- a/testsuites/psxtests/psximfs02/init.c +++ b/testsuites/psxtests/psximfs02/init.c @@ -161,6 +161,22 @@ rtems_task Init( IMFS_dump(); + puts( "chown /fifo to 10 -- OK" ); + status = chown( "/fifo", 10, 10 ); + rtems_test_assert( status == 0 ); + + puts( "Changing euid to 10" ); + status = seteuid( 10 ); + rtems_test_assert( status == 0 ); + + puts( "chmod /fifo -- OK" ); + status = chmod( "/fifo", S_IRWXU ); + rtems_test_assert( status == 0 ); + + printk( "chown /fifo to %o -- OK", 0 ); + status = chown( "/fifo", 0, 0 ); + rtems_test_assert( status == 0 ); + puts( "*** END OF TEST IMFS 02 ***" ); rtems_test_exit(0); } diff --git a/testsuites/psxtests/psximfs02/psximfs02.scn b/testsuites/psxtests/psximfs02/psximfs02.scn index 60fda98a4d..4a5ac027e1 100644 --- a/testsuites/psxtests/psximfs02/psximfs02.scn +++ b/testsuites/psxtests/psximfs02/psximfs02.scn @@ -57,5 +57,8 @@ Creating a fifo -- OK ....node-link links not printed ....node-slink links not printed ....fifo FIFO not printed -*************** End of Dump *************** -*** END OF TEST IMFS 02 *** +*************** End of Dump *************** +chown /fifo to 10 -- OK +Changing euid to 10 +chmod /fifo -- OK +chown /fifo to 0 -- OK*** END OF TEST IMFS 02 *** diff --git a/testsuites/psxtests/psxpasswd02/init.c b/testsuites/psxtests/psxpasswd02/init.c index 48b66196b1..2a78becfaf 100644 --- a/testsuites/psxtests/psxpasswd02/init.c +++ b/testsuites/psxtests/psxpasswd02/init.c @@ -17,6 +17,7 @@ #include #include #include +#include void print_passwd( struct passwd *pw @@ -63,6 +64,9 @@ rtems_task Init( struct passwd *pw; struct group *gr; int status = -1; + char str[100] = {0}; + int max_int = INT_MAX; + int limit_value = 0; FILE *fp = NULL; @@ -127,6 +131,28 @@ rtems_task Init( rtems_test_assert( !pw ); rtems_test_assert( errno == EINVAL ); + fp = fopen( "/etc/passwd", "w" ); + rtems_test_assert( fp != NULL ); + fprintf( fp, "user:x:999999999999:1:dummy::/:/bin/sh\n" ); + fclose( fp ); + + puts( "Init - getpwnam(\"root\") -- expected EINVAL" ); + pw = getpwnam( "root" ); + rtems_test_assert( !pw ); + rtems_test_assert( errno == EINVAL ); + + sprintf( str, "user:x:%d%d:1:dummy::/:/bin/sh\n", max_int/10, max_int%10+1 ); + + fp = fopen( "/etc/passwd", "w" ); + rtems_test_assert( fp != NULL ); + fprintf( fp, str ); + fclose( fp ); + + puts( "Init - getpwnam(\"root\") -- expected EINVAL" ); + pw = getpwnam( "root" ); + rtems_test_assert( !pw ); + rtems_test_assert( errno == EINVAL ); + puts( "Init - getgrent() -- OK" ); gr = getgrent(); rtems_test_assert( gr != NULL ); diff --git a/testsuites/psxtests/psxpasswd02/psxpasswd02.scn b/testsuites/psxtests/psxpasswd02/psxpasswd02.scn index 21b661d391..99d2be5635 100644 --- a/testsuites/psxtests/psxpasswd02/psxpasswd02.scn +++ b/testsuites/psxtests/psxpasswd02/psxpasswd02.scn @@ -9,6 +9,8 @@ Init - setgrent() -- OK Init - getpwnam("root") -- expected EINVAL Init - getpwnam("root") -- expected EINVAL Init - getpwnam("root") -- expected EINVAL +Init - getpwnam("root") -- expected EINVAL +Init - getpwnam("root") -- expected EINVAL Init - getgrent() -- OK group name: admin group password: -- cgit v1.2.3