Commit graph

119 commits

Author SHA1 Message Date
Karel Zak
f0c60dff1a tests: add sfdisk --wipe and --wipe-partition tests
Addresses: https://github.com/karelzak/util-linux/issues/410
Addresses: https://github.com/karelzak/util-linux/issues/411
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-15 12:48:06 +01:00
Ruediger Meier
fc5fa9036a tests: let lsmod fail silently
This is mostly for non-Linux systems where lsmod is not
even available.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-11-07 10:51:43 +01:00
Ruediger Meier
5c711ba945 tests: consolidate rmmod scsi_debug
- auto cleanup on test exit
 - Add smart timeout: Newer openSUSE systems on OBS failed to rmmod
   almost always. udevadm settle does not seem to have any affect.
 - now tests will fail if rmmod fails

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-10-21 15:08:49 +02:00
Filipe Brandenburger
88a5f90e87 tests: Use proper word splitting when executing tests
Use the shell special variable "$@" instead of the inferior $* to
execute the test command in ts_valgrind.  The expansion of "$@" respects
proper word splitting and makes it possible to pass the command empty
arguments.  It might also prevent surprises with quoting in corner
cases.

Tested that `make check` passes.

Valgrind run with `make check TS_OPTS='--nonroot --memcheck'` passes.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2016-08-10 13:37:43 -07:00
Karel Zak
94fa9b4637 tests: implement ts_skip_subtest
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-11 11:01:14 +02:00
Karel Zak
4a62215c84 tests: fix for non-ncurses version
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-06-09 12:10:33 +02:00
Karel Zak
edeb6223fe tests: make tests more portable due to mtab
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-15 14:10:23 +02:00
Ruediger Meier
c3f323cb2c tests: don't depend on GNU md5sum
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-04-13 12:29:16 +02:00
Ruediger Meier
e486622991 tests: skip old socat silently
I've seen enough logs with verbose socat output for now. Let's
make it quiet.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-13 21:47:32 +01:00
Ruediger Meier
8d323f0dd6 tests: fix non-working udevadm settle for scsi_debug
We don't sleep anymore since 01b38917. This does not work
on Debian 7 (wheezy)/linux-3.2. Is it the kernel's or udev's
fault?

We simmply add a better sleep again plus some todos for later
improvements.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-09 14:41:10 +01:00
Ruediger Meier
7e604f3c80 tests: don't skip case "output undefined"
Treat missing expected files as empty and let the test fail if
there is non-empty output.

Expected output may be missing in these cases:
 1. forgot to commit the file after changing/adding a (sub)test
 2. a bug in a test where we do tricks with TS_EXPECTED
 3. and most notable if ts_die() is called before a subtest is
    initialized, e.g. in ts_scsi_debug_init()

I always wondered why we don't treat this as FAILED. Now we do
so, ts_finalize and ts_gen_diff looks much cleaner now.

The change discovers that tests with subtest were ignoring the
"non-sub" expected files which had to be fixed. BTW we removed
any zero sized files.

Moreover now we respect diff's return value. In past all test
succeeded when diff was not able to write to diffdir, e.g. when
running tests as normal user after they run as root.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 23:34:24 +01:00
Ruediger Meier
855f7f0650 tests: add option --parsable
This is to force the one-line results also for non-parallel case.
We are using it for travis auto-build and on other build farms.

Moreover you can set this (and any other) option globally by env
which is the only way to pass it to make distcheck.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-05 22:19:24 +01:00
Ruediger Meier
2979724f5d tests: --parallel prints results in a single line
Like in non-parallel case we are printing only one line per
(sub)test now. The output lines must contain the full test name
to be useful.

This patch does not change anything for the non-parallel output
format except a bit code cleanup.

BTW changed blkid/low-probe test description to have shorter
lines.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-05 17:43:45 +01:00
Ruediger Meier
4303124ad5 tests: fix ts_option helpers
These two problems should be fixed now:
  - BSD awk only accepts 1-char field seperator
  - ts_has_option() did not returned "yes" if an option was given
    multiple times

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-18 12:53:48 +01:00
Ruediger Meier
01e8c90ca2 tests: ts_fdisk_clean(), remove optimal iosize
It's a pity a pity that we have to remove it. In past our test suite
could discover a kernel bug (4.4). But now they've changed optimal
iosizes on purpose.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-10 21:06:41 +01:00
Ruediger Meier
23d8c55684 tests: minor cleanup ts_fdisk_clean()
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-10 21:06:40 +01:00
Karel Zak
98604ef9f2 tests: fallback for missing TS_DESC
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-05 12:31:32 +01:00
Ruediger Meier
1cb10736e4 tests: always create sparse image files
This saves about 400M disk I/O and space.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-01-05 12:21:56 +01:00
Ruediger Meier
01b38917ad tests: no more sleep, udevadm settle only
This seems to work nowadays and saves 37s.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-01-05 12:21:55 +01:00
Karel Zak
161f399f13 tests: add sfdisk --move-data test
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-09 14:43:31 +02:00
Ruediger Meier
4ba0bfbb51 tests: add $top_builddir to $PATH
Since we have dropped some more hardcoded search paths we should
make sure that our tested binaries would use the right helpers
from our build directory.

See 07b51567 and follow-up commits.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-05-08 15:11:56 +02:00
Karel Zak
6f13d7a1b2 Merge branch 'tests-refactor-loop-cleanup' of https://github.com/rudimeier/util-linux
* 'tests-refactor-loop-cleanup' of https://github.com/rudimeier/util-linux:
  tests: never use -o pipefail
  tests: loop tests, don't call ts_die() with DEVICE parameter
  tests: scsi_debug tests, don't call ts_die() with DEVICE parameter
  tests: introduce TS_LOOP_DEVS for cleanup
  tests: introduce ts_cleanup_on_exit()
2015-04-22 10:03:12 +02:00
Ruediger Meier
cbae7931c8 tests: introduce TS_LOOP_DEVS for cleanup
We are maintaining an array TS_LOOP_DEVS to de-initialize devices
always on exit. Until now there was no cleanup in ts_skip().

The downside is that we can't execute ts_device_init() in a subshell
anymore. The device is returned via global variable TS_LODEV, similar
like we do already in ts_scsi_debug_init().

Tests which don't use ts_device_init() to create loop devices may use
ts_register_loop_device() to get them cleaned up later.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-04-14 13:18:42 +02:00
Ruediger Meier
caf31605dd tests: introduce ts_cleanup_on_exit()
ts_cleanup_on_exit() is always called on exit, e.g. after ts_skip,
ts_die, ts_finalize ...

A first usage example is the cleanup of TS_SUID_PROGS which is now also done
on ts_skip. Later we want to fix some left loop devices.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-04-14 13:18:42 +02:00
Karel Zak
f8c0152970 Merge branch 'tests-logger' of https://github.com/rudimeier/util-linux
* 'tests-logger' of https://github.com/rudimeier/util-linux:
  travis: install socat >= 1.7.2
  tests: add subtests for invalid logger devive
  tests: logger/errors does not use --no-act
  tests: logger, validate written socket data
  tests: logger with socat device
  tests: simplify common logger options
  logger: --stderr and --no-act turn "auto-errors" on
2015-04-14 11:52:06 +02:00
Karel Zak
866372c699 tests: make libmount context tests sensitive to USE_LIBMOUNT_FORCE_MOUNTINFO
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-14 11:26:54 +02:00
Ruediger Meier
c9813f2cbe tests: logger with socat device
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-04-13 13:24:34 +02:00
Ruediger Meier
85fca7e5bc tests: ts_scsi_debug_init() sleeps a bit earlier
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-04-02 12:09:15 +02:00
Karel Zak
d995c2f082 tests: add --skip-loopdevs
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-17 11:34:22 +01:00
Ruediger Meier
5f708381a1 tests: optionally skip tests where loop support is needed
It can be hard to check for loop support (e.g. on LXC containers). Let
the user skip it manually by env:

TS_OPT_FEAT_SKIP_LOOP="yes"

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-03-16 14:32:34 +01:00
Benno Schulenberg
0209a128b5 tests: improve some wordings of the output
For one, replace the puzzlingly stern imperative "IGNORE" with
the simple and light-hearted and descriptive "SKIPPED".

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-19 10:55:10 +01:00
Ruediger Meier
fa8f8b7469 tests: python tests should not remove user's LD_LIBRARY_PATH
LD_LIBRARY_PATH must be preserved like it's done in libtool's
temporary wrapper scripts.

This problem was noticed when building with Intel's icc (15.0.0):
$ make check TS_OPTS="libmount"
$ tail tests/diff/libmount/tabfiles-py-parse-mtab
[...]
+Traceback (most recent call last):
+  File "/tmp/util-linux/libmount/python/test_mount_tab.py", line 8, in <module>
+    import pylibmount as mnt
+ImportError: libimf.so: cannot open shared object file: No such file or directory

... although libimf.so was in LD_LIBRARY_PATH.

NOTE 1:
  When running root checks "sudo -E" is not enough to preserve
  LD_LIBRARY_PATH because glibc already removes is. This would work:
  $ sudo -E env LD_LIBRARY_PATH=$LD_LIBRARY_PATH make check TS_OPTS="--parallel=1"

NOTE 2:
  We also preserve PYTHONPATH which could bring us similar problems if
  the user has a customized python installation.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-01-20 13:12:29 +01:00
Ville Skyttä
9779f59831 docs: Spelling fixes
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-18 13:59:19 +01:00
Andreas Henriksson
eee79f2843 tests: Fall back on host/getent in ts_resolve_host
Neither dig or nslookup would be my first option for resolving,
so add the host utility of ISC/bind fame and the (slow) getent
utility shipped with libc.

This extends the conditions introduced in ...

  commit a98de9696e
  Author: Ruediger Meier <ruediger.meier@ga-group.nl>
  Date:   Wed Jun 11 19:28:20 2014 +0200

      tests: skip some last tests if no dns support

... and should help us not skip certain tests when we have
network connection but none of dig or nslookup available.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2014-07-28 11:09:52 +02:00
Sami Kerola
723c70434b tests: add function to change directory reliable way
Without arguments bash cd will move to $HOME. Ensure also that when
directory is assumed to be changed the current directory and intented
destination are the same location.

Reference: http://www.spinics.net/lists/util-linux-ng/msg09509.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-18 18:34:14 +01:00
Ruediger Meier
a98de9696e tests: skip some last tests if no dns support
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-06-12 01:09:38 +02:00
Ruediger Meier
15b2606c4f tests: fix python tests for dist and out-of-tree builds
- add python helper scripts to the dist
- helper scripts are always in srcdir
- python libs are in builddir
- abort tests if helpers are missing

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-06-04 10:14:24 +02:00
Ruediger Meier
f80c0d38b9 tests: ts_scsi_debug_init skip instead of die
If any of these modprobe commands fails then it's not a broken test.
ALso ts_die often does not work correctly from subtests which should
be fixed someday too.

BTW modprobe dry-run (even the real modprobe) is not reliable.
Moreover now we respect blacklisted modules (-b).

This error handling is not only useful to let the test-suite succeed
on broken systems but also to not fail all "scsi_debug tests" after
just one of them failed to umount something.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-27 00:06:43 +02:00
Karel Zak
1efded63df Merge branch 'tests-mount' of https://github.com/rudimeier/util-linux
* 'tests-mount' of https://github.com/rudimeier/util-linux:
  tests: use ts_mount for cramfs
  tests: ts_mount knows which fs is expected
  tests: ts_mount validates error message
  tests, add function ts_mount
2014-05-16 14:30:05 +02:00
Ruediger Meier
d2cc2ba722 tests: ts_mount knows which fs is expected
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-16 12:07:26 +02:00
Ruediger Meier
a23c435ea2 tests: ts_mount validates error message
Skip only if mount reports a non-empty fs which is not available
in /proc/filesystems.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-16 12:07:03 +02:00
Ruediger Meier
2f95494707 tests, add function ts_mount
We want to generalize mounts similar to how we do it already in
minix/mkfs. Currently most of our other checks just fail if
"fs not supported".

Note that the new function checks a bit stronger than before in
minix/mkfs. It respects mount's return value and stderr goes
to $TS_OUTPUT too.

It's a bit ugly that we write to $TS_OUTPUT from inside of the
function. But if the caller would do it then we couldn't
ts_skip and the whole function would be pointless.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-16 12:06:00 +02:00
Ruediger Meier
d1962aaec6 tests: add function ts_check_prog
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-15 12:00:59 +02:00
Karel Zak
37bc9a51c8 Merge branch 'travis-root-checks-v2' of https://github.com/rudimeier/util-linux
* 'travis-root-checks-v2' of https://github.com/rudimeier/util-linux:
  travis-ci: enable root checks
  travis-ci: minor cleanup and speedup
  tests: introduce TS_CMD_UUIDGEN (never use installed one)
  tests, don't write TS_DEVICE to stdout anymore
  tests: ts_scsi_debug_init must not run in a subshell
  tests: cleanup ts_scsi_debug_init
  tests: some more tests need loop support
  tests: ts_device_init requires loop support
  tests: use ts_check_losetup in losetup test
  tests: add function ts_check_losetup
  tests: ts_device_init remove useless error handling
2014-05-14 14:15:58 +02:00
Ruediger Meier
07d9ed0a40 tests, don't write TS_DEVICE to stdout anymore 2014-05-13 17:38:41 +02:00
Ruediger Meier
dd761f7924 tests: cleanup ts_scsi_debug_init
Sort out global and local vars. Now we set TS_DEVICE globally
to be use later.
Skip really quiet if modprobe fails.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-13 17:37:28 +02:00
Ruediger Meier
5ec15aefbb tests: add function ts_check_losetup
Unfortunately losetup -f does not return an error nowadays.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-13 17:36:51 +02:00
Ruediger Meier
733094a851 tests: fix "KNOWN FAILED" for subtests
It didn't worked for tests with subtests.

Here we consolidate both cases which fixes the issue by the way. This
is basically a rewrite of 7641ccec.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-13 15:39:25 +02:00
Ruediger Meier
b5eb509709 tests: ts_device_init remove useless error handling
Don't know why we should deinit the empty string.
This patch prepares further refactoring or error handling.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-12 16:25:16 +02:00
Ruediger Meier
7641ccec60 tests: add exit case "KNOWN FAILED"
Now we can mark tests as known to be broken without bothering
users with exit failure. In the build log this "KNOWN FAILED"
may be interpreted as TODO ;)

The main advantage of "known-fail" instead of just skipping
is that we will still find the test diff.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-12 09:56:08 +02:00