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
|
summary: Check that IIO device nodes are accessible through an interface
details: |
This test makes sure that a snap using the IIO interface can access
devices nodes exposed by a slot properly.
It modifies the core snap to provide a iio slot. The actual iio device
node is served as a plain file with static text content. The test expects
that, after a snap declared a iio plug is installed and connected, it can
access the node and read/write its content.
systems: [ubuntu-core-*-64]
prepare: |
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
# Mock IIO device node and give it some content we can verify
# the test snap can read.
echo "iio-0" > /dev/iio:device0
echo "Given a snap declaring a plug on iio is installed"
"$TESTSTOOLS"/snaps-state install-local iio-consumer
echo "And the iio plug is connected"
snap connect iio-consumer:iio core:iio0
restore: |
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
rm -f /dev/iio:device0
execute: |
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
echo "Checks the snap can read from the IIO device node"
SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
test "$("$SNAP_MOUNT_DIR"/bin/iio-consumer.read)" = "iio-0"
echo "Checks the snap can write to the IIO device node"
"$SNAP_MOUNT_DIR"/bin/iio-consumer.write "hello"
test "$("$SNAP_MOUNT_DIR"/bin/iio-consumer.read)" = "hello"
|