1
0
mirror of https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git synced 2025-12-15 11:22:43 +03:00
tiny-cloud/tests/init-early.test
Natanael Copa 38cbdee6a2 Return failure if any of install_modules fails
Add test to verify that install_modules can be skipped and that
install_modules returns failure if it fails to update mdev.conf.
2023-03-09 11:47:34 +01:00

95 lines
2.3 KiB
Plaintext
Executable File

#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
export PREFIX="$srcdir"
export MOCK=echo
init_tests \
expand_root \
expand_root_partition \
expand_root_skip \
install_hotplugs_skip \
install_hotplugs_fail
PROVIDERS="aws azure gcp nocloud oci"
expand_root_body() {
fake_bin test-expand-root <<-EOF
#!/bin/sh
. "$srcdir"/lib/tiny-cloud/init-early
expand_root
EOF
mkdir proc
echo "/dev/xvda / ext4 rw,noatime 0 0" > proc/mounts
for provider in $PROVIDERS; do
CLOUD="$provider" atf_check \
-o match:"resize2fs /dev/xvda" \
test-expand-root
done
}
expand_root_partition_body() {
fake_bin test-expand-root <<-EOF
#!/bin/sh
. "$srcdir"/lib/tiny-cloud/init-early
expand_root
EOF
mkdir -p proc sys/class/block \
sys/devices/pci0000:00/0000:00:1b.0/0000:01:00.0/nvme/nvme0/nvme0n1/nvme0n1p2 \
sys/devices/pci0000:00/0000:00:1b.0/0000:01:00.0/nvme/nvme0/nvme0n1/device
ln -s ../../devices/pci0000:00/0000:00:1b.0/0000:01:00.0/nvme/nvme0/nvme0n1 sys/class/block/nvme0n1
ln -s ../../devices/pci0000:00/0000:00:1b.0/0000:01:00.0/nvme/nvme0/nvme0n1/nvme0n1p2 sys/class/block/nvme0n1p2
echo 2 > sys/class/block/nvme0n1p2/partition
echo "/dev/nvme0n1p2 / ext4 rw,noatime 0 0" > proc/mounts
for provider in $PROVIDERS; do
CLOUD="$provider" atf_check \
-o match:"sfdisk .*/dev/nvme0n1" \
-o match:"partx .*/dev/nvme0n1" \
-o match:"resize2fs /dev/nvme0n1p2" \
test-expand-root
done
}
expand_root_skip_body() {
fake_bin test-expand-root <<-EOF
#!/bin/sh
SKIP_INIT_ACTIONS=expand_root
. "$srcdir"/lib/tiny-cloud/init-early
expand_root
EOF
for provider in $PROVIDERS; do
CLOUD="$provider" atf_check \
-o match:'^ SKIPPING$' \
test-expand-root
done
}
install_hotplugs_skip_body() {
fake_bin test-install-hotplugs <<-EOF
#!/bin/sh
SKIP_INIT_ACTIONS=install_hotplugs
. "$srcdir"/lib/tiny-cloud/init-early
install_hotplugs
EOF
for provider in $PROVIDERS; do
CLOUD="$provider" atf_check \
-o match:'^ SKIPPING$' \
test-install-hotplugs
done
}
install_hotplugs_fail_body() {
fake_bin test-install-hotplugs <<-EOF
#!/bin/sh
HOTPLUG_MODULES="vnic_eth_hotplug"
. "$srcdir"/lib/tiny-cloud/init-early
install_hotplugs
EOF
CLOUD=aws atf_check -s not-exit:0 \
-o match:"^ vnic_eth_hotplug\(!\)$" \
test-install-hotplugs
}