config: Fix SCRATCH_DEV_POOL handling

With changes introduced in 667308dd97bf41382d4ab299fa5b56c235cfeb27
it is no longer possible to use SCRATCH_DEV_POOL variable because of
error:

 common/config: Error: $SCRATCH_DEV should be unset when
 $SCRATCH_DEV_POOL is set

This was because get_next_config() would get called twice and hence it
would complain on the second run that SCRATCH_DEV is already set. Fix
it by making sure that we call get_next_config() only once if there
are no sections in the config file.

Also make sure that we export SCRATCH_DEV in the case we're deducing it
from SCRATCH_DEV_POOL.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Filipe David Manana <fdmanana@gmail.com>
Tested-by: Filipe David Manana <fdmanana@gmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
config: Unset SCRATCH_DEV when deduced from SCRATCH_DEV_POOL

In the case that we already have sections in the config file we
have to make sure that we unset SCRATCH_DEV if it has been deduced from
the SCRATCH_DEV_POOL so that it does not complain about SCRATCH_DEV in
this case.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Tested-by: Filipe David Manana <fdmanana@gmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
config: Fix setting FSTYP automatically

Currently if the FSTYP is not set, the code to get FSTYP using blikd
would not work. This is because we're using HOSTOS environment variable
which might not be set (at least not on my system) and because it's
already late in the code path.

Fix this by using OSTYP environment variable as a fallback in the case
that HOSTOS does not work and move the check to common/config.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Tested-by: Filipe David Manana <fdmanana@gmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
check: fix wallclock wrapping problem

If a test cross two days, the time may be negative, let's use
the UTC seconds instead, for example:

2014-04-03 23:43:42 ./check generic/074 generic/075 generic/112 generic/113 generic/132 generic/133 generic/231
FSTYP         -- xfs (non-debug)
PLATFORM      -- Linux/x86_64 vpx-2 3.14.0-00001-g462fa88
MKFS_OPTIONS  -- -f -bsize=4096 /dev/vdd
MOUNT_OPTIONS -- /dev/vdd /fs/scratch

generic/074	 100s
generic/075	 220s
generic/112	 226s
generic/113	 188s
generic/132	 18s
generic/133	 37s
generic/231	 -85401s
Ran: generic/074 generic/075 generic/112 generic/113 generic/132 generic/133 generic/231
Passed all 7 tests

Reported-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
ext4/306: disable 64bit feature too

mke2fs ext4 without extent feature will fail if 64bit feature is
enabled in mke2fs.conf

mke2fs 1.42.9 (28-Dec-2013)
Extents MUST be enabled for a 64-bit filesystem.  Pass -O extents to rectify.

So disable 64bit feature together with extent explicitly.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
config: fix specifying configuration value with equality sign

Currently there is a problem with parse_config_section() when the
configuration value contains equality sign like this for example:

MOUNT_OPTIONS="-o data=journal"

the result will be

export MOUNT_OPTIONS="-o data="journal"

which is not going to work. The reason is that the expression used to
parse the configuration options uses greedy matching '.*'. Fix this by
using non greedy expression to match the first equality sign '[^=]'.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
generic/204: correct log size for XFS

generic/204 fails on device with Advanced Format of 4096 bytes per
physical sector and when partition starts at the 4K boundary/./In
this case filesystem sector/block size will be of 4096 bytes size
and _scratch_mkfs_sized fails because mkfs reports that 5Mb log size
is not enough to create a filesystem, for example attempt to make
filesystem on such partition:

mkfs.xfs -f -bsize=4096 -l size=5m -d size=109051904 /dev/sdb2"

results to:

"log size 1280 blocks too small, minimum size is 1605 blocks"

and generic/204 fails with ENOSPC before it has finished creating
the necessary files. Log size of 7MB is enough for this test to pass.

Signed-off-by: Alexander Tsvetkov <alexander.tsvetkov@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
generic/022: Fix output file

In commit 21723cdb, renumbering the test wasn't completed entirely,
leaving the output file with a wrong test number. It should be 022,
fix it.

[dchinner: Yup, my mistake. editted the commit message to reflect
 that.]

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
config: Add -s option to run only specified sections

This commit adds -s option which allows you to specify only certain
sections from the config file to be run. The '-s' argument can be
specified multiple times to allow multiple sections to be run.

The options are still carried between section, that includes the
sections which are not going to be run.

Update README.config-sections as well.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
common: add infrastructure for renameat2 syscall tests

The renameat2() syscall was merged into 3.15-rc (merge commit:
7df934526c0b).

This adds the shared infrastructure for the actual test scripts.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
generic: check plain renameat2 syscall

Check with zero flags.  This is what rename(2) and renameat(2) now
call, so this actually tests the behavior of these syscalls as well.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
generic: check noreplace renameat2 syscall

Check with RENAME_NOREPLACE flag.  This flag indicates that the
rename must fail if the target of the rename exists.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
generic: check cross renameat2 syscall

Check with RENAME_EXCHANGE flag.  This flag indicates that the
source and destination files are to be exchanged.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
generic/300: add fallocate() checks

Generic/300 fails when run on a test filesystem that does not
support fallocate(). It uses fio's falloc ioengine to generate part
of its I/O load and both allocates blocks and punches holes.  This
causes EOPNOTSUPP failures when the test is run on indirect
block-mapped ext4 filesystems or pre-3.14 ext4 filesystems created
with bigalloc.

Verify that the test filesystem supports fallocate() before
proceeding with the test, checking for both block allocation and
hole punching capabilities.  Also, delete any pre-existing test
output.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
generic/311: add fallocate() check

Generic/311 fails when run on a test filesystem that does not
support fallocate().  Its I/O load is produced by fsync-tester,
which uses fallocate() system calls to allocate blocks for some of
its test cases.  This causes EOPNOTSUPP failures when the test is
run on indirect block-mapped ext4 filesystems.

Verify that the test filesystem supports fallocate() before
proceeding with the test, checking for block allocation
capabilities.  Also, fix a minor error message typo.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
generic/004: fix filtering of expected error message

The failure message goes to stderr, so we need to redirect stderr to
stdout before running sed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
generic: add renameat2 system call number for i386

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
generic/024: fix output number

Didn't update a patch correctly when renumbering it. This time
on a test that doesn't run on XFS yet, so it avoided smoke tests...

Signed-off-by: Dave Chinner <david@fromorbit.com>
generic: add renameat2 system call number for i386

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
renameat2 syscall: turn EEXIST into ENOTEMPTY

XFS is returning EEXIST rather than ENOTEMPTY for several of
these rename tests. The rename man page says this about the errors:

       ENOTEMPTY or EEXIST
              newpath is a nonempty directory, that is, contains
              entries other than "." and "..".

Which implies that both errors are valid and so the test should pass
in either case.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>