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 091af053c5 Use printf for skip_action
printf is posix compatible and works with all shell. echo -n does not
work with yash and is not posix compatible.

Add test for skipping expand_root
2023-03-09 11:47:34 +01:00

67 lines
1.6 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
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
}