aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/test-install.sh4
-rw-r--r--tests/unit/test_test_install.bats21
2 files changed, 24 insertions, 1 deletions
diff --git a/scripts/test-install.sh b/scripts/test-install.sh
index cf933a5..8cfe2ec 100755
--- a/scripts/test-install.sh
+++ b/scripts/test-install.sh
@@ -22,7 +22,9 @@ VM_DIR="$PROJECT_DIR/vm"
VM_RAM="4096"
VM_CPUS="4"
VM_DISK_SIZE="20G"
-export SSH_PORT="2222"
+# Overridable so a test VM can use a free port when another VM already
+# holds 2222 (e.g. SSH_PORT=2223 scripts/test-install.sh single-disk).
+export SSH_PORT="${SSH_PORT:-2222}"
export SSH_PASSWORD="archangel"
SERIAL_LOG="$LOG_DIR/serial.log"
diff --git a/tests/unit/test_test_install.bats b/tests/unit/test_test_install.bats
index 9cbb1aa..6b911af 100644
--- a/tests/unit/test_test_install.bats
+++ b/tests/unit/test_test_install.bats
@@ -214,3 +214,24 @@ EOF
[ "$status" -eq 0 ]
[ "$output" = "" ]
}
+
+#############################
+# SSH_PORT override
+#############################
+# The hostfwd port must be overridable so a test VM can coexist with
+# another VM already holding 2222 (re-sourcing applies the top-level
+# assignment with the env value in scope).
+
+@test "SSH_PORT honors a preset value" {
+ SSH_PORT=3333
+ # shellcheck disable=SC1091
+ source "${BATS_TEST_DIRNAME}/../../scripts/test-install.sh"
+ [ "$SSH_PORT" = "3333" ]
+}
+
+@test "SSH_PORT defaults to 2222 when unset" {
+ unset SSH_PORT
+ # shellcheck disable=SC1091
+ source "${BATS_TEST_DIRNAME}/../../scripts/test-install.sh"
+ [ "$SSH_PORT" = "2222" ]
+}