Commit Graph

151 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek d4c880d5a4 meson: add second build system
To build: meson build && ninja -C build
To run tests: ninja -C build check
To install for packaging: DESTDIR=/var/tmp/inst ninja -C build install
To install for realz: sudo ninja -C build install

v2:
- Optional items are now based on the 'feature' feature in meson.
  Built libraries which are disabled turn into disabler() objects
  and also poison any executables which link to them.

What is there:
- building of the binaries and libs and the python module
- installation of binaries, libs, python module, localization files,
  man pages, pkgconfig files
- running of tests
- most options to configure build equivalently to the
  ./configure settings

Partially implemented:
- disabling of stuff when things missing. In the C code, the defines
  are all used, so that should be fine. In the build system, some
  files should be skipped, but that is probably not always done properly.
  Getting this right might require some testing of various build option
  combinations to get the details right.

Not implemented:
- static builds of fdisk and other binaries
- things marked with XXX or FIXME
- ???

Differences:
- .la files are not created. They are useless and everybody hates them.
- Requires.private in pkgconfig files are not present in the
  autogenerated .pc file. Not sure if they should be there or not. If
  necessary, they can be added by hand.
- man pages and systemd units are installed by the install target. Not
  sure why 'make install' doesn't do that.
- the split between / and /usr is probably wrong. But it's all pointless
  anyway, so maybe we could simplify things but not implementing it at
  all under meson?
2021-03-17 15:07:27 +01:00
Frantisek Sumsal 81edf9f0da ci: deal with uninstrumented binaries using instrumented libs
All `eject` tests were failing under ASan, since they call /bin/mount,
which is uninstrumented, but it picks up the instrumented `libblkid`
library, causing ASan to complain:

gcc:
ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
eject: unmount of `/home/runner/work/util-linux/util-linux/tests/output/eject/umount-by-disk-mounted-mnt' failed

clang:
/bin/umount: symbol lookup error: /home/runner/work/util-linux/util-linux/.libs/libblkid.so.1: undefined symbol: __sancov_lowest_stack
eject: unmount of `/home/runner/work/util-linux/util-linux/tests/output/eject/umount-by-disk-mounted-mnt' failed

Subsequently, all tests which require the `scsi_debug` module get skipped,
since it's still in use due to the failed umount:

fdisk: align 512/4K                   ... SKIPPED (cannot remove scsi_debug module (rmmod))
fdisk: align 512/4K +alignment_offset ... SKIPPED (cannot remove scsi_debug module (rmmod))
fdisk: align 512/4K +MD               ... SKIPPED (cannot remove scsi_debug module (rmmod))

In case of gcc this can be easily resolved by setting $LD_PRELOAD to the
respective ASan library. clang makes this a bit more difficult, since it
compiles the ASan library statically, so firstly we need to force dynamic
linking (via -shared-asan), and then add the runtime DSO path to the
linker cache, since it's in a non-standard path.
2021-02-01 12:00:30 +01:00
Karel Zak bf7e7d5c84 tests: dump more information about CFS and block devices
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-26 10:30:01 +01:00
Evgeny Vereshchagin 78905e4450 tests: take exit codes into account
In its current form the testsuite isn't suitable for running
fuzz targets because it ignores exit codes and relies solely
on diffs (that unfortunately aren't helpful because the nondeterministic
nature of fuzz targets makes it kind of hard to specify expected output
in advance). This patch is supposed to address the "exit code" issue for now.

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 1b9f2ff333 tests: turn off detect_leaks on s390x, use more asan options
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-07-03 13:26:08 +00:00
Evgeny Vereshchagin e6a4d8cc06 build-sys: add --enable-ubsan to make it possible to build util-linux with UBSan
mostly to prepare for https://github.com/karelzak/util-linux/pull/1068
but it's useful even without fuzzing.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-07-03 11:17:53 +02:00
Karel Zak e7db499f1c tests: cleanup fdisk based stuff
* use fdisk --noauto-pt to avoid re-creation of the default architecture specific PT
* use more verbose "Created a new" messages in the output

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-24 14:30:16 +01:00
Karel Zak eb61e95f1c tests: remove unbuffered ts_run feature
It's unnecessary as stdout and stderr are split in the tests.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-30 16:30:35 +02:00
Karel Zak cbf858aa08 tests: split stdout and stderr
* add $TS_ERRLOG for script stderr output
* add optional $TS_EXPECTED_ERR which points to expected/*/*.err

This change allows to keep track about stderr output from our commands
(already found bug in sfdisk...).

We do not have to depend on fragile stdout vs. stderr order (due to
different buffering semantic in different libc, etc.).

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-30 15:50:07 +02:00
Patrick Steinhardt 59a46f36b6 tests: use env and support both unbuffer/stdbuf
Triggered by commit f612c4c67 (tests: fix --unbuffered mode with
ASAN, 2019-08-27), which says:

    Well, this patch sucks. It would be nice to have things in
    the way how it has been original expected by Patrick's patch,
    but ...

So this commit here effectively reverts it and instead tries to
improve the shortcomings of the original patch. First, it uses
env(1) to set ASAN_OPTIONS instead of directly adding it to the
args array to fix execution of "${args[@]}" "$@".

Second, it now supports both unbuffer(1) and stdbuf(1). The
latter uses LD_PRELOAD tricks, which doesn't play nicely with
ASAN, so it will not be used if ASAN has been requested. It's
still valuable to have support for both, as many more systems
will have stdbuf(1) from coreutils installed but not unbuffer(1)
from expect.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-28 08:56:24 +02:00
Karel Zak 71210f5bab tests: don't show diff for TS_KNOWN_FAIL
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-27 14:38:21 +02:00
Karel Zak 751fae0d96 tests: improve unbuffer check
* remove obsolete stdbuf check

* check for unbuffer command in ts_run() than skip all test

Reported-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-27 14:28:11 +02:00
Karel Zak f612c4c674 tests: fix --unbuffered mode with ASAN
Unfortunately, ASAN is pretty sensitive to LD_PRELOAD, but stdbuf from
coreutils is based on LD_PRELOAD. So, I have replaced stdbuf with
unbuffer (from expect pkg).

The another problem is "${args[@]}" "$@" which does not work as expected.

Well, this patch sucks. It would be nice to have things in the way
how it has been original expected by Patrick's patch, but ...

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-27 13:02:38 +02:00
Patrick Steinhardt 801d689e47 tests: remove reliance on buffer behaviour of stderr/stdout streams
In the test cases "rename::exit_codes" and "rename::exit_codes", we rely
on the flushing behaviour of stderr and stdout streams relative to each
other. Streams in glibc will not flush on newlines if stdout is pointing
to a non-TTY file descriptor, but relying on this is fragile and may
break on systems with a different behaviour like musl libc.

Fix this by introducing a new parameter "--unbuffered" to `ts_run`. If
this parameter is passed and stdbuf(1) from coreutils is available, then
it will use it to disable buffering of standard output completely. Like
this, we can selectively run tests with this if ordering of messages
from stdout and stderr is being checked.

Signed-off-by: Patrick Steinhardt <ps@pks.im>

x
2019-08-27 09:36:05 +02:00
Karel Zak 7c90efa384 tests: add --noskip-commands
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>
2019-03-05 11:06:41 +01:00
Karel Zak 43b4a4d3c7 tests: add --use-system-commands
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>
2019-03-04 17:14:12 +01:00
Karel Zak 51684b312e tests: use libtool to execute with valgrind
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>
2018-03-21 12:23:22 +01:00
Ruediger Meier 9ca02cf52d tests: consolidate ts_device_has UUID or LABEL
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>
2018-03-19 11:46:11 +01:00
Ruediger Meier ec182d8b9d tests: fix grep expressions for devices
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>
2018-03-19 11:46:11 +01:00
Ruediger Meier 539b0b09ea tests: re-introduce bash 3 compatibility (OSX)
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>
2018-03-08 12:04:44 +01:00
Ruediger Meier 55a680c17f tests: dont't timeout flock
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>
2018-03-07 19:12:54 +01:00
Ruediger Meier b0d9114a61 tests: don't use unlocked resources
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>
2018-03-07 19:11:36 +01:00
Ruediger Meier 613a337ed4 tests: don't lock fd 1 (stdout), don't use /proc/$$/fd
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>
2018-03-07 18:41:04 +01:00
root 20432749c1 tests: suppress warning for old sync(1)
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>
2018-01-24 12:53:35 +01:00
Karel Zak 44d753407d tests: unlocks on failed ts_scsi_debug_init
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-07 15:08:29 +01:00
Karel Zak 7acd4b463a tests: support multiple locks
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-07 14:41:08 +01:00
Karel Zak e140506af3 tests: use flock to modify fstab
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>
2017-12-06 15:55:09 +01:00
Karel Zak 9deb8c7dfd tests: add lock on shared resources (e.g. scsi_debug)
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>
2017-12-06 14:21:38 +01:00
Karel Zak b97cc9a829 build-sys: add --enable-asan and --memcheck-asan for tests
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>
2017-11-23 14:59:05 +01:00
Karel Zak d3f58f8aee tests: rename --memcheck to --memcheck-valgrind
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-23 14:03:23 +01:00
Karel Zak 02ae505fd4 tests: rename ts_valgrind to ts_run
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>
2017-11-23 13:44:53 +01:00
Karel Zak 74fe554a41 tests: add --show-diff
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-16 14:14:54 +01:00
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