mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
* New work ir organization for nested execution
* Fixes after merge
* Remove image dir call
* Fixes for tests
* Each image has an id to be distint for other images created manually
* Fix shell check error
* Save and restore compressed images
* Fixes for tests which failed
* Just keep 1 image
* Small fixes for default run
* Add checks for channels
* Fix issues found during execution
* Add new check for hotplug
* As core could be installed from any source, the version could be anything
It is tested on listing test so here just verify the channel is correct
* Fix core version check for core built from current branch
* test fix
* Fix shellcheck issue in spread.yaml
* New documentation for nested tests
* Update default value for SPREAD_BUILD_SNAPD_FROM_CURRENT var
* Fix documentation
* Using LOGS_DIR to read serial.log in spread.yaml
* Using local vars on functions and prefix NESTED_ for global vars
* Fix global variable without NESTED_ prefix
* Fix another var without NESTED_ prefix
* break case in case the system is rebooted after refresh or revert
* Update var names in github actions configuration
* Update vars without NESTED_
* Add another NESTED_ prefix
* Fix for cloud-init test
* Updating documentation with new names for variables
* Updating the name of the nested functions with prefix nested_
* Making simpler the management of the images and the compression
* Update variable names, moving SPREAD_NESTED_ to NESTED_
* Gracefull shutdown for the vm
* Fix shellcheck
* fix missing import
* Support parameters on generic function nested_get_image_url_for_vm
* Shell check fix
* Fix shellcheck of function
* Sync after the users are created to avoid issue after restart the vm
* Minor fix to locate correctly the assets
* Updating function names
* Fix for {} on function nested_configure_cloud_init_on_core20_vm
* Updating nested_execute function name
* Small fixes addressing review comments
* Adding 3 small fixes
110 lines
3.5 KiB
Bash
110 lines
3.5 KiB
Bash
#!/bin/bash
|
|
|
|
# shellcheck source=tests/lib/nested.sh
|
|
. "$TESTSLIB"/nested.sh
|
|
|
|
|
|
hotplug_add_dev1() {
|
|
nested_add_tty_chardev my-chardev1 /tmp/serialport1
|
|
nested_add_usb_serial_device my-usb-serial my-chardev1 1234
|
|
}
|
|
|
|
hotplug_del_dev1() {
|
|
nested_del_device my-usb-serial
|
|
nested_remove_chardev my-chardev1
|
|
}
|
|
|
|
hotplug_add_dev2() {
|
|
nested_add_tty_chardev my-chardev2 /tmp/serialport2
|
|
nested_add_usb_serial_device my-usb-serial2 my-chardev2 5678
|
|
}
|
|
|
|
hotplug_del_dev2() {
|
|
nested_del_device my-usb-serial2
|
|
nested_remove_chardev my-chardev2
|
|
}
|
|
|
|
# Check that given slot is not present in 'snap connections' output
|
|
# (note, it can still be present in the state with hotplug-gone=true)
|
|
check_slot_not_present() {
|
|
SLOT_NAME="$1"
|
|
for _ in $(seq 10); do
|
|
if ! nested_exec "snap connections system" | MATCH ":$SLOT_NAME"; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
if nested_exec "snap connections system" | MATCH ":$SLOT_NAME "; then
|
|
echo "slot $SLOT_NAME shouldn't be present anymore"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Check that given slot is present in 'snap connections' output (but is not connected)
|
|
check_slot_present() {
|
|
SLOT_NAME="$1"
|
|
for _ in $(seq 10); do
|
|
if nested_exec "snap connections system" | MATCH "serial-port .* - .* :$SLOT_NAME"; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
nested_exec "snap connections system" | MATCH "serial-port .* - .* :$SLOT_NAME"
|
|
}
|
|
|
|
# Check that given slot has hotplug-gone=true, meaning the device was unplugged but there are connections remembered for it
|
|
check_slot_gone() {
|
|
SLOT_NAME="$1"
|
|
nested_exec 'sudo jq -r ".data[\"hotplug-slots\"][\"'"$SLOT_NAME"'\"][\"hotplug-gone\"]" /var/lib/snapd/state.json' | MATCH "true"
|
|
}
|
|
|
|
# Check that given slot has hotplug-gone=false, meaning the device is plugged
|
|
check_slot_not_gone() {
|
|
SLOT_NAME="$1"
|
|
nested_exec 'sudo jq -r ".data[\"hotplug-slots\"][\"'"$SLOT_NAME"'\"][\"hotplug-gone\"]" /var/lib/snapd/state.json' | MATCH "false"
|
|
}
|
|
|
|
# Check that given slot has no record in "hotplug-slots" map in the state
|
|
check_slot_not_present_in_state() {
|
|
SLOT_NAME="$1"
|
|
nested_exec 'sudo jq -r ".data[\"hotplug-slots\"][\"'"$SLOT_NAME"'\"] // \"missing\"" /var/lib/snapd/state.json' | MATCH "missing"
|
|
}
|
|
|
|
check_slot_device_path() {
|
|
SLOT_NAME="$1"
|
|
DEVICE_PATH="$2"
|
|
nested_exec 'sudo jq -r ".data[\"hotplug-slots\"][\"'"$SLOT_NAME"'\"][\"static-attrs\"].path" /var/lib/snapd/state.json' | MATCH "$DEVICE_PATH"
|
|
}
|
|
|
|
# Check that given slot is connected to the serial-port-hotplug snap, per 'snap connections' output
|
|
check_slot_connected() {
|
|
SLOT_NAME="$1"
|
|
for _ in $(seq 10); do
|
|
if nested_exec "snap connections" | MATCH "serial-port .*serial-port-hotplug:serial-port .*$SLOT_NAME"; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
nested_exec "snap connections" | MATCH "serial-port .*serial-port-hotplug:serial-port .*$SLOT_NAME"
|
|
}
|
|
|
|
# Check that apparmor profile allows rw access to given device path.
|
|
verify_apparmor_profile() {
|
|
DEVPATH=$1
|
|
for _ in $(seq 10); do
|
|
if nested_exec "cat /var/lib/snapd/apparmor/profiles/snap.serial-port-hotplug.consumer" | MATCH "$DEVPATH rwk,"; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
nested_exec "cat /var/lib/snapd/apparmor/profiles/snap.serial-port-hotplug.consumer" | MATCH "$DEVPATH rwk,"
|
|
}
|
|
|
|
wait_for_all_changes() {
|
|
for _ in $(seq 10); do
|
|
if ! nested_exec "snap changes" | MATCH "Doing"; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
} |