Commit Graph

68 Commits (master)

Author SHA1 Message Date
Qu Wenruo 121b9a2e4c btrfs-progs: tests: Add --force for repair command
Since commit e388bf38 ("btrfs-progs: check: warn users about the
possible dangers of --repair") `btrfs check --repair` will wait 10
seconds before really repair the fs.

This hugely slow down the fsck tests. Add --force for check_image()

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2020-01-09 14:27:09 +01:00
David Sterba b9000ce339 btrfs-progs: tests: remove unused variables in common
All the run_* helpers have unused variable cmd, probably a leftover from
debugging the option injection magic.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-11-22 19:07:16 +01:00
David Sterba 8041a1c229 btrfs-progs: tests: enhance convert option injection
Add support for TEST_ARGS_CONVERT to allow injection of eg. checksum
command for the all tests. Use like

 $ make TEST_ARGS_CONVERT='--csum=xxhash' TEST_ENABLE_OVERRIDE=true test-convert

This affects all btrfs-convert commands that are run by run_check and
other helpers, IOW this affects all tests, not just convert specific ones.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-11-18 19:21:10 +01:00
David Sterba f24ba8126e btrfs-progs: tests: enhance mkfs option injection
Add support for TEST_ARGS_MKFS to allow injection of eg. checksum
command for the all tests. Use like

 $ make TEST_ARGS_MKFS='--csum=xxhash' TEST_ENABLE_OVERRIDE=true test-mkfs

This affects all mkfs.btrfs commands that are run by run_check and other
helpers, IOW this affects all tests, not just mkfs specific ones.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-11-18 19:21:09 +01:00
Qu Wenruo 6f24e7276b btrfs-progs: tests: Avoid debug log populating stdout
When running misc-test/034, we got unexpected log output:
      [TEST/misc]   033-filename-length-limit
      [TEST/misc]   034-metadata-uuid
  Checking btrfstune logic
  Checking dump-super output
  Checking output after fsid change
  Checking for incompat textual representation
  Checking setting fsid back to original
  Testing btrfs-image restore

This is caused by commit 2570cff076 ("btrfs-progs: test: cleanup misc-tests/034")
which uses _log facility which also populates stdout.

Just change _log() to echo "$*" >> "$RESULTS" to fix it.
Unlike the initial commit, there is no other user of _log, so it
shouldn't affect other tests.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
David Sterba 3a1e12abdc btrfs-progs: tests: add helper to compare kernel versions
Return succcess if runnning kernel >= parameter. Most callers will want
to skip the test.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:01 +02:00
David Sterba 0528d89454 btrfs-progs: tests: common: add shell missing quotes
The loop device helpers lack shell quotes, though not strictly
necessary, add them for consistency.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:01 +02:00
David Sterba 53ae6525b9 btrfs-progs: tests: don't print dd transfer info
The transfer lines from dd bloat the logs and other lines may not fit.
Disable xfer in all dd commands but still allow errors to be caught.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 02:06:34 +02:00
David Sterba 201ad5c9e5 btrfs-progs: tests: add helper to compare kernel versions
Return succcess if runnning kernel >= parameter. Most callers will want
to skip the test.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 02:06:34 +02:00
David Sterba 2a24192454 btrfs-progs: tests: add helper for common mkfs on TEST_DEV
Lots of test opencode the mkfs phase with no special needs, add a helper
that forcibly creates fileystem on TEST_DEV. Any options can be added,
except devices.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-06-05 20:27:32 +02:00
Josh Soref 0509c05ae6 btrfs-progs: tests: fix typos in test comments
Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 17:53:43 +01:00
David Sterba 402ac7a140 btrfs-progs: tests: update log markers
Use visual markers that separate tests and individual commands run via
the run_* helpers.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:32 +02:00
David Sterba 510bb4ccc4 btrfs-progs: tests: add helper to log pipe stdout
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-19 19:24:07 +01:00
Gu Jinxiang cebf3b3722 btrfs-progs: introduce TEST_TOP and INTERNAL_BIN for tests
Use TEST_TOP as base for tests to reference any files, this will be used
for git and external testsuite.

INTERNAL_BIN is needed for referencing binaries that could reside in
different paths in git vs external testsuite.

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
[ add quotes around sourced files, update changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-13 15:41:32 +01:00
Su Yue 03401ccd7c btrfs-progs: tests common: remove meaningless colon in extract_image()
The colon is meaningless so remove it.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-07 15:32:08 +01:00
David Sterba 7de5fafc64 btrfs-progs: tests: enhance common umount helper to take optional paths
The run_check_umount_test_dev umounts the TEST_DEV and also optionally
uses the arguments but this would not work as expected if the TEST_DEV
is not a vald path for umount (eg. a restored image).

Update the helper so it tries to umount all paths, or fallback to
TEST_DEV to keep the current behaviour.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-31 15:14:03 +01:00
David Sterba 81dd246d95 btrfs-progs: tests: truncate test image to 0 first
We use the prepare_test_dev helper to make sure the image has at least
this size. The "at least" part is not desired by some tests as the
device might be larger than the test expects.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-31 15:14:02 +01:00
David Sterba 6e8571e2df btrfs-progs: tests: fix typo in error message
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-08 19:50:27 +01:00
Qu Wenruo 2c2db167c7 btrfs-progs: test/common: Enhance prepare_test_dev to reset device size
So prepare_test_dev() can be called several times in one test case, to
test different device sizes.

Signed-off-by: Qu Wenruo <wqu@suse.com>
[ switch to [ ] ]
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-03 17:10:05 +01:00
Qu Wenruo 2bf30fb3b1 btrfs-progs: test/common: Introduce run_mustfail_stdout
For later test case which needs info from stderr.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-03 17:10:03 +01:00
Lakshmipathi.G 7a060ea026 btrfs-progs: tests/common: Display warning only after searching for btrfs kernel module
Signed-off-by: Lakshmipathi.G <lakshmipathi.g@giis.co.in>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-11-14 15:59:00 +01:00
David Sterba 509af95c92 btrfs-progs: tests: make sure _is_file_or_command does not get confused
The test cli/007-check-force reports something like:

$ type -p '--string that starts with dashes'
bash: type: --: invalid option

Add the option/argument separator.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:05 +02:00
David Sterba 03fb34b6b4 btrfs-progs: tests: remove temporary loopdev files
Remove files for testing loop devices when using the helper.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:28 +02:00
Misono, Tomohiro cb39164f9d btrfs-progs: test: fix name generation not to contain trailing spaces
First patch causes test-convert fails.  This is because
generate_dataset() creates a name containing trailing spaces for
"slow_symlink" type, and cause getfacl error in convert_test_perm().
(This is not noticed since original run_check_stdout() throws away the
error.)

Fix this by use space for delimiter for cut.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
Misono, Tomohiro 02e9bb9f23 btrfs-progs: test: fix run_check_stdout() call _fail()
run_check_stdout() uses "... | tee ... || _fail".  However, since tee
won't fail, _fail() is not called even if first command fails.

Fix this by checking PIPESTATUS in the end.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 528a5bf6ad btrfs-progs: tests: move loopdev helpers out of the testcase to common
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba fb0d53a937 btrfs-progs: tests: fix _is_file_or_command detection
type -p returns an empty string for nonexistent commands, but the -f
test on an empty string does not behave the same on all shells. To be
safe, use the quoted value.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-08-25 15:58:05 +02:00
David Sterba d7dd9d00e9 btrfs-progs: tests: catch bad usage of run_mustfail
This function has an extra argument and can get forgotten, add a sanity
check so the bad usage can be caught during development.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-08-24 19:08:18 +02:00
Adam Buchbinder 5c2cf48a4c btrfs-progs: tests: Use '-t btrfs' mount option in tests
Without it, mount (at least from util-linux 2.20.1) tries (and fails) to
mount some filesystems as NTFS.

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-20 19:46:11 +02:00
Lu Fengqi a0e44021ab btrfs-progs: check: Fix lowmem mode override to allow it skip repair work
Current common.local doesn't handle lowmem mode well.
It passes "--mode=lowmem" alone with "--repair", making it unable to
check lowmem mode.

It's caused by the following bugs:

1) Wrong variable in test/common.local
   We should check TEST_ARGS_CHECK, not TEST_CHECK, which is not defined
   so we never return 1.

2) Wrong parameter passed to _cmd_spec() in test/common
   This prevents us from grepping the correct parameters.

Fix it.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:49 +01:00
Qu Wenruo 46b8ea0e99 btrfs-progs: convert-test: trigger chunk allocation after convert
Populate fs after convert so we can trigger data chunk allocation.
This can expose too restrict old rollback condition

Reported-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-12-21 16:29:06 +01:00
David Sterba 50e742a6b0 btrfs-progs: tests: add support for additional command arguments
Add convenient support for extending command arguments, now implemented
for 'btrfs check' to cover the low-memory mode. If defined, arguments
are inserted to any 'btrfs check' command in tests. Exceptions could be
defined in common.local.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 11:07:06 +01:00
David Sterba 55db7bf059 btrfs-progs: tests: more variable quoting in common scripts
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 11:07:06 +01:00
David Sterba c1d714f944 btrfs-progs: tests: drop redundant test for rwx number validity
The list of rwx permissions is now hardcoded but used to begenerated and
the invalid numbers filtered out. Not necessary anymore.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 11:07:06 +01:00
Tsutomu Itoh b0d8975582 btrfs-progs: test: fix how to make test files in fsck-tests 013
In my test environment, following error was occurred because the size
of /lib/modules/`uname -r`/* is larger than 1GB.

# make test-fsck
    [TEST]   fsck-tests.sh
    [TEST/fsck]   013-extent-tree-rebuild
failed: cp -aR /lib/modules/4.9.0-rc5/ /test/btrfs-progs/tests/mnt
test failed for case 013-extent-tree-rebuild
Makefile:272: recipe for target 'test-fsck' failed
make: *** [test-fsck] Error 1
#

In this test case, 'generate_dataset small' is enough for making the
test files, so I will use 'generate_dataset' instead of 'cp'.

For this, move 'generate_dataset()' from 'common.convert' to 'common'.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 11:07:06 +01:00
David Sterba d4ce61f7a2 btrfs-progs: tests: add fallback to current directory for check_all_images
Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 11:07:05 +01:00
David Sterba 7cd40e125b btrfs-progs: tests: check for TEST_LOG values by a regex
The set of possible values will be extended so check for existence of
the keyword.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 10:51:38 +01:00
David Sterba 9d0e6a67f9 btrfs-progs: tests: enhance run_mayfail description comment
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:25:19 +01:00
David Sterba cc0d3d3198 btrfs-progs: tests: add quotes around variables in common
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:25:19 +01:00
David Sterba 8a44fd062a btrfs-progs: tests: add assertion helper
Helper to extend sanity checks in various functions.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:25:18 +01:00
David Sterba 4ad7a967d1 btrfs-progs: tests: check if kernel has btrfs support
Add some sanity checks, reported among other issues via bugzilla.

References: https://bugzilla.kernel.org/show_bug.cgi?id=177141
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:25:18 +01:00
David Sterba 45827710e2 btrfs-progs: tests: teach extract_image about packed streams
Packed streams for testing purposes should be packed with 'xz -9' and
use suffix .stream.xz .

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:23:29 +01:00
David Sterba a08ca376f7 btrfs-progs: tests: teach run_mayfail about sigabrt
Mayfail helper should stop when we encoutner an abort.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba b6bf79eb96 btrfs-progs: tests: don't treat segfault as ignorable error
Some fuzzed images cause various tools to crash but the mayfail helper
would not recognize that. We don't mind if the utility failes but it
must not crash.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
Qu Wenruo fde5ae2e49 btrfs-progs: convert-tests: Add support for custom test scripts
Add support for custom convert test scripts, just like fsck tests.

Instead of generic convert tests, we need more specifically created images
for new convert tests.

This patch provide the needed infrastructure for later convert test
cases.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-03 15:22:18 +02:00
Nicholas D Steeves bd2cc320af btrfs-progs: typo review of strings and comments
Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
David Sterba 10d308d5ea btrfs-progs: tests: introduce mustfail helper
Invalid syntax, expected failure on corrupted data etc. Failure is
success.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-30 16:25:59 +02:00
David Sterba 425274ed8f btrfs-progs: tests: do not log output of run_mayfail to terminal
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>
2015-11-02 09:35:08 +01:00
David Sterba 1c4aefc2b8 btrfs-progs: tests: add support for command instrumentation
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>
2015-11-02 09:35:07 +01:00
David Sterba 1fcb190793 btrfs-progs: tests: do not run sudo helper tests if not necessary
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>
2015-11-02 09:35:06 +01:00