test/devices.bats: fix "additional device permissions" case
Using /dev/loop-control is problematic since it is not supposed
to be read from or written to.
Use /dev/kmsg, and actually enable the write test.
@@ -41,7 +41,7 @@ EOF
@test "additional devices permissions" {
# We need a ubiquitously configured device that isn't in the
# OCI spec default set.
- declare -r device="/dev/loop-control"
+ declare -r device="/dev/kmsg"
declare -r timeout=30
if ! test -r $device; then
@@ -63,21 +63,20 @@ EOF
if ! is_cgroup_v2; then
# Dump the deviced cgroup configuration for debugging.
output=$(crictl exec --timeout=$timeout --sync "$ctr_id" cat /sys/fs/cgroup/devices/devices.list)
- [[ "$output" == *"c 10:237 w"* ]]
+ [[ "$output" == *"c 1:11 w"* ]]
fi
# Opening the device in read mode should fail because the device
# cgroup access only allows writes.
- run crictl exec --timeout=$timeout --sync "$ctr_id" dd if=$device of=/dev/null count=1
+ run crictl exec --timeout=$timeout --sync "$ctr_id" head -1 $device
[ "$status" -ne 0 ]
[[ "$output" == *"Operation not permitted"* ]]
- # The write should be allowed by the devices cgroup policy, so we
- # should see an EINVAL from the device when the device fails it.
- # TODO: fix that test, currently fails with "dd: can't open '/dev/loop-control': No such device non-zero exit code"
- # run crictl exec --timeout=$timeout --sync "$ctr_id" dd if=/dev/zero of=$device count=1
- # echo $output
- # [[ "$output" == *"Invalid argument"* ]]
+ # The write should be allowed by the devices cgroup policy
+ run crictl exec --timeout=$timeout --sync "$ctr_id" sh -c "echo woohoo | tee $device"
+ [ "$status" -eq 0 ]
+ # check there's no error message of any kind from tee
+ [[ "$output" == "woohoo" ]]
}
@test "annotation devices support" {
