Skip to content

Commit

Permalink
Merge pull request #362 from google/fix-cli-tests-2
Browse files Browse the repository at this point in the history
cli-tests: account for protojson whitespace randomization
  • Loading branch information
josephlr committed Aug 19, 2022
2 parents f0c1cae + afad6a1 commit a1ddf6e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion cli-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ filter_test_output()
# "bash: line 1: " instead of just "bash: ". Filter out the "line 1: ".
sedscript+="s@^bash: line 1: @bash: @;"

# Work around protojson whitespace randomization.
sedscript+="/^Options: /s@ @ @g;"
sedscript+="s@^Options: @Options: @;"

sed -e "$sedscript" "$raw_output"
}

Expand Down Expand Up @@ -162,7 +166,7 @@ setup_for_test()
fscrypt setup --time=1ms --quiet --all-users > /dev/null

# The tests assume kernel support for v2 policies.
if ! grep -q '"policy_version": "2"' "$FSCRYPT_CONF"; then
if ! grep -E -q '"policy_version": +"2"' "$FSCRYPT_CONF"; then
cat 1>&2 << EOF
ERROR: Can't run these tests because your kernel doesn't support v2 policies.
You need kernel v5.4 or later.
Expand Down
2 changes: 1 addition & 1 deletion cli-tests/t_v1_policy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mkdir "$dir"
chown "$TEST_USER" "$dir"

_print_header "Set policy_version 1"
sed -i 's/"policy_version": "2"/"policy_version": "1"/' "$FSCRYPT_CONF"
sed -E -i 's/"policy_version": +"2"/"policy_version": "1"/' "$FSCRYPT_CONF"

_print_header "Try to encrypt as root"
_expect_failure "echo hunter2 | fscrypt encrypt --quiet --name=prot '$dir'"
Expand Down
4 changes: 2 additions & 2 deletions cli-tests/t_v1_policy_fs_keyring.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ cd "$(dirname "$0")"
. common.sh

_print_header "Enable v1 policies with fs keyring"
sed -e 's/"use_fs_keyring_for_v1_policies": false/"use_fs_keyring_for_v1_policies": true/' \
-e 's/"policy_version": "2"/"policy_version": "1"/' \
sed -E -e 's/"use_fs_keyring_for_v1_policies": +false/"use_fs_keyring_for_v1_policies": true/' \
-e 's/"policy_version": +"2"/"policy_version": "1"/' \
-i "$FSCRYPT_CONF"

dir="$MNT/dir"
Expand Down

0 comments on commit a1ddf6e

Please sign in to comment.