From c5fcffb6b256524edfc8fdab5588b836835f8e2c Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 28 Nov 2022 18:26:15 +0100 Subject: test: add -i option to set up devices only --- test/test.sh | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/test.sh b/test/test.sh index 665f8e9..c0b4b94 100755 --- a/test/test.sh +++ b/test/test.sh @@ -7,6 +7,8 @@ script_dir="$( dirname -- "${BASH_SOURCE[0]}" )" script_dir="$( cd -- "$script_dir" && pwd )" readonly script_dir +devices_only= + base_dir="$( mktemp -d )" readonly base_dir @@ -136,7 +138,7 @@ cleanup() { local name find "$base_dir/devices" -mindepth 1 -maxdepth 1 -type d -printf '%P\0' \ | while IFS= read -d '' -r name; do - echo "Removing interface: $name" + echo "Removing device: $name" ip link delete "$name" type wireguard || true done fi @@ -144,16 +146,41 @@ cleanup() { echo "Removing $base_dir" rm -rf -- "$base_dir" - echo "Brining down containers..." - docker-compose down -v --remove-orphans + if [ -z "$devices_only" ]; then + echo "Brining down containers..." + docker-compose down -v --remove-orphans + fi } main() { cd -- "$script_dir/.." trap cleanup EXIT + + local opt + while getopts ':i' opt "$@"; do + case "$opt" in + i) + devices_only=1 + ;; + :) + echo "usage error: required argument missing for option -$OPTARG" >&2 + exit 1; + ;; + *) + echo "usage error: invalid option -$OPTARG" >&2; + exit 1; + ;; + esac + done + add_devices - build_services - check_api + + if [ -z "$devices_only" ]; then + build_services + check_api + else + while true; do sleep 1; done + fi } -main +main "$@" -- cgit v1.2.3