Debian Codegraph @

cli-tests/README.md

raw
1 # fscrypt command-line interface tests
2
3 ## Usage
4
5 To run the command-line interface (CLI) tests for `fscrypt`, ensure
6 that your kernel is v5.4 or later and has `CONFIG_FS_ENCRYPTION=y`.
7 Also ensure that you have the following packages installed:
8
9 * e2fsprogs
10 * expect
11 * keyutils
12
13 Then, run:
14
15 ```shell
16 make cli-test
17 ```
18
19 You'll need to enter your `sudo` password, as the tests require root.
20
21 If you only want to run specific tests, run a command like:
22
23 ```shell
24 make && sudo cli-tests/run.sh t_encrypt t_unlock
25 ```
26
27 ## Updating the expected output
28
29 When the output of `fscrypt` has intentionally changed, the test
30 `.out` files need to be updated. This can be done automatically by
31 the following command, but be sure to review the changes:
32
33 ```shell
34 make cli-test-update
35 ```
36
37 ## Writing CLI tests
38
39 The fscrypt CLI tests are `bash` scripts named like `t_*.sh`.
40
41 The test scripts must be executable and begin by sourcing `common.sh`.
42 They all run in bash "extra-strict mode" (`-e -u -o pipefail`). They
43 run as root and have access to the following environment:
44
45 * `$DEV`, `$DEV_ROOT`: ext4 filesystem images with encryption enabled
46
47 * `$MNT`, `$MNT_ROOT`: the mountpoints of the above filesystems.
48 Initially all filesystems are mounted and are setup for fscrypt.
49 Login protectors will be stored on `$MNT_ROOT`.
50
51 * `$TMPDIR`: a temporary directory that the test may use
52
53 * `$FSCRYPT_CONF`: location of the fscrypt.conf file. Initially this
54 file exists and specifies to use v2 policies with the default
55 settings, except password hashing is configured to be extra fast.
56
57 * `$TEST_USER`: a non-root user that the test may use. Their password
58 is `TEST_USER_PASS`.
59
60 Any output (stdout and stderr) the test prints is compared to the
61 corresponding `.out` file. If a difference is detected then the test
62 is considered to have failed. The output is first sent through some
63 standard filters; see `run.sh`.
64
65 The test is also failed if it exits with nonzero status.
66
67 See `common.sh` for utility functions the tests may use.