From 091af053c5470c24917bb9fc8149cb63d9d9646e Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 8 Mar 2023 18:25:39 +0100 Subject: [PATCH] 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 --- lib/tiny-cloud/init-common | 2 +- tests/init-early.test | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/tiny-cloud/init-common b/lib/tiny-cloud/init-common index 1622bd1..ef6bbb2 100644 --- a/lib/tiny-cloud/init-common +++ b/lib/tiny-cloud/init-common @@ -25,5 +25,5 @@ skip_action() { # action not in the skip list? echo "$SKIP_INIT_ACTIONS" | grep -Eq "\b$action\b" || return 1 - echo -n " SKIPPING" + printf " SKIPPING" } diff --git a/tests/init-early.test b/tests/init-early.test index 2d3539d..eb22852 100755 --- a/tests/init-early.test +++ b/tests/init-early.test @@ -7,7 +7,8 @@ export MOCK=echo init_tests \ expand_root \ - expand_root_partition + expand_root_partition \ + expand_root_skip PROVIDERS="aws azure gcp nocloud oci" @@ -49,3 +50,17 @@ expand_root_partition_body() { 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 +} +