summaryrefslogtreecommitdiffstats
path: root/tests/functions.sh
Commit message (Collapse)AuthorAgeFilesLines
* tests: add --noskip-commandsKarel Zak2019-03-051-1/+8
| | | | | | | The default is SKIP missing commands on --use-system-commands, but with --noskip-commands the test will FAIL. Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: add --use-system-commandsKarel Zak2019-03-041-5/+29
| | | | | | | | | | | | | This change allows to use commands from $PATH rather than from $top_builddir. There two basic use cases: * check differences between installed and git version run.sh --use-system-command --show-diff * check system binaries by upstream tests (for example tests from src.rpm package) Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: use libtool to execute with valgrindKarel Zak2018-03-211-0/+1
| | | | | | | | The libtool based build system uses scripts rather than real binaries in $top_builddir. It's necessary to use libtool --mode=execute to call valgrind for the real binary (from .libs/). Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: consolidate ts_device_has UUID or LABELRuediger Meier2018-03-191-16/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | Regarding parallel root checks ... - fix: add a few missing "udevadm settle" where we are using LABELs or UUIDs - introduce ts_udevadm_settle(): * Still trivial implementation. The idea is to use it in future for all tests instead of directly calling "udevadm settle". So we could add debug messages, wait for specific events, add code for non-udev systems or even use "udevadm --{start,stop}-exec-queue" to be really sure what we are doing and why using udevadm at all. * The currently unused args may be used in future and show the code reader already now why we are calling "udevadm settle" at all. * So far this patch only affects swapon/, mount/, libmount/ tests, and is only about UUIDs and LABELs, but may be continued later for "partitions", "md devices", whatever. * We are calling ts_udevadm_settle() right *before* we need a LABEL or UUID, not just *after* we created one. This may be a bit better for speed and shows the code reader which command would fail without settle. - function ts_device_has_uuid() is unused now, we trust blkid(1). Renamed to ts_is_uuid() in case we would need it again. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: fix grep expressions for devicesRuediger Meier2018-03-191-2/+2
| | | | | | | | | | ts_is_mounted "/dev/loop1" returned true if /dev/loop17 was mounted. A very annoying source of sporadic failures since many years. This issue became more visible since running the checks in parallel, which increases the probability to get bigger loop device numbers. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: re-introduce bash 3 compatibility (OSX)Ruediger Meier2018-03-081-17/+20
| | | | | | | | | | | | | | | | | Bash 4 is now almost 10 years old and it seemed to be fine in 613a337e to use associative arrays. Unfortunately OSX will probably never update to 4 because of GPLv3. We don't want to lose our travis OSX build and use plain arrays again. BTW remove that "informative warnings" about unlocked resources. They were only silent so far because of a bug. Any system where scsi_debug is broken would print a lot of these warnings. This also tells us that we could even stop calling ts_unlock() explicitly. Just exiting the tests would be good enough. Note that currently flock(1) is not available on our OSX build anyways. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: dont't timeout flockRuediger Meier2018-03-071-1/+1
| | | | | | | | | | | | The only situation where we would block endless is if another parallel test has the lock and hangs for another reason. This means that the other test would still keep hanging even if we timeout here. The user would have to interrupt the other test or the whole test-suite anyways. Note that we would certainly run into any timeout when using --parallel=200, so that all scsi tests start the same time. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: don't use unlocked resourcesRuediger Meier2018-03-071-0/+20
| | | | | | | | The test-suite did not survive when flock timeouts after 30s because then ts_cleanup_on_exit() may use resources (e.g. rmmod scsi_debug) while not having the lock. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: don't lock fd 1 (stdout), don't use /proc/$$/fdRuediger Meier2018-03-071-20/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On debian-kfreebsd we've locked stdout which messed up our test logs. Using /proc/*/fd/ is not portable. Even ts_init's test for "/proc/self/fd" does not help because /proc/*/fd behaves strange here: $ ls -l /proc/$$/fd lr--r--r-- 1 rudi user 0 Mar 6 23:11 /proc/2194/fd -> unknown $ file /proc/$$/fd /proc/2194/fd: broken symbolic link to `unknown' ## wtf? $ test -d /proc/$$/fd; echo $? 0 $ ls -l /proc/$$/fd/ ls: cannot access /proc/2194/fd/: No such file or directory ## but $ ls -l /proc/self/fd/ total 0 cr-xr-xr-x 1 root root 0, 3 Mar 6 19:39 0 cr-xr-xr-x 1 root root 0, 4 Mar 6 19:39 1 cr-xr-xr-x 1 root root 0, 5 Mar 6 19:39 2 cr-xr-xr-x 1 root root 0, 6 Mar 6 19:39 3 This is how this patch changes the test output: [...] blkid: partitions probing: [06] sgi ... OK blkid: partitions probing: [07] sun ... OK blkid: partitions probing ... OK (all 7 sub-tests PASSED) -ls: cannot access /proc/66215/fd/: No such file or directory + blkid: mbr-wholedisk ... SKIPPED (missing scsi_debug module (dry-run)) blkid: MD raid0 (whole-disks) ... SKIPPED (losetup not found) blkid: MD raid1 (last partition) ... SKIPPED (missing in PATH: mdadm) blkid: MD raid1 (whole-disks) ... SKIPPED (losetup not found) @@ -343,11 +343,11 @@ dmesg: facilities ... SKIPPED (test_dmesg not found) dmesg: indentation ... SKIPPED (test_dmesg not found) eject: umount ... SKIPPED (eject not found) -ls: cannot access /proc/69561/fd/: No such file or directory -ls: cannot access /proc/69609/fd/: No such file or directory + fdisk: align 512/4K ... SKIPPED (missing scsi_debug module (dry-run)) + fdisk: align 512/4K +alignment_offset ... SKIPPED (missing scsi_debug module (dry-run)) fdisk: align 512/4K +MD ... SKIPPED (missing in PATH: mdadm) fdisk: align 512/512 ... SKIPPED (losetup not found) [...] Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: suppress warning for old sync(1)root2018-01-241-2/+2
| | | | | | | | | Old sync(1) prints a warning which looks ugly among our test output: "sync: ignoring all arguments" Seen on travis, Ubuntu <= 14.04 (Trusty). Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: unlocks on failed ts_scsi_debug_initKarel Zak2017-12-071-5/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: support multiple locksKarel Zak2017-12-071-6/+47
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: use flock to modify fstabKarel Zak2017-12-061-1/+10
| | | | | | | Note that for btrfs test we need to use low-level ts_fstab_addline, because we add multiple lines there. Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: add lock on shared resources (e.g. scsi_debug)Karel Zak2017-12-061-0/+27
| | | | | | | The patch enables flock for scsi_debug to avoid collision between tests. The patch also adds ./run.sh --nolocks to disable this feature. Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: add --enable-asan and --memcheck-asan for testsKarel Zak2017-11-231-1/+11
| | | | | | | | | The command ./configure --enable-asan adds -fsanitize=address to the compiler command line. In the regression tests leaks detection is disabled by default. You have to use --memcheck-asan on test command line to enable. Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: rename --memcheck to --memcheck-valgrindKarel Zak2017-11-231-9/+18
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: rename ts_valgrind to ts_runKarel Zak2017-11-231-1/+1
| | | | | | | Let's make our tests more generic, so we can later hide more stuff into ts_run call. Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: add --show-diffKarel Zak2017-02-161-0/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: add sfdisk --wipe and --wipe-partition testsKarel Zak2017-02-151-0/+10
| | | | | | 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>
* tests: let lsmod fail silentlyRuediger Meier2016-11-071-2/+2
| | | | | | | This is mostly for non-Linux systems where lsmod is not even available. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: consolidate rmmod scsi_debugRuediger Meier2016-10-211-5/+43
| | | | | | | | | - 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>
* tests: Use proper word splitting when executing testsFilipe Brandenburger2016-08-101-2/+2
| | | | | | | | | | | | | | 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>
* tests: implement ts_skip_subtestKarel Zak2016-07-111-5/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: fix for non-ncurses versionKarel Zak2016-06-091-0/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: make tests more portable due to mtabKarel Zak2016-04-151-0/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: don't depend on GNU md5sumRuediger Meier2016-04-131-1/+1
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: skip old socat silentlyRuediger Meier2016-03-131-8/+9
| | | | | | | 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>
* tests: fix non-working udevadm settle for scsi_debugRuediger Meier2016-03-091-2/+15
| | | | | | | | | | | 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>
* tests: don't skip case "output undefined"Ruediger Meier2016-03-071-30/+18Star
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* tests: add option --parsableRuediger Meier2016-03-051-4/+13
| | | | | | | | | | 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>
* tests: --parallel prints results in a single lineRuediger Meier2016-03-051-17/+20
| | | | | | | | | | | | | | 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>
* tests: fix ts_option helpersRuediger Meier2016-02-181-2/+4
| | | | | | | | | 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>
* tests: ts_fdisk_clean(), remove optimal iosizeRuediger Meier2016-02-101-0/+1
| | | | | | | | 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>
* tests: minor cleanup ts_fdisk_clean()Ruediger Meier2016-02-101-12/+12
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: fallback for missing TS_DESCKarel Zak2016-01-051-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: always create sparse image filesRuediger Meier2016-01-051-1/+2
| | | | | | This saves about 400M disk I/O and space. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: no more sleep, udevadm settle onlyRuediger Meier2016-01-051-1/+0Star
| | | | | | This seems to work nowadays and saves 37s. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: add sfdisk --move-data testKarel Zak2015-09-091-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: add $top_builddir to $PATHRuediger Meier2015-05-081-0/+3
| | | | | | | | | | 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>
* Merge branch 'tests-refactor-loop-cleanup' of ↵Karel Zak2015-04-221-13/+29
|\ | | | | | | | | | | | | | | | | | | | | 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()
| * tests: introduce TS_LOOP_DEVS for cleanupRuediger Meier2015-04-141-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * tests: introduce ts_cleanup_on_exit()Ruediger Meier2015-04-141-5/+11
| | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'tests-logger' of https://github.com/rudimeier/util-linuxKarel Zak2015-04-141-0/+29
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * '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
| * | tests: logger with socat deviceRuediger Meier2015-04-131-0/+29
| |/ | | | | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* / tests: make libmount context tests sensitive to USE_LIBMOUNT_FORCE_MOUNTINFOKarel Zak2015-04-141-1/+1
|/ | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: ts_scsi_debug_init() sleeps a bit earlierRuediger Meier2015-04-021-4/+4
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: add --skip-loopdevsKarel Zak2015-03-171-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: optionally skip tests where loop support is neededRuediger Meier2015-03-161-0/+4
| | | | | | | | | 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>
* tests: improve some wordings of the outputBenno Schulenberg2015-02-191-3/+3
| | | | | | | 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>
* tests: python tests should not remove user's LD_LIBRARY_PATHRuediger Meier2015-01-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>