VirtualBox

Ignore:
Timestamp:
May 4, 2017 11:55:34 PM (8 years ago)
Author:
vboxsync
Message:

testboxscript: modified the setup to no save default values and tricked setup.sh to replace solserv with the new names.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testboxscript/setup.sh

    r66798 r66800  
    66
    77#
    8 # Copyright (C) 2006-2015 Oracle Corporation
     8# Copyright (C) 2006-2017 Oracle Corporation
    99#
    1010# This file is part of VirtualBox Open Source Edition (OSE), as
     
    334334}
    335335
     336##
     337# Parses the testboxscript.py invocation, setting TESTBOXSCRIPT_xxx config
     338# variables accordingly.  Both darwin and solaris uses this.
     339common_testboxscript_args_to_config()
     340{
     341    MY_ARG=0
     342    while [ $# -gt 0 ];
     343    do
     344        case "$1" in
     345            # boolean
     346            "--hwvirt")                 TESTBOXSCRIPT_HWVIRT="yes";;
     347            "--no-hwvirt")              TESTBOXSCRIPT_HWVIRT="no";;
     348            "--nested-paging")          TESTBOXSCRIPT_NESTED_PAGING="yes";;
     349            "--no-nested-paging")       TESTBOXSCRIPT_NESTED_PAGING="no";;
     350            "--io-mmu")                 TESTBOXSCRIPT_IOMMU="yes";;
     351            "--no-io-mmu")              TESTBOXSCRIPT_IOMMU="no";;
     352            # optios taking values.
     353            "--system-uuid")            TESTBOXSCRIPT_SYSTEM_UUID="$2"; shift;;
     354            "--scratch-root")           TESTBOXSCRIPT_SCRATCH_ROOT="$2"; shift;;
     355            "--test-manager")           TESTBOXSCRIPT_TEST_MANAGER="$2"; shift;;
     356            "--builds-path")            TESTBOXSCRIPT_BUILDS_PATH="$2"; shift;;
     357            "--builds-server-type")     TESTBOXSCRIPT_BUILDS_TYPE="$2"; shift;;
     358            "--builds-server-name")     TESTBOXSCRIPT_BUILDS_NAME="$2"; shift;;
     359            "--builds-server-share")    TESTBOXSCRIPT_BUILDS_SHARE="$2"; shift;;
     360            "--builds-server-user")     TESTBOXSCRIPT_BUILDS_USER="$2"; shift;;
     361            "--builds-server-passwd")   TESTBOXSCRIPT_BUILDS_PASSWD="$2"; shift;;
     362            "--testrsrc-path")          TESTBOXSCRIPT_TESTRSRC_PATH="$2"; shift;;
     363            "--testrsrc-server-type")   TESTBOXSCRIPT_TESTRSRC_TYPE="$2"; shift;;
     364            "--testrsrc-server-name")   TESTBOXSCRIPT_TESTRSRC_NAME="$2"; shift;;
     365            "--testrsrc-server-share")  TESTBOXSCRIPT_TESTRSRC_SHARE="$2"; shift;;
     366            "--testrsrc-server-user")   TESTBOXSCRIPT_TESTRSRC_USER="$2"; shift;;
     367            "--testrsrc-server-passwd") TESTBOXSCRIPT_TESTRSRC_PASSWD="$2"; shift;;
     368            "--putenv")
     369                ## @todo remove any existing variable or we'll end up with a pretty long number of putenv statements on solaris.
     370                TESTBOXSCRIPT_ENVVARS+=("$2");
     371                shift;;
     372            --*)
     373                echo "error: Unknown option '$1' in existing config"
     374                exit 1
     375                ;;
     376
     377            # Non-option bits.
     378            *.py) ;; # ignored, should be the script.
     379
     380            *)  if [ ${MY_ARG} -ne 0 ]; then
     381                    echo "error: unknown non-option '$1' in existing config"
     382                    exit 1
     383                fi
     384                TESTBOXSCRIPT_PYTHON="$1"
     385                ;;
     386        esac
     387        shift
     388        MY_ARG=$((${MY_ARG} + 1))
     389    done
     390}
     391
     392##
     393# Used by common_compile_testboxscript_command_line, please override.
     394#
     395os_add_args() {
     396    echo "os_add_args is not implemented" 2>&1
     397    exit 1
     398}
     399
     400##
     401# Compiles the testboxscript.py command line given the current
     402# configuration and defaults.
     403#
     404# This is used by solaris and darwin.
     405#
     406# The os_add_args function will be called several with one or two arguments
     407# each time.  The caller must override it.
     408#
     409common_compile_testboxscript_command_line() {
     410    if [ -n "${TESTBOXSCRIPT_PYTHON}" ]; then
     411        os_add_args "${TESTBOXSCRIPT_PYTHON}"
     412    fi
     413    os_add_args "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript.py"
     414
     415    for var in ${TESTBOXSCRIPT_CFG_NAMES};
     416    do
     417        varcfg=TESTBOXSCRIPT_${var}
     418        vardef=TESTBOXSCRIPT_DEFAULT_${var}
     419        if [ "${!varcfg}" != "${!vardef}"  -a  "${var}" != "PYTHON" ]; then # PYTHON handled above.
     420            my_opt=TESTBOXSCRIPT_OPT_${var}
     421            if [ -n "${!my_opt}" ]; then
     422                if [ "${!my_opt}"  != "--skip" ]; then
     423                    os_add_args "${!my_opt}" "${!varcfg}"
     424                fi
     425            else
     426                my_opt_yes=${my_opt}_YES
     427                my_opt_no=${my_opt}_NO
     428                if [ -n "${!my_opt_yes}" -a -n "${!my_opt_no}" ]; then
     429                    if [ "${!varcfg}" = "yes" ]; then
     430                        os_add_args "${!my_opt_yes}";
     431                    else
     432                        if [ "${!varcfg}" != "no" ]; then
     433                            echo "internal option misconfig: var=${var} not a yes/no value: ${!varcfg}";
     434                            exit 1;
     435                        fi
     436                        os_add_args "${!my_opt_yes}";
     437                    fi
     438                else
     439                    echo "internal option misconfig: var=${var} my_opt_yes=${my_opt_yes}=${!my_opt_yes} my_opt_no=${my_opt_no}=${!my_opt_no}"
     440                    exit 1;
     441                fi
     442            fi
     443        fi
     444    done
     445
     446    i=0
     447    while [ "${i}" -lt "${#TESTBOXSCRIPT_ENVVARS[@]}" ];
     448    do
     449        os_add_args "--putenv" "${TESTBOXSCRIPT_ENVVARS[${i}]}"
     450        i=$((${i} + 1))
     451    done
     452}
     453
    336454
    337455#
     
    361479# Config.
    362480#
    363 TESTBOXSCRIPT_PYTHON=""
    364 TESTBOXSCRIPT_USER=""
    365 TESTBOXSCRIPT_HWVIRT=""
    366 TESTBOXSCRIPT_IOMMU=""
    367 TESTBOXSCRIPT_NESTED_PAGING=""
    368 TESTBOXSCRIPT_SYSTEM_UUID=""
    369 TESTBOXSCRIPT_PATH_TESTRSRC=""
    370 TESTBOXSCRIPT_TEST_MANAGER=""
    371 TESTBOXSCRIPT_SCRATCH_ROOT=""
    372 TESTBOXSCRIPT_BUILDS_PATH=""
    373 TESTBOXSCRIPT_BUILDS_TYPE="cifs"
    374 TESTBOXSCRIPT_BUILDS_NAME="vboxstor.de.oracle.com"
    375 TESTBOXSCRIPT_BUILDS_SHARE="builds"
    376 TESTBOXSCRIPT_BUILDS_USER="guestr"
    377 TESTBOXSCRIPT_BUILDS_PASSWD="guestr"
    378 TESTBOXSCRIPT_TESTRSRC_PATH=""
    379 TESTBOXSCRIPT_TESTRSRC_TYPE="cifs"
    380 TESTBOXSCRIPT_TESTRSRC_NAME="teststor.de.oracle.com"
    381 TESTBOXSCRIPT_TESTRSRC_SHARE="testrsrc"
    382 TESTBOXSCRIPT_TESTRSRC_USER="guestr"
    383 TESTBOXSCRIPT_TESTRSRC_PASSWD="guestr"
     481TESTBOXSCRIPT_CFG_NAMES="DIR PYTHON USER HWVIRT IOMMU NESTED_PAGING SYSTEM_UUID PATH_TESTRSRC TEST_MANAGER SCRATCH_ROOT"
     482TESTBOXSCRIPT_CFG_NAMES="${TESTBOXSCRIPT_CFG_NAMES}   BUILDS_PATH   BUILDS_TYPE   BUILDS_NAME   BUILDS_SHARE   BUILDS_USER   BUILDS_PASSWD"
     483TESTBOXSCRIPT_CFG_NAMES="${TESTBOXSCRIPT_CFG_NAMES} TESTRSRC_PATH TESTRSRC_TYPE TESTRSRC_NAME TESTRSRC_SHARE TESTRSRC_USER TESTRSRC_PASSWD"
     484
     485# testboxscript.py option to config mappings.
     486TESTBOXSCRIPT_OPT_DIR="--skip"
     487TESTBOXSCRIPT_OPT_PYTHON="--skip"
     488TESTBOXSCRIPT_OPT_USER="--skip"
     489TESTBOXSCRIPT_OPT_HWVIRT_YES="--hwvirt"
     490TESTBOXSCRIPT_OPT_HWVIRT_NO="--no-hwvirt"
     491TESTBOXSCRIPT_OPT_NESTED_PAGING_YES="--nested-paging"
     492TESTBOXSCRIPT_OPT_NESTED_PAGING_NO="--no-nested-paging"
     493TESTBOXSCRIPT_OPT_IOMMU_YES="--io-mmu"
     494TESTBOXSCRIPT_OPT_IOMMU_NO="--no-io-mmu"
     495TESTBOXSCRIPT_OPT_SYSTEM_UUID="--system-uuid"
     496TESTBOXSCRIPT_OPT_TEST_MANAGER="--test-manager"
     497TESTBOXSCRIPT_OPT_SCRATCH_ROOT="--scratch-root"
     498TESTBOXSCRIPT_OPT_BUILDS_PATH="--builds-path"
     499TESTBOXSCRIPT_OPT_BUILDS_TYPE="--builds-server-type"
     500TESTBOXSCRIPT_OPT_BUILDS_NAME="--builds-server-name"
     501TESTBOXSCRIPT_OPT_BUILDS_SHARE="--builds-server-share"
     502TESTBOXSCRIPT_OPT_BUILDS_USER="--builds-server-user"
     503TESTBOXSCRIPT_OPT_BUILDS_PASSWD="--builds-server-passwd"
     504TESTBOXSCRIPT_OPT_PATH_TESTRSRC="--testrsrc-path"
     505TESTBOXSCRIPT_OPT_TESTRSRC_TYPE="--testrsrc-server-type"
     506TESTBOXSCRIPT_OPT_TESTRSRC_NAME="--testrsrc-server-name"
     507TESTBOXSCRIPT_OPT_TESTRSRC_SHARE="--testrsrc-server-share"
     508TESTBOXSCRIPT_OPT_TESTRSRC_USER="--testrsrc-server-user"
     509TESTBOXSCRIPT_OPT_TESTRSRC_PASSWD="--testrsrc-server-passwd"
     510
     511# Defaults:
     512TESTBOXSCRIPT_DEFAULT_DIR="there-is-no-default-for-this-value"
     513TESTBOXSCRIPT_DEFAULT_PYTHON=""
     514TESTBOXSCRIPT_DEFAULT_USER="vbox"
     515TESTBOXSCRIPT_DEFAULT_HWVIRT=""
     516TESTBOXSCRIPT_DEFAULT_IOMMU=""
     517TESTBOXSCRIPT_DEFAULT_NESTED_PAGING=""
     518TESTBOXSCRIPT_DEFAULT_SYSTEM_UUID=""
     519TESTBOXSCRIPT_DEFAULT_PATH_TESTRSRC=""
     520TESTBOXSCRIPT_DEFAULT_TEST_MANAGER=""
     521TESTBOXSCRIPT_DEFAULT_SCRATCH_ROOT=""
     522TESTBOXSCRIPT_DEFAULT_BUILDS_PATH=""
     523TESTBOXSCRIPT_DEFAULT_BUILDS_TYPE="cifs"
     524TESTBOXSCRIPT_DEFAULT_BUILDS_NAME="vboxstor.de.oracle.com"
     525TESTBOXSCRIPT_DEFAULT_BUILDS_SHARE="builds"
     526TESTBOXSCRIPT_DEFAULT_BUILDS_USER="guestr"
     527TESTBOXSCRIPT_DEFAULT_BUILDS_PASSWD="guestr"
     528TESTBOXSCRIPT_DEFAULT_TESTRSRC_PATH=""
     529TESTBOXSCRIPT_DEFAULT_TESTRSRC_TYPE="cifs"
     530TESTBOXSCRIPT_DEFAULT_TESTRSRC_NAME="teststor.de.oracle.com"
     531TESTBOXSCRIPT_DEFAULT_TESTRSRC_SHARE="testrsrc"
     532TESTBOXSCRIPT_DEFAULT_TESTRSRC_USER="guestr"
     533TESTBOXSCRIPT_DEFAULT_TESTRSRC_PASSWD="guestr"
     534
     535# Set config values to defaults.
     536for var in ${TESTBOXSCRIPT_CFG_NAMES}
     537do
     538    defvar=TESTBOXSCRIPT_DEFAULT_${var}
     539    eval TESTBOXSCRIPT_${var}="${!defvar}"
     540done
    384541declare -a TESTBOXSCRIPT_ENVVARS
    385542
     
    387544os_load_config
    388545
    389 # Set defaults.
     546
     547#
     548# Config tweaks.
     549#
     550
     551# The USER must be a non-empty value for the successful execution of this script.
    390552if [ -z "${TESTBOXSCRIPT_USER}" ]; then
    391     TESTBOXSCRIPT_USER=vbox;
     553    TESTBOXSCRIPT_USER=${TESTBOXSCRIPT_DEFAULT_USER};
    392554fi;
     555
     556# The DIR must be according to the setup.sh location.
    393557TESTBOXSCRIPT_DIR=`dirname "${DIR}"`
     558
     559# Storage server replacement trick.
     560if [ "${TESTBOXSCRIPT_BUILDS_NAME}" = "solserv.de.oracle.com" ]; then
     561    TESTBOXSCRIPT_BUILDS_NAME=${TESTBOXSCRIPT_DEFAULT_BUILDS_NAME}
     562fi
     563if [ "${TESTBOXSCRIPT_TESTRSRC_NAME}" = "solserv.de.oracle.com" ]; then
     564    TESTBOXSCRIPT_TESTRSRC_NAME=${TESTBOXSCRIPT_DEFAULT_TESTRSRC_NAME}
     565fi
    394566
    395567
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette