From a164ed3d7dde486aed66f911a9510cbc41dc2e04 Mon Sep 17 00:00:00 2001 From: Lars Karlitski Date: Sun, 2 Jun 2019 19:47:02 +0200 Subject: [PATCH] tests: Set BLUEPRINTS_DIR in all cases `setup_tests()` expected BLUEPRINTS_DIR to be set, but it wasn't when running in automated mode (with $CLI set). Fix this and move share and blueprint dirs to function arguments. --- tests/test_cli.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/test_cli.sh b/tests/test_cli.sh index 2d098cba..1b267abc 100755 --- a/tests/test_cli.sh +++ b/tests/test_cli.sh @@ -7,20 +7,23 @@ set -eu rm -rf /var/tmp/beakerlib-*/ function setup_tests { + local share_dir=$1 + local blueprints_dir=$2 + # explicitly enable sshd for live-iso b/c it is disabled by default # due to security concerns (no root password required) - sed -i.orig 's/^services.*/services --disabled="network" --enabled="NetworkManager,sshd"/' $1/composer/live-iso.ks + sed -i.orig 's/^services.*/services --disabled="network" --enabled="NetworkManager,sshd"/' $share_dir/composer/live-iso.ks # explicitly enable logging in with empty passwords via ssh, because # the default sshd setting for PermitEmptyPasswords is 'no' awk -i inplace " /%post/ && FLAG != 2 {FLAG=1} /%end/ && FLAG == 1 {print \"sed -i 's/.*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' /etc/ssh/sshd_config\"; FLAG=2} {print}" \ - $1/composer/live-iso.ks + $share_dir/composer/live-iso.ks # append a section with additional option on kernel command line to example-http-server blueprint # which is used for building of most of the images - cat >> $BLUEPRINTS_DIR/example-http-server.toml << __EOF__ + cat >> $blueprints_dir/example-http-server.toml << __EOF__ [customizations.kernel] append = "custom_cmdline_arg" @@ -51,13 +54,12 @@ if [ -z "$CLI" ]; then cp -R ./share/* $SHARE_DIR chmod a+rx -R $SHARE_DIR - setup_tests $SHARE_DIR + setup_tests $SHARE_DIR $BLUEPRINTS_DIR # start the lorax-composer daemon ./src/sbin/lorax-composer --sharedir $SHARE_DIR $BLUEPRINTS_DIR & else export PACKAGE="composer-cli" - SHARE_DIR="/usr/share/lorax" - setup_tests $SHARE_DIR + setup_tests /usr/share/lorax /var/lib/lorax/composer/blueprints systemctl restart lorax-composer fi @@ -95,7 +97,7 @@ if [ -z "$CLI" ]; then teardown_tests $SHARE_DIR else systemctl stop lorax-composer - teardown_tests $SHARE_DIR + teardown_tests /usr/share/lorax # start lorax-composer again so we can continue with manual or other kinds # of testing on the same system systemctl start lorax-composer