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