From c46b12ea049c442c66c60716a6af8e45c86a9d79 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 2 May 2023 14:32:10 +0200 Subject: [PATCH] tests: fix tests to use init__ prefix commit 4b86923358c0 (Fixes for tiny-cloud Wrapper) changed API so all init functions had an init__ prefix and the SKIP_INIT_ACTION was moved to tiny-cloud. Adjust the tests for this. --- tests/init-early.test | 54 ++++--------------------------------------- tests/init-final.test | 4 ++-- tests/init-main.test | 16 ++++--------- 3 files changed, 10 insertions(+), 64 deletions(-) diff --git a/tests/init-early.test b/tests/init-early.test index b1ffae5..d640ace 100755 --- a/tests/init-early.test +++ b/tests/init-early.test @@ -9,33 +9,21 @@ lib="$srcdir"/lib/tiny-cloud/init 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 - . "$lib" - 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 + sh -c ". $lib; init__expand_root" done } expand_root_partition_body() { - fake_bin test-expand-root <<-EOF - #!/bin/sh - . "$lib" - 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 @@ -49,46 +37,12 @@ expand_root_partition_body() { -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 - . "$lib" - 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 - . "$lib" - install_hotplugs - EOF - for provider in $PROVIDERS; do - CLOUD="$provider" atf_check \ - -o match:'^ SKIPPING$' \ - test-install-hotplugs + sh -c ". $lib; init__expand_root" done } install_hotplugs_fail_body() { - fake_bin test-install-hotplugs <<-EOF - #!/bin/sh - HOTPLUG_MODULES="vnic_eth_hotplug" - . "$lib" - install_hotplugs - EOF CLOUD=aws atf_check -s not-exit:0 \ - -o match:"^ vnic_eth_hotplug\(!\)$" \ - test-install-hotplugs + -e match:"vnic_eth_hotplug\(!\)" \ + sh -c ". $lib; HOTPLUG_MODULES='vnic_eth_hotplug'; init__install_hotplugs" } diff --git a/tests/init-final.test b/tests/init-final.test index 08b496f..2360965 100755 --- a/tests/init-final.test +++ b/tests/init-final.test @@ -38,10 +38,10 @@ run_userdata_body() { echo "hello from user-data" EOF CLOUD="nocloud" atf_check \ - sh -c ". \"$lib\"; save_userdata" + sh -c ". \"$lib\"; init__save_userdata" CLOUD="nocloud" atf_check \ -o match:"hello from user-data" \ - sh -c ". \"$lib\"; run_userdata" + sh -c ". \"$lib\"; init__run_userdata" grep "hello from user-data" var/log/user-data.log || atf_fail "user-data.log failed" grep -w "0" var/log/user-data.exit || atf_fail "user-data.exit failed" } diff --git a/tests/init-main.test b/tests/init-main.test index 6a27261..0cfe770 100755 --- a/tests/init-main.test +++ b/tests/init-main.test @@ -42,16 +42,8 @@ set_hostname_body() { CLOUD="nocloud" atf_check \ -o match:"hostname.*-F $PWD/etc/hostname" \ - sh -c ". \"$lib\"; set_hostname" + sh -c ". \"$lib\"; init__set_hostname" atf_check -o match:"^myhostname$" cat etc/hostname - - rm etc/hostname - CLOUD="nocloud" atf_check \ - -o not-match:"hostname.*-F $PWD/etc/hostname" \ - sh -c "SKIP_INIT_ACTIONS=set_hostname ; . \"$lib\"; set_hostname" - if test -f etc/hostname; then - atf_fail "etc/hostname should not exist" - fi } set_ssh_keys_body() { @@ -66,7 +58,7 @@ set_ssh_keys_body() { EOF CLOUD="nocloud" atf_check \ -o match:"chown.*/\.ssh" \ - sh -c ". \"$lib\"; set_ssh_keys" + sh -c ". \"$lib\"; init__set_ssh_keys" atf_check -o match:"^ssh-ed25519 keydata" \ -o match:"^ssh-rsa foobar" \ cat home/alpine/.ssh/authorized_keys @@ -77,7 +69,7 @@ save_userdata_plain_body() { #userdata EOF CLOUD="nocloud" atf_check \ - sh -c ". \"$lib\"; save_userdata" + sh -c ". \"$lib\"; init__save_userdata" atf_check -o match:"^#userdata" cat var/lib/cloud/user-data } @@ -88,7 +80,7 @@ save_userdata_compressed_body() { fake_userdata_nocloud < tmpfile CLOUD="nocloud" atf_check \ - sh -c ". \"$lib\"; save_userdata" + sh -c ". \"$lib\"; init__save_userdata" if ! grep "^#userdata" var/lib/cloud/user-data; then atf_fail "$comp failed"