[PATCH] New fstest to check rename POSIX conformance

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Feb 10 08:14:13 UTC 2014


Hello Andre,

thanks for the test case.

On 2014-02-08 13:26, Andre Marques wrote:
> Hi,
>
> As discussed in [1], I created a new fstest to check the rename()
> implementation against the POSIX specification [2].
>
> What the attached patch does not test:
>
> - Testing the existance of a link visible to other processes during the rename
> process (ensuring that there is always a reference to the file). Not sure about
> the best way to test this.

The file system instance is locked during the rename operation, so other 
threads cannot interfere here.

What happens if you rename a file with an open file descriptor should be tested.

>
> - Testing that after all processes close their references to a file after it
> was removed by rename() the file contents are removed (or marked as free space,
> I guess). I only found platform dependent ways of dealing with disk block's.

Maybe you can use the statvfs() function for this.

>
> - 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.

>
>
> This test uses the MOUNTED IMFS filesystem, for no particular reason, so if
> that's an issue please let me know.
>
> [1] - http://www.rtems.org/pipermail/rtems-users/2014-January/012378.html
>
> [2] - http://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html
>
> --André Marques
>
> 0001-New-fstest-to-check-rename-POSIX-conformance.patch
>
>
>>From fe91c9c1072112c5d191a231da0ef4c04159dce6 Mon Sep 17 00:00:00 2001
> From: Andre Marques<andre.lousa.marques at gmail.com>
> Date: Sat, 8 Feb 2014 11:40:49 +0000
> Subject: [PATCH] New fstest to check rename POSIX conformance
>
> ---
>   testsuites/fstests/Makefile.am                     |   1 +
>   testsuites/fstests/configure.ac                    |   1 +
>   testsuites/fstests/fsrename/fsrename.doc           |  19 +
>   testsuites/fstests/fsrename/fsrename.scn           | 166 +++++
>   testsuites/fstests/fsrename/test.c                 | 788 +++++++++++++++++++++
>   testsuites/fstests/mimfs_fsrename/Makefile.am      |  31 +
>   .../fstests/mimfs_fsrename/mimfs_fsrename.scn      | 174 +++++
>   7 files changed, 1180 insertions(+)
>   create mode 100644 testsuites/fstests/fsrename/fsrename.doc
>   create mode 100644 testsuites/fstests/fsrename/fsrename.scn
>   create mode 100644 testsuites/fstests/fsrename/test.c
>   create mode 100644 testsuites/fstests/mimfs_fsrename/Makefile.am
>   create mode 100644 testsuites/fstests/mimfs_fsrename/mimfs_fsrename.scn
>
[...]
> diff --git a/testsuites/fstests/fsrename/test.c b/testsuites/fstests/fsrename/test.c
> new file mode 100644
> index 0000000..c133476
> --- /dev/null
> +++ b/testsuites/fstests/fsrename/test.c
> @@ -0,0 +1,788 @@
> +/*
> + *  COPYRIGHT (c) 2014 - .
> + *  Andre Marques<andre.lousa.marques at gmail.com>
> + *
> + *  The license and distribution terms for this file may be
> + *  found in the file LICENSE in this distribution or at
> + *http://www.rtems.com/license/LICENSE.
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include "config.h"
> +#endif
> +
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <unistd.h>
> +
> +#include "fstest.h"
> +#include "pmacros.h"
> +
> +static void symbolic_link_test (void)
> +{
> +
> +  uint32_t fd;
> +  uint32_t status;

Should be int instead of uint32_t.

> +  char *name01 = "name01";
> +  char *name02 = "name02";
> +
> +  char *symlink01 = "slink01";

Should be "const char *".

> +
[...]

> +
> +  unlink (name01);

Please check the return value of all functions.

> +
> +  unlink (name02);
> +
> +  unlink (symlink01);
> +
> +  /*
> +   * The new argument points to a symbolic link to another file and
> +   * the old argument points to a file.
> +   */
> +
> +  puts("\nNew is a simbolic link and rename operates on the simbolic link itself\n");
> +
> +  fd = creat (name01, mode);

assert(fd >= 0);

> +  status = close (fd);
> +  rtems_test_assert (status == 0);


-- 
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