From 8d49eed7f0a3fb6f605adb93a7e51d29610338d9 Mon Sep 17 00:00:00 2001 From: Dmitry Maksyoma Date: Wed, 25 Jan 2023 17:51:58 +1300 Subject: [PATCH] Support --perf-test, --shell in test-deb, test-rpm --- builder/os_ver_cli.sh | 2 ++ builder/process_test_options.sh | 49 +++++++++++++++++++++++++++++++++ builder/test-deb | 6 +++- builder/test-rpm | 5 +++- 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 builder/process_test_options.sh diff --git a/builder/os_ver_cli.sh b/builder/os_ver_cli.sh index f23fb9e..534810d 100644 --- a/builder/os_ver_cli.sh +++ b/builder/os_ver_cli.sh @@ -1,3 +1,5 @@ +#!/bin/bash + default_os=${default_os:-ubuntu} default_os_codename=${default_os_codename:-bionic} diff --git a/builder/process_test_options.sh b/builder/process_test_options.sh new file mode 100644 index 0000000..da8b55c --- /dev/null +++ b/builder/process_test_options.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +usage() { + echo >&2 "Usage: $(basename "$0") [-s|--shell] [-p|--perf-test] [-h|--help] " + exit +} + +process_options() { + local sorted_options=$(getopt -o psh --long perf-test --long shell --long help -- "$@") + eval set -- $sorted_options + + while : ; do + case "$1" in + -p|--perf-test) + entrypoint_args='-interface 0.0.0.0 -selfBench :1' + entrypoint_executable="--entrypoint=/usr/bin/Xvnc" + shift + ;; + -s|--shell) + entrypoint_executable="--entrypoint=bash" + shift + ;; + -h|--help) + print_usage=1 + ;; + --) + shift + break + ;; + esac + done + + leftover_options=("$@") +} + +declare -a leftover_options + +if [ "$#" -eq 0 ]; then + usage + exit +fi + +process_options "$@" +set -- "${leftover_options[@]}" + +if [ -n "$print_usage" ]; then + usage + exit +fi diff --git a/builder/test-deb b/builder/test-deb index 50accfa..9a8c11d 100755 --- a/builder/test-deb +++ b/builder/test-deb @@ -3,6 +3,7 @@ set -e cd "$(dirname "$0")/.." +. ./builder/process_test_options.sh . ./builder/os_ver_cli.sh . ./builder/common.sh @@ -11,8 +12,11 @@ docker build --build-arg KASMVNC_PACKAGE_DIR="builder/build/${os_codename}" \ --build-arg BUILD_DEBIAN_REVISION="$build_debian_revision" \ -t "$tester_image" \ -f "builder/dockerfile.${os}_${os_codename}${build_tag}.deb.test" . + docker run -it -p "443:$VNC_PORT" --rm \ -e KASMVNC_VERBOSE_LOGGING=$KASMVNC_VERBOSE_LOGGING \ -e "VNC_USER=foo" -e "VNC_PW=foobar" \ -e "VNC_PORT=$VNC_PORT" \ - "$tester_image" + $entrypoint_executable \ + "$tester_image" \ + $entrypoint_args diff --git a/builder/test-rpm b/builder/test-rpm index fbf731e..aed8652 100755 --- a/builder/test-rpm +++ b/builder/test-rpm @@ -3,6 +3,7 @@ set -e cd "$(dirname "$0")/.." +. ./builder/process_test_options.sh . ./builder/os_ver_cli.sh . ./builder/common.sh @@ -16,4 +17,6 @@ docker run -it -p "443:$VNC_PORT" --rm \ -e KASMVNC_VERBOSE_LOGGING=$KASMVNC_VERBOSE_LOGGING \ -e "VNC_USER=foo" -e "VNC_PW=foobar" \ -e "VNC_PORT=$VNC_PORT" \ - kasmvnctester_${os}:$os_codename + $entrypoint_executable \ + kasmvnctester_${os}:$os_codename \ + $entrypoint_args