From 514a3fe4d3c257dededcf891735b640e1ba29fa6 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 17 May 2010 17:56:13 +0000 Subject: 2010-05-17 Bharath Suri * psxfile01/test.c, psxfile01/psxfile01.scn: This file now exercises the _rename_r in libcsupport. For now, it also provides two fsmount_me_h handlers to enable certain error checking paths --- testsuites/psxtests/ChangeLog | 7 ++ testsuites/psxtests/psxfile01/psxfile01.scn | 92 +++++++++++---- testsuites/psxtests/psxfile01/test.c | 167 +++++++++++++++++++++++++++- 3 files changed, 243 insertions(+), 23 deletions(-) (limited to 'testsuites') diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog index 7cfeac08c6..bdef401885 100644 --- a/testsuites/psxtests/ChangeLog +++ b/testsuites/psxtests/ChangeLog @@ -1,3 +1,10 @@ +2010-05-17 Bharath Suri + + * psxfile01/test.c, psxfile01/psxfile01.scn: This file now + exercises the _rename_r in libcsupport. For now, it also + provides two fsmount_me_h handlers to enable certain error + checking paths + 2010-04-28 Joel Sherrill * psxfile01/test.c: Add check for errno on chdir(NULL). diff --git a/testsuites/psxtests/psxfile01/psxfile01.scn b/testsuites/psxtests/psxfile01/psxfile01.scn index 6c4e7ef25b..350bacef42 100644 --- a/testsuites/psxtests/psxfile01/psxfile01.scn +++ b/testsuites/psxtests/psxfile01/psxfile01.scn @@ -1,8 +1,7 @@ -NOTE: If you get the following assertion, then your target does not -have enough memory in the heap used by malloc to allocate all the -files used during this test: +Could not open '/dev/kqemu' - QEMU acceleration layer not activated: No such file or directory +Initialized console on port COM1 9600-8-N-1 -assertion "memory" failed: file "...../c/src/lib/libc/memfile.c", line 340 + *** FILE TEST 1 *** *************** Dump of Entire IMFS *************** @@ -13,13 +12,15 @@ assertion "memory" failed: file "...../c/src/lib/libc/memfile.c", line 340 stat of /dev/console ....st_dev (0x0:0x0) ....st_ino 3 may vary by small amount -....mode = 00020771 +....mode = 00020755 ....nlink = 1 ....uid = 0 ....gid = 0 ....atime = Fri Jan 1 00:00:00 1988 ....mtime = Fri Jan 1 00:00:00 1988 ....ctime = Fri Jan 1 00:00:00 1988 +....st_blksize 0 +....st_blocks 0 mkdir /dev/tty @@ -54,11 +55,39 @@ tcdrain /tmp/john mknod /tmp/joel (0)the first write!!! +rename /tmp/joel to /tmp/drjoel +rename /tmp/drjoel to /tmp/joel +rename /tmp/drjoel to /tmp/joel - Should result in an error since old path is not valid +rename /tmp/joel to /tmp/drjoel/joel - Should result in an error since new path is not valid +changing dir to /tmp +rename joel to drjoel +rename drjoel to joel +creating directory /imfs +creating directory /imfs/hidden_on_mount +mounting filesystem with IMFS_ops at /imfs +creating directory /imfs/test (on newly mounted filesystem) +attempt to rename directory joel to /imfs/test/joel - should fail with EXDEV +changing dir to / +attempt to rename across filesystem, with old path having a parent node +attempt to rename tmp/joel to /imfs/test/joel +Unmounting /imfs +Mounting filesystem @ /imfs with no support for evalformake +change directory to /imfs +exercise _rename_r, with target on /imfs - expected ENOTSUP +attempt to rename /tmp/joel to joel +change directory to / +Mounting filesystem @ /imfs with no support for rename +creating directory /imfs/test +creating directory /imfs/test/old_dir +changing to / +attempt to rename imfs/old_dir to imfs/new_dir +unmounting /imfs +End of _rename_r tests (10)the first write!!! -stat( /tmp/joel ) returned +stat( /tmp/joel ) returned ....st_dev (0x0:0x0) -....st_ino 10 may vary by small amount +....st_ino 12 may vary by small amount ....mode = 00100700 ....nlink = 1 ....uid = 0 @@ -66,6 +95,8 @@ stat( /tmp/joel ) returned ....atime = Sat Dec 31 09:00:00 1988 ....mtime = Sat Dec 31 09:00:00 1988 ....ctime = Sat Dec 31 09:00:00 1988 +....st_blksize 0 +....st_blocks 0 unlink /tmp/joel unlink /tmp/joel mknod /tmp/joel @@ -85,10 +116,11 @@ mknod /tmp/joel (513)the first write!!! -(139743) -stat( /tmp/joel ) returned +Skipping maximum file size test since max_size is 4329344 bytes +That is likely to be bigger than the available RAM on many targets. +stat( /tmp/joel ) returned ....st_dev (0x0:0x0) -....st_ino 11 may vary by small amount +....st_ino 13 may vary by small amount ....mode = 00100700 ....nlink = 1 ....uid = 0 @@ -96,17 +128,21 @@ stat( /tmp/joel ) returned ....atime = Sat Dec 31 09:00:00 1988 ....mtime = Sat Dec 31 09:00:00 1988 ....ctime = Sat Dec 31 09:00:00 1988 +....st_blksize 0 +....st_blocks 0 stat of /tmp/j stat(/tmp/j) returned -1 (errno=2) ....st_dev (0x0:0x0) ....st_ino 3 may vary by small amount -....mode = 00020771 +....mode = 00020755 ....nlink = 1 ....uid = 0 ....gid = 0 ....atime = Fri Jan 1 00:00:00 1988 ....mtime = Fri Jan 1 00:00:00 1988 ....ctime = Fri Jan 1 00:00:00 1988 +....st_blksize 0 +....st_blocks 0 fopen of /tmp/j fprintf to /tmp/j (1) 26 characters written to the file @@ -115,34 +151,38 @@ fprintf to /tmp/j (4) 26 characters written to the file (5) 26 characters written to the file ....st_dev (0x0:0x0) -....st_ino 12 may vary by small amount -....mode = 00100660 +....st_ino 14 may vary by small amount +....mode = 00100644 ....nlink = 1 ....uid = 0 ....gid = 0 ....atime = Sat Dec 31 09:00:00 1988 ....mtime = Sat Dec 31 09:00:00 1988 ....ctime = Sat Dec 31 09:00:00 1988 +....st_blksize 0 +....st_blocks 0 This is call 1 to fprintf This is call 2 to fprintf This is call 3 to fprintf This is call 4 to fprintf This is call 5 to fprintf ....st_dev (0x0:0x0) -....st_ino 12 may vary by small amount -....mode = 00100660 +....st_ino 14 may vary by small amount +....mode = 00100644 ....nlink = 1 ....uid = 0 ....gid = 0 ....atime = Sat Dec 31 09:00:01 1988 ....mtime = Sat Dec 31 09:00:00 1988 ....ctime = Sat Dec 31 09:00:00 1988 +....st_blksize 0 +....st_blocks 0 *************** Dump of Entire IMFS *************** / ....dev/ ........console (device 0, 0) ........tty/ -............S3 (device 255, 128) +............S3 (device 128, 255) ........test_console (device 0, 0) ....etc/ ........passwd (file 0) @@ -150,25 +190,29 @@ This is call 5 to fprintf ........my_dir/ ........tom (file 0) ........john (file 0) -........joel (file 279487) +........joel (file 533) ........j (file 130) +....imfs/ +........hidden_on_mount/ *************** End of Dump *************** truncate /tmp/j to length of 40 ....st_dev (0x0:0x0) -....st_ino 12 may vary by small amount -....mode = 00100660 +....st_ino 14 may vary by small amount +....mode = 00100644 ....nlink = 1 ....uid = 0 ....gid = 0 ....atime = Sat Dec 31 09:00:02 1988 ....mtime = Sat Dec 31 09:00:00 1988 ....ctime = Sat Dec 31 09:00:00 1988 +....st_blksize 0 +....st_blocks 0 *************** Dump of Entire IMFS *************** / ....dev/ ........console (device 0, 0) ........tty/ -............S3 (device 255, 128) +............S3 (device 128, 255) ........test_console (device 0, 0) ....etc/ ........passwd (file 0) @@ -177,6 +221,8 @@ truncate /tmp/j to length of 40 ........tom (file 0) ........john (file 0) ........j (file 40) +....imfs/ +........hidden_on_mount/ *************** End of Dump *************** truncate /tmp/j to length of 0 truncate /tmp to length of 0 should fail with EISDIR @@ -187,7 +233,7 @@ truncate /tmp to length of 0 should fail with EISDIR ....dev/ ........console (device 0, 0) ........tty/ -............S3 (device 255, 128) +............S3 (device 128, 255) ........test_console (device 0, 0) ....etc/ ........passwd (file 0) @@ -196,6 +242,8 @@ truncate /tmp to length of 0 should fail with EISDIR ........tom (file 0) ........john (file 0) ........j (file 0) +....imfs/ +........hidden_on_mount/ *************** End of Dump *************** Writing First File Writing Second File @@ -204,5 +252,5 @@ this is a test line (0)this is a test line this is a test line -*** END OF FILE TEST 1 *** +*** END OF FILE TEST 1 *** diff --git a/testsuites/psxtests/psxfile01/test.c b/testsuites/psxtests/psxfile01/test.c index 79d115496a..69e74ca49a 100644 --- a/testsuites/psxtests/psxfile01/test.c +++ b/testsuites/psxtests/psxfile01/test.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -37,7 +38,8 @@ void test_case_reopen_append(void); char test_write_buffer[ 1024 ]; - +rtems_filesystem_operations_table IMFS_ops_no_evalformake; +rtems_filesystem_operations_table IMFS_ops_no_rename; /* * File test support routines. */ @@ -115,6 +117,30 @@ void stat_a_file( } +int no_evalformake_IMFS_initialize( + rtems_filesystem_mount_table_entry_t *temp_mt_entry +) +{ + return IMFS_initialize_support( + temp_mt_entry, + &IMFS_ops_no_evalformake, + &IMFS_memfile_handlers, + &IMFS_directory_handlers + ); +} + +int no_rename_IMFS_initialize( + rtems_filesystem_mount_table_entry_t *temp_mt_entry +) +{ + return IMFS_initialize_support( + temp_mt_entry, + &IMFS_ops_no_rename, + &IMFS_memfile_handlers, + &IMFS_directory_handlers + ); +} + /* * Main entry point of the test @@ -144,6 +170,17 @@ int main( time_t ctime2; rtems_status_code rtems_status; rtems_time_of_day time; + rtems_filesystem_mount_table_entry_t *mt_entry; + + IMFS_ops_no_evalformake = IMFS_ops; + IMFS_ops_no_rename = IMFS_ops; + + IMFS_ops_no_evalformake.fsmount_me_h = no_evalformake_IMFS_initialize; + IMFS_ops_no_evalformake.evalformake_h = NULL; + + IMFS_ops_no_rename.fsmount_me_h = no_rename_IMFS_initialize; + IMFS_ops_no_rename.rename_h = NULL; + printf( "\n\n*** FILE TEST 1 ***\n" ); @@ -336,6 +373,134 @@ int main( test_write( "/tmp/joel", 0, "the first write!!!\n" ); test_cat( "/tmp/joel", 0, 0 ); + /* Exercise _rename_r */ + + /* Simple rename test */ + puts( "rename /tmp/joel to /tmp/drjoel"); + status = _rename_r(NULL,"/tmp/joel","/tmp/drjoel"); + rtems_test_assert(status == 0); + + /* Simple rename test */ + puts("rename /tmp/drjoel to /tmp/joel"); + status = _rename_r(NULL,"/tmp/drjoel","/tmp/joel"); + rtems_test_assert(status == 0); + + /* Invalid old path */ + puts("rename /tmp/drjoel to /tmp/joel - Should result in an error \ +since old path is not valid"); + status = _rename_r(NULL,"/tmp/drjoel","/tmp/joel"); + rtems_test_assert(status == -1); + + /* Invalid new path */ + puts("rename /tmp/joel to /tmp/drjoel/joel - Should result in an error \ +since new path is not valid"); + status = _rename_r(NULL,"/tmp/joel","/tmp/drjoel/joel"); + rtems_test_assert(status == -1); + + puts("changing dir to /tmp"); + status = chdir("/tmp/"); + rtems_test_assert(status == 0); + + puts("rename joel to drjoel"); + status = _rename_r(NULL,"joel","drjoel"); + rtems_test_assert(status == 0); + + puts("rename drjoel to joel"); + status = _rename_r(NULL,"drjoel","joel"); + rtems_test_assert(status == 0); + + /* Rename across file systems */ + puts("creating directory /imfs"); + status = mkdir("/imfs",0777); + rtems_test_assert(status == 0); + puts("creating directory /imfs/hidden_on_mount"); + status = mkdir("/imfs/hidden_on_mount",0777); + rtems_test_assert(status == 0); + + puts("mounting filesystem with IMFS_ops at /imfs"); + status = mount(&mt_entry, &IMFS_ops, + RTEMS_FILESYSTEM_READ_WRITE, + NULL, "/imfs"); + rtems_test_assert(status == 0); + rtems_test_assert(mt_entry != NULL); + puts("creating directory /imfs/test (on newly mounted filesystem)"); + status = mkdir("/imfs/test", 0777); + rtems_test_assert(status == 0); + + puts("attempt to rename directory joel to /imfs/test/joel - should fail with EXDEV"); + status = _rename_r(NULL, "joel", "/imfs/test/joel"); + rtems_test_assert(status == -1); + rtems_test_assert(errno == EXDEV); + + puts("changing dir to /"); + status = chdir("/"); + rtems_test_assert(status == 0); + + puts("attempt to rename across filesystem, with old path having a parent node"); + puts("attempt to rename tmp/joel to /imfs/test/joel"); + status = _rename_r(NULL, "tmp/joel", "/imfs/test/joel"); + rtems_test_assert(status == -1); + rtems_test_assert(errno == EXDEV); + + puts("Unmounting /imfs"); + status = unmount("/imfs"); + rtems_test_assert(status == 0); + + puts("Mounting filesystem @ /imfs with no support for evalformake"); + + status = mount(&mt_entry, &IMFS_ops_no_evalformake, + RTEMS_FILESYSTEM_READ_WRITE, + NULL, "/imfs"); + rtems_test_assert(status == 0); + rtems_test_assert(mt_entry != NULL); + + puts("change directory to /imfs"); + status = chdir("/imfs"); + rtems_test_assert(status == 0); + + puts("exercise _rename_r, with target on /imfs - expected ENOTSUP"); + puts("attempt to rename /tmp/joel to joel"); + status = _rename_r(NULL, "/tmp/joel", "joel"); + rtems_test_assert(status == -1); + rtems_test_assert(errno == ENOTSUP); + + puts("change directory to /"); + status = chdir("/"); + rtems_test_assert(status == 0); + + status = unmount("/imfs"); + rtems_test_assert(status == 0); + + + puts("Mounting filesystem @ /imfs with no support for rename"); + status = mount(&mt_entry, &IMFS_ops_no_rename, + RTEMS_FILESYSTEM_READ_WRITE, + NULL, "/imfs"); + rtems_test_assert(status == 0); + rtems_test_assert(mt_entry != NULL); + + puts("creating directory /imfs/test"); + status = mkdir("/imfs/test", 0777); + rtems_test_assert(status == 0); + + puts("creating directory /imfs/test/old_dir"); + status = mkdir("/imfs/test/old_dir", 0777); + rtems_test_assert(status == 0); + + puts("changing to /"); + status = chdir("/"); + + puts("attempt to rename imfs/old_dir to imfs/new_dir"); + status = _rename_r(NULL, "imfs/test/old_dir", "imfs/test/new_dir"); + rtems_test_assert(status == -1); + rtems_test_assert(errno == ENOTSUP); + + puts("unmounting /imfs"); + status = unmount("/imfs"); + rtems_test_assert(status == 0); + + puts("End of _rename_r tests"); + /* * Test simple write to a file at a non-0 offset in the first block */ -- cgit v1.2.3