No need to log expected failures to the terminal, the results file is
fine; pass the return value of the command.
Signed-off-by: David Sterba <dsterba@suse.com>
Add a way to wrap commands executed by the tests. This means the
common wrappers: run_check, run_check_stdout and run_mayfail , with the
exception of the use root_helper.
The contents of the shell variable INSTRUMENT are prepended to the
command, without quotes. Use with care.
Example: this has been tested with valgrind, the output goes to the
RESULTS file.
$ INSTRUMENT=valgrind make test-misc
Any use of root_helper/SUDO_HELPER will skip the instrumentation.
Signed-off-by: David Sterba <dsterba@suse.com>
We use setup_root_helper in some helpers to make sure that the sudo
helper is set up, and adding that to each test. Make the real test run
only once.
Signed-off-by: David Sterba <dsterba@suse.com>
Set the variable TEST_LOG=tty (in the enviroment or as parameter to
make) to print commands executed by 'run_check' helpers to terminal (ie.
/dev/tty). This might be useful to see the test progress beside watching
the results file.
Signed-off-by: David Sterba <dsterba@suse.com>
002-bad-transid outout 'transid verify failed' message in screen
which is just a warning in btrfs-image in normal condition of this
test.
This patch move above warning into $RESULTS, to:
1: Avoid trouble screen output
2: Let user known detail if other error happened in btrfs-image
Before patch:
# ./fsck-tests.sh
[TEST] 001-bad-file-extent-bytenr
[TEST] 002-bad-transid
parent transid verify failed on 29360128 wanted 9 found 755944791
parent transid verify failed on 29360128 wanted 9 found 755944791
Ignoring transid failure
[TEST] 003-shift-offsets
[TEST] 004-no-dir-index
...
After patch:
# ./fsck-tests.sh
[TEST] 001-bad-file-extent-bytenr
[TEST] 002-bad-transid
[TEST] 003-shift-offsets
[TEST] 004-no-dir-index
...
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Move code for extract image file to a function from check_all_images()
for common use, so caller can use this function to extrace single
image file.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
[minor reformatting and updates]
Signed-off-by: David Sterba <dsterba@suse.com>
mount command in old system can not add "-o loop" option automatically
for a loop device, and make following test 013-extent-tree-rebuild fail.
Considering that $TEST_DEV can be block or loop device, we need to determine
our mount option in a condition for both case.
Introduce a wrapper that will add the loop options if needed.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
For example, $TEST_DIR is common used in severial tests, and have
duplicated code for initialize.
These duplicated code not only benifits harddisk vendor, but have
inconsistent details, as:
convert-tests.sh: lack of mkdir
fsck-tests/012-leaf-corruption/test.sh: unnecessary mkdir
fsck-tests/013-extent-tree-rebuild/test.sh: unnecessary init
misc-tests/XXX ...
And severial error message:
_fail "unable to create mount point on $TEST_MNT"
_fail "failed to create mount point"
...
This patch move initizlizaton of $TEST_DIR to common init_env(),
to avoid above problem, and init_env() can be used to add more
things in future.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This code block is used several tests, move it to ./common and add a
helper.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Sometimes we need to process the output of the command, but run_check
captures all the output into results file.
Signed-off-by: David Sterba <dsterba@suse.cz>
Use upper case variant name for the following variants:
1) top -> TOP
2) script_dir -> SCRIPT_DIR
And change the following variant name:
1) RESULT -> RESULTS
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Although fsck-test/012 uses sudo, it uses 'sudo -n', which won't prompt
user to input password and will return 1 if no valid credential is
found.
And this makes test result quite annoying since it fails to mount and
still continue, which will always fail.
This patch will check 'sudo -v -n' and 'sudo -n true' to determine
whether sudo works fine in different version/settings, since in some
setting/version, 'sudo -v -n' will fail even the user is set NOPASSWD.
Also, remove the 'have_root_helper' variant, since there is a
possibility that sudo credential will timeout during the test and
'have_root_helper' won't help to detect such problem.
New '_sudo' command will do credential check if needed to avoid such
problem.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Sudo may not be configured to run without user prompt, in that case the
tests would be stuck.
Reported-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Most of the checks run fine without root, but some of them may need to
do a mount test or access the data. Add the support to selectively run
commands under root, hardcoded to sudo for now.
Signed-off-by: David Sterba <dsterba@suse.cz>
Change the old btrfsck test infrastructure (btrfs-image dump or xz raw
dump) to the new test infrastructure.
1) Test case layout
The new infrastructure is dir based, each dir is one test type, and can
contain multiple images/scripts for different corner cases.
So layout will be the following:
btrfs-progs
|-tests
|-fsck-tests
|-001-SOME-CORRUPT-TYPE
|-IMAGE-FOR-CASE1
|-IMAGE-FOR-CASE2
2) Test case image types
Only 2 types for test case images.
a) btrfs-image dump
This one is the simplest case, one only needs to add the image to
corresponding dir.
b) custom script
This one is for all the resting cases which can't fit btrfs-image,
like csum error or script can generate the image (this reduces the
size obviously and good for review)
The old binary dump also belongs to this type, so need to add script
to extract them.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>