2010-05-17 Bharath Suri <bharath.s.jois@gmail.com>

* 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
This commit is contained in:
Joel Sherrill committed 2010-05-17 17:56:13 +00:00
1 parent 377c0cb0e3
commit 514a3fe4d3
3 files changed
+243 -23

No files matched your search

+7
View File
@@ -1,3 +1,10 @@
2010-05-17 Bharath Suri <bharath.s.jois@gmail.com>
* 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 <joel.sherrill@oarcorp.com>
* psxfile01/test.c: Add check for errno on chdir(NULL).
File diff suppressed because it is too large. Load diff
+166 -1
View File
@@ -30,6 +30,7 @@
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <rtems/imfs.h>
#include <rtems.h>
#include <rtems/libio.h>
@@ -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
*/