24 Commits

Author SHA1 Message Date
Milan Broz
c9008528f9 tests: Remove function xx() bashism.
Posix does not use function keyword, moreover, we use it inconsistently.
2025-01-27 20:43:33 +01:00
Milan Broz
3d535dcf31 tests: Add trap for segfault and sigabrt
If bash test script uses a pattern that test that command should fail
  command && fail
(IOW fail function is called only if command exited successfully),
it can mask potential segfault, as it return non-zero exit code.

Fix it by using trap for scripts that uses this pattern.

The same applies for SIGABRT (abort() call).
2025-01-27 20:42:25 +01:00
Ondrej Kozina
9a5a3855a0 Enable valgrind tests in meson. 2023-11-15 18:40:44 +01:00
daniel.zatovic
429afe8fc3 Add valgrind support to more tests. 2022-08-10 07:45:13 +00:00
Milan Broz
8531a8a753 Skip more tests if --disable-cryptsetup is used.
If there is no cryptsetup, some tests returns ok while noting was
tested in reality. Just mark them skipped.
2022-02-02 21:29:54 +01:00
Guilhem Moulin
cbc143bf95 tests: Replace which calls with command -v.
AFAIK older versions of the POSIX Standard didn't specify a way to
locate commands.  Many operating systems and distributions added a
which(1) utility for that purpose, unfortunately without consistent
behavior across the board.

OTOH POSIX.1-2008 (or was it older?  POSIX.1-2001 mentions it too, but
with a restriction: “On systems supporting the User Portability Utilities
option”) specifies that `command -v` can be used for that purpose:

    https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/utilities/command.html

Moreover the standard adds that if the argument is neither a valid
utility, builtin, shell function nor alias then “no output shall be
written and the exit status shall reflect that the name was not found”.
It's therefore no longer needed to void the error output (spewing error
messages was one of the inconsistent behavior of the different which(1)
utilities).

The upcoming Debian 12 (codename Bookworm) appears to have deprecated
its which(1) utility (as a first step for its removal from the base
system):

    $ which foo
    /usr/bin/which: this version of `which' is deprecated; use `command -v' in scripts instead.

In most places the deprecation notice isn't visible when running the
test suite because most `which` calls run with the error output
redirected to /dev/null, however this is not the case everywhere:

    https://gitlab.com/cryptsetup/cryptsetup/-/blob/v2.4.3/tests/integrity-compat-test#L333
    https://gitlab.com/cryptsetup/cryptsetup/-/blob/v2.4.3/tests/reencryption-compat-test2#L232

This commit replaces all `which` calls from tests/* with `command -v`,
and removes the error output redirection.
2022-01-15 08:50:15 +00:00
Milan Broz
0a7c13207d Fix broken loopaes test.
We actually try to write file in /dev because the device is deactivated.

Broken since 2018 in 8728ba08e2
2021-03-25 00:07:53 +01:00
Milan Broz
ff364347cf Add FAIL backtrace to all bash tests. 2019-06-20 15:11:56 +02:00
Ondrej Kozina
ff0030d74f Add missing --retry parameter in tests cleanup. 2019-06-18 13:26:20 +02:00
Milan Broz
456ab38caa Allow to set CRYPTSETUP_PATH in tests for system installed cryptsetup tools.
Run: make check CRYPTSETUP_PATH=/sbin
2019-03-08 08:16:45 +01:00
Milan Broz
943cc16020 Fix test to print exit line and use explicit key size. 2019-01-25 13:38:24 +01:00
Milan Broz
8728ba08e2 Fix loopaesOpen for keyfile on standard input.
The change in keyfile processing caused that special loopAES
keyfiles are no longer read from stdin if key-file argument is "-".

Fix it by using /dev/stdin in cryptsetup if "-" is detected.
(The libcryptsetup API no longer parses spacial meaning of "-" internally).

Fixes #364.
2018-01-24 09:05:52 +01:00
Milan Broz
d77bbe93c1 Use non-recursive automake.
This change also causes that now binaries and libraries are placed in
build root directory.

Now we can use subdir-objects for automake.
2017-10-12 11:48:17 +02:00
Milan Broz
1c2cc9f35c Do not print error output from older "which" command in tests. 2017-10-11 08:04:02 +02:00
Milan Broz
a0880b64f2 Add magic exit code for automake to count skipped tests. 2017-08-23 16:54:04 +02:00
Milan Broz
8b8e206c07 Skip multikey if not supported (e.g. FIPS mode - md5 for IV not available). 2012-07-12 12:53:26 +02:00
Milan Broz
8256b673a1 Fix offset parameter.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@482 36d66b0a-2a48-0410-832c-cd162a569da5
2011-03-22 21:11:28 +00:00
Milan Broz
2072adf705 Also support --skip option for loopaesOpen.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@481 36d66b0a-2a48-0410-832c-cd162a569da5
2011-03-22 20:51:50 +00:00
Milan Broz
bce295738b Fix offset option for loopaesOpen.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@476 36d66b0a-2a48-0410-832c-cd162a569da5
2011-03-21 17:48:30 +00:00
Milan Broz
4505d0a36b Add defaults to --help output.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@460 36d66b0a-2a48-0410-832c-cd162a569da5
2011-03-14 13:41:00 +00:00
Milan Broz
9ba3bb3a5e Fix loopaes open parameters.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@458 36d66b0a-2a48-0410-832c-cd162a569da5
2011-03-14 00:07:39 +00:00
Milan Broz
2124cbf5ee Fix error output redirection in tests.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@439 36d66b0a-2a48-0410-832c-cd162a569da5
2011-03-10 21:01:49 +00:00
Milan Broz
eb29f40384 Allocate free loop devices instead of using hardcoded.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@438 36d66b0a-2a48-0410-832c-cd162a569da5
2011-03-10 20:18:40 +00:00
Milan Broz
4f3a65a629 Add simple Loop-AES compatibility check.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@437 36d66b0a-2a48-0410-832c-cd162a569da5
2011-03-10 17:16:03 +00:00