generic: Add first statx test
authorDavid Howells <dhowells@redhat.com>
Mon, 10 Apr 2017 13:32:52 +0000 (14:32 +0100)
committerEryu Guan <eguan@redhat.com>
Tue, 11 Apr 2017 04:34:24 +0000 (12:34 +0800)
commitd1ba8b79a600d64b68763184fee1126382c0d05a
treea84f798c89f27d16a7013a8712fbd24809828ad7
parent29f8137fcb43081efd5424ffef6f393f28fdc44b
generic: Add first statx test

Add a statx test script that does the following:

 (1) Creates one each of the various types of file object and creates a
     hard link to the regular file.

     Note that the creation of an AF_UNIX socket is done with netcat in a
     bash coprocessing thread.  This might be best done with another
     in-house helper to avoid a dependency on nc.

 (2) Invokes the C test program included in this patch after the creation
     and hands it a list of things to check appropriate to each object.

 (3) Asks the test program to check the creation time of each object
     against that of the preceding object.

 (4) Makes various tests on the timestamps of the hardlinked file.

The patch also creates a C[*] test program to do the actual stat checking.
The test program then does the following:

 (1) Compares the output of statx() to that of fstatat().

 (2) Optionally compares the timestamps to see that they're sensibly
     ordered with respect to each other.

 (3) Optionally compares the timestamps to those of a reference file.

 (4) Optionally compares the timestamps to a specified time.

 (5) Optionally compares selected stats to values specified on the command
     line.

 (6) Optionally compares all the stats to those of a reference file,
     requiring them to be the same (hard link checking).

For example:

./src/stat_test /dev/null \
       stx_type=char \
       stx_rdev_major=3 \
       stx_rdev_minor=8 \
       stx_nlink=1 \
       ref=/dev/zero \
       ts=B,b

The test program can also be given a --check-statx parameter to give a
quick exit code-based answer on whether statx() exists within the kernel.

[*] Note that it proved much easier to do this in C than trying to do it in
    shell script and trying parsing the output of xfs_io.  Using xfs_io has
    other pitfalls also: it wants to *open* the file, even if the file is
    not an appropriate type for this or does not grant permission to do so.
    I can get around this by opening O_PATH, but then xfs_io fails to
    handle XFS files because it wants to issue ioctls on every fd it opens.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
.gitignore
common/rc
src/Makefile
src/stat_test.c [new file with mode: 0644]
src/statx.h [new file with mode: 0644]
tests/generic/423 [new file with mode: 0755]
tests/generic/423.out [new file with mode: 0644]
tests/generic/group