Commit Graph

53 Commits

Author SHA1 Message Date
Karel Zak 70a7b61a84 tests: update mountpoint tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-11 10:52:11 +01:00
Karel Zak 1161323b5a tests: update swaplabel.err
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-06 11:13:15 +01:00
Sami Kerola bd66eb2e43 tests: move misc/ul to ul/ directory
Reference: https://github.com/karelzak/util-linux/pull/1165#issuecomment-715173662
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-11-09 16:31:59 +01:00
Samanta Navarro 062e6a3945 whereis: extend test case
Previous commits are covered with these test cases.

Removed dependency on system layout.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2020-11-04 11:43:09 +00:00
Mark Hindley 3e93958117 tests: Fix mountpoint test failure in build chroots.
The test assumed that / was a mountpoint. This is not always the case, for
example in pbuilder/cowbuilder chroots. So use / if findmnt verifies it is a
mountpoint, otherwise use the first mountpoint found. Skip the test if no
mountpoints are found.

Signed-off-by: Mark Hindley <mark@hindley.org.uk>
2020-06-24 15:44:44 +02:00
Karel Zak f12d5ad279 lib/strutils: fix uint64_t overflow
Addresses: https://github.com/karelzak/util-linux/issues/998
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-17 10:25:17 +02:00
Karel Zak b38c20e13a ilib/strutils: fix rounding in size_to_human_string()
Thanks to bub75 for the idea.

The patch adds SIZE_DECIMAL_2DIGITS into regression tests.

Addresses: https://github.com/karelzak/util-linux/issues/998
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-15 15:06:37 +02: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 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 11aaedf574 tests: use subtests for mountpoint(1)
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-07 11:45:57 +02:00
Sami Kerola 6d56251220
mountpoint: add --nofollow option
The no follow option will allow user to distinct mount points from symbolic
links pointing to them.  Arguably this is pretty pedantic option, mounting a
device or bind mount to a directory via symlink does not have or cause any
issues.

Addresses: https://github.com/karelzak/util-linux/issues/832
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-02 19:39:05 +01:00
Karel Zak 7895231321 tests: update setarch test
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-01 16:53:45 +01:00
Vaclav Dolezal 910a879f3d tests: mbsencode - removed emoji, added control unicode character
Emojis are apparently too recent to be reliably recognised as printable
on test machines.

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-01-11 10:38:43 +01:00
Vaclav Dolezal cad13ba344 tests: add tests for encode functions from lib/mbsalign.c
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-01-10 17:40:53 +01:00
Ruediger Meier 5abaf5b035 tests: add more tests for line(1)
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-14 11:48:22 +02:00
Ruediger Meier 22edf0a639 Revert "tests: use stdbuf when stderr and stdout is randomly ordered"
stdbuf does not seem to work reliable. Failed on travis/OSX

This reverts commit 398b3148be.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-01 11:24:00 +02:00
Ruediger Meier 398b3148be tests: use stdbuf when stderr and stdout is randomly ordered
glibc seems to flush stdout before stderr.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-01 10:28:02 +02:00
Karel Zak 10146e56b0 tests: add flock tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-31 14:30:02 +01:00
Karel Zak b6782d8697 tests: move getopt to separate directory
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-22 13:39:31 +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 33bed90a7f tests: improve setarch tests, regarding --uname-2.6 issues
Add some more tests:
  * error handling "unknown arch" and "unknown command"
  * "noop" test with host arch and no other options
  * all options except --uname-2.6
  * --uname-2.6 whithout any other options but handle fatal
    glibc error "kernel too old" (with debug output)
  * add a "real" --uname-2.6 test which validates uname(1)
    output

Note the "kernel too old" cases are systems where glibc was
configured to support only kernels > 3.0. On some archs
(e.g. x86) --uname-2.6 still works with such glibc because
2.6.39 had all needed features on board (e.g. vdso).
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=806911

Some people reported segfaults (after execvp) but I can only
reproduce it on arm* and aarch64 qemu-user-space builds. We
don't need to fix our tests for such broken systems where
also many other tests fail currently.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-24 08:14:34 +01:00
Ruediger Meier 9508e2972b setarch: add "exec" message to --verbose
Also we don't need fflush() in non-verbose case.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-22 14:13:33 +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
Karel Zak 7ed6a6a00d tests: make swaplabel test more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-26 16:49:39 +01:00
Karel Zak b35831b755 tests: update swapfile output
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-26 16:02:54 +01:00
Ruediger Meier caad4ded12 tests: add some line tests
regarding e03f29b6 ...

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-12-03 01:56:53 +01:00
Ruediger Meier 89342005bc tests: fix swaplabel test for 9a83b03c
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-01-26 15:18:31 +01:00
Ruediger Meier fc39d106d2 Revert "tests: simplify and update swaplabel test"
After mkswap refactoring we have still a "minimal swap size"
wich depend on PAGE_SIZE. Next commit will fix the test for
output changes made in 9a83b03c.

This reverts commit b4d27255f2.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-01-26 14:31:46 +01:00
Sami Kerola d458000dea tests: add more getopt tests
After importing Frodo's tests I ran coverage to see if something had
remained unchecked, and there were couple tests that could be done.

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-08 20:07:00 +00:00
Sami Kerola 93575f2943 tests: copy test-suite from Frodo Looijaard's getopt
The test cases and their names are the same, but the surrounding testing
facility with Frodo's svn and util-linux are pretty different so this is
not exactly 1:1 copy.

Reference: svn://svn.frodo.looijaard.name/public/getopt/trunk/tests
CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-08 20:07:00 +00:00
Karel Zak b4d27255f2 tests: simplify and update swaplabel test
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-10 11:46:46 +01:00
Ruediger Meier 34c265f01c setarch: flush output streams before exec
This fixes the following (non-deterministic) discrepancy:

$ setarch x86_64 -RFZLvXBIST3 --uname-2.6 echo success
Switching on READ_IMPLIES_EXEC.
Switching on ADDR_LIMIT_32BIT.
Switching on SHORT_INODE.
Switching on WHOLE_SECONDS.
Switching on STICKY_TIMEOUTS.
Switching on ADDR_LIMIT_3GB.
Switching on UNAME26.
success

$ setarch x86_64 -RFZLvXBIST3 --uname-2.6 echo success  &> /tmp/bla; cat /tmp/bla
success

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-22 09:41:24 +02:00
Ruediger Meier d61bff4e2b tests: swaplabel needs to respect pagesize
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-03-15 01:25:02 +01:00
Sami Kerola 59ac7e76c6 tests: check swaplabel, and perform more swapon boundary tests
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-03-12 12:06:35 +01:00
Karel Zak 093407a585 tests: update ionice test
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-17 14:30:03 +01:00
Sami Kerola 7c7061f771 rev: stop adding new line at the end when input does not have it
When the rev(1) is executed twice outcome is expected to be exactly what
it was originally.  That includes not adding new line at the end of the
output.  The oneliner below demonstrates earlier issue.

$ printf "abc\n123" | rev | rev

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-06-07 12:24:46 +02:00
Karel Zak 7cabfd8677 tests: use checksum to detect rev(1) consistency
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-05 09:38:46 +01:00
Sami Kerola a94c2240a7 tests: add whereis(1) check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 10:29:34 +01:00
Sami Kerola 724454828f tests: add fallocate(1) check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 10:09:36 +01:00
Sami Kerola b74fe86e1d tests: add setarch(8) check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 10:09:36 +01:00
Sami Kerola ee65de0b07 tests: add setsid(1) check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 10:09:36 +01:00
Sami Kerola f49b9ec780 tests: add line(1) check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 10:09:35 +01:00
Sami Kerola 2464558fdf tests: add ionice(1) check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-24 16:49:34 +01:00
Sami Kerola 2613a5dd14 tests: add ul(1) check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-24 16:49:33 +01:00
Sami Kerola 0dcb8fe8cb tests: add mcookie(1) check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-24 16:49:31 +01:00
Sami Kerola c5565210b6 tests: add getopt(1) check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-24 16:49:29 +01:00
Sami Kerola 5390fbe958 tests: add rev(1) check
Fairly lenghty input line tries to ensure realloc segment in code is hit
at least once.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-24 16:49:25 +01:00
Francesco Cosoleto 5d2a98490e This adds a second parameter to size_to_human_string() to return a
string with a different format based on the following flags:

        SIZE_SUFFIX_1LETTER  = "1K"
        SIZE_SUFFIX_3LETTER  = "1KiB",
        SIZE_SUFFIX_SPACE    = "1 KiB" or "1 K"

[kzak@redhat.com: - rename flags to SIZE_SUFFIX_* format,
                  - fix suffix[] buffer size
                  - add 3 letter version to the test]

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-26 15:32:33 +02:00
Dave Reisner f9e05dafd0 lib: [strutils] avoid integer overflow on large values
This is visible on a 2TB disk via lsblk, where a large partition
incorrectly displays as 1.171798692T instead of 1.8T. This is
corrected by using a uint64_t type instead of a simple int --
consistant with the type used in lsblk.c to represent the raw size in
bytes.

[kzak@redhat.com: - add EiB support
                  - add size_to_human_string() to regression tests]

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-15 10:13:31 +01:00