Skip to content

Commit

Permalink
tests: fix prompting test case where client expects error
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
  • Loading branch information
olivercalder committed Oct 21, 2024
1 parent 6649587 commit eeb8e0d
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ if ! snap run --shell prompting-client.scripted -c "ls ${TEST_DIR}/Downloads" |
exit 1
fi

echo "Attempt to write the file"
echo "Attempt to write the file, to which the client should reply with a conflicting rule and exit with error"
snap run --shell prompting-client.scripted -c "echo it is written > ${TEST_DIR}/Downloads/test.txt"

echo "Attempt to chmod the file after it has been written"
snap run --shell prompting-client.scripted -c "chmod 664 ${TEST_DIR}/Downloads/test.txt"
echo "Don't attempt to chmod the file after it has been written, since the client should have exited"

# Wait for the client to write its result and exit
timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done"
Expand All @@ -34,7 +33,7 @@ CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")"
# We don't expect success, since there should be a rule conflict with the rule
# we just added to grant read access forever
if [ "$CLIENT_OUTPUT" = "success" ] ; then
echo "test unexpectedly succeeded, expected rule conflict error"
echo "client reply unexpectedly succeeded, expected rule conflict error"
echo "output='$CLIENT_OUTPUT'"
exit 1
fi
Expand Down

0 comments on commit eeb8e0d

Please sign in to comment.