[PATCH] New fstest to check rename POSIX conformance

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Feb 21 08:12:58 UTC 2014


On 2014-02-20 00:36, Andre Marques wrote:
>>>
>>>>
>>>>>
>>>>> - Testing errno values in error situations. There is already a fstest named
>>>>> fserror which purpose seems to be checking errno values for a bunch of
>>>>> functions (rename included, but with some errno values missing). Not sure
>>>>> if I
>>>>> should put them in this test or add to fserror.
>>>>
>>>> I would move all rename related tests to this new test program.
>>>
>>> About the errno value testing, I'm currently missing EIO, ENOSPC, EROFS and
>>> EXDEV.
>>>
>>> EROFS and EXDEV require mounting a second filesystem. How can I do this in
>>> RTEMS? Can it be done at runtime? I've been looking at the fileio sample, which
>>> uses the fsmount() function, but I need a disk to mount with it.
>>
>> For EROFS there is already a test in fstests/fsrofs01.
>>
>
> So I leave EROFS out of this test?

Yes, I would leave the EROFS test out.

>
>> You can mount as many file system instances as you want.  You can do this
>> with mount().  The mount() parameters are file system dependent. The generic
>> file system tests (and your rename test should be one of them) use a support
>> file for this:
>>
>> ./testsuites/fstests/mrfs_support/fs_support.c
>> ./testsuites/fstests/mimfs_support/fs_support.c
>> ./testsuites/fstests/mdosfs_support/fs_support.c
>> ./testsuites/fstests/imfs_support/fs_support.c
>> ./testsuites/fstests/jffs2_support/fs_support.c
>
> Yes I'm using support files on Makefile.am.
>
> For mount() should I use a ramdisk for the device file?
>
> I tried to create a ramdisk as in
>
> http://www.rtems.org/onlinedocs/doxygen/cpukit/html/group__rtems__ramdisk.html#gac6c99eed9f3b92bb4cf5184b25972e65
>
>
> but the program exits during the rtems_blkdev_create() call, if I use
> "/dev/rda" as the device path.

How does the code look like?

>
>>
>> You can use the system file system as the second file system for the EXDEV test.
>>
>
> I'm reading this as mounting an instance of the system filesystem. Am I right?

You need two file system instances.  If you configure the system with 
CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM, then it starts with the IMFS as the root 
file system.  For the file system tests you need a file system instance to 
test.  This is set up with the test_initialize_filesystem() function, e.g.

void test_initialize_filesystem(void)
{
   int rv;

   erase_all();

   rv = mkdir(BASE_FOR_TEST, S_IRWXU | S_IRWXG | S_IRWXO);
   rtems_test_assert(rv == 0);

   rtems_resource_snapshot_take(&before_mount);

   rv = mount(
     NULL,
     BASE_FOR_TEST,
     RTEMS_FILESYSTEM_TYPE_JFFS2,
     RTEMS_FILESYSTEM_READ_WRITE,
     &mount_data
   );
   rtems_test_assert(rv == 0);
}

void test_shutdown_filesystem(void)
{
   int rv = unmount(BASE_FOR_TEST);
   rtems_test_assert(rv == 0);
   rtems_test_assert(rtems_resource_snapshot_check(&before_mount));
}

So for the EXDEV test you can use for example:

rename("/abc.txt", BASE_FOR_TEST "/abc.txt");

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list