From bc89c4886936f68ad504d02e84a407092a315289 Mon Sep 17 00:00:00 2001 From: spo Date: Thu, 20 Aug 2015 14:38:50 +0300 Subject: [PATCH] Improve SQUISH test scripts --- squishide_run.sh | 7 +- .../shared/scripts/common.py | 4 +- .../tst_sketch_004/test.py | 3 +- test_squish-vnc.sh | 8 + test_squish.sh | 6 +- vnc-run | 168 ++++++++++++++++++ vnc.sh | 4 + 7 files changed, 196 insertions(+), 4 deletions(-) create mode 100755 test_squish-vnc.sh create mode 100755 vnc-run create mode 100755 vnc.sh diff --git a/squishide_run.sh b/squishide_run.sh index 5f3922959..75627af13 100755 --- a/squishide_run.sh +++ b/squishide_run.sh @@ -1,4 +1,9 @@ #!/bin/bash -x -source env_squish.sh +a_dir=$(dirname $0) + +source ${a_dir}/env_squish.sh + +export TEST_DATA_DIR=$(cd ${a_dir}; pwd)/test.squish/shared/testdata + squishide diff --git a/test.squish/suite_ISSUES_SALOME/shared/scripts/common.py b/test.squish/suite_ISSUES_SALOME/shared/scripts/common.py index d06625300..60dc3d80d 100644 --- a/test.squish/suite_ISSUES_SALOME/shared/scripts/common.py +++ b/test.squish/suite_ISSUES_SALOME/shared/scripts/common.py @@ -1,7 +1,9 @@ +import os + testSettings.logScreenshotOnError = True testSettings.logScreenshotOnFail = True #RESULTS_PATH = "/dn48/newgeom/eso/sources/test.squish/shared/testresults/" -DATA_PATH = "/dn48/newgeom/eso/sources/test.squish/shared/testdata/" +DATA_PATH = os.getenv('TEST_DATA_DIR') g_points = {"XY_plane": (332, 250), "XZ_plane": (355, 207)} # one of the construction planes def help_points(name): diff --git a/test.squish/suite_ISSUES_SALOME/tst_sketch_004/test.py b/test.squish/suite_ISSUES_SALOME/tst_sketch_004/test.py index 601a25bec..5c6a7fe1a 100644 --- a/test.squish/suite_ISSUES_SALOME/tst_sketch_004/test.py +++ b/test.squish/suite_ISSUES_SALOME/tst_sketch_004/test.py @@ -1,3 +1,4 @@ +import os def main(): #[project] NewGEOM @@ -17,7 +18,7 @@ def main(): set_defaults() #[step] Open 'for_sketch_004.hdf' - open(DATA_PATH + "for_sketch_004.hdf") + open(os.path.join(DATA_PATH, "for_sketch_004.hdf")) #[step] Activate NewGeom clickButton(waitForObject(":SALOME 7.6.0.NewGeom_QToolButton")) diff --git a/test_squish-vnc.sh b/test_squish-vnc.sh new file mode 100755 index 000000000..1afa54823 --- /dev/null +++ b/test_squish-vnc.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +a_dir=$(dirname $0) + +cd ${a_dir} + +${a_dir}/vnc.sh ${a_dir}/test_squish.sh + diff --git a/test_squish.sh b/test_squish.sh index cda872e27..ddb66a092 100755 --- a/test_squish.sh +++ b/test_squish.sh @@ -1,5 +1,7 @@ #!/bin/bash -x +a_dir=$(dirname $0) + set -e if [ "$#" = 1 ]; then @@ -8,7 +10,9 @@ elif [ -z ${SQUISHSERVER_PORT} ]; then SQUISHSERVER_PORT=4320 fi -source env_squish.sh +export TEST_DATA_DIR=$(cd ${a_dir}; pwd)/test.squish/shared/testdata + +source ${a_dir}/env_squish.sh for aut in linux_run.sh salome_run.sh; do squishserver --config addAUT ${aut} $(pwd) diff --git a/vnc-run b/vnc-run new file mode 100755 index 000000000..9e730ce1a --- /dev/null +++ b/vnc-run @@ -0,0 +1,168 @@ +#!/bin/bash + +# This script starts an instance of vncserver, runs a command +# with that server available, and kills the X server when done. The return +# value of the command becomes the return value of this script. + +set -e + +PROGNAME=vnc-run +SERVERNUM=99 +AUTHFILE= +ERRORFILE=/dev/null +STARTWAIT=3 +VNCARGS="-screen 0 640x480x8" +LISTENTCP="-nolisten tcp" +XAUTHPROTO=. + +# Query the terminal to establish a default number of columns to use for +# displaying messages to the user. This is used only as a fallback in the event +# the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while the +# script is running, and this cannot, only being calculated once.) +DEFCOLUMNS=$(stty size 2>/dev/null | awk '{print $2}') || true +if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" >/dev/null 2>&1; then + DEFCOLUMNS=80 +fi + +# Display a message, wrapping lines at the terminal width. +message () { + echo "$PROGNAME: $*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} +} + +# Display an error message. +error () { + message "error: $*" >&2 +} + +# Display a usage message. +usage () { + if [ -n "$*" ]; then + message "usage error: $*" + fi + cat <&2 + exit 2 +fi + +if ! which xauth >/dev/null; then + error "xauth command not found" + exit 3 +fi + +if ! which vncserver >/dev/null; then + error "vncserver command not found" + exit 4 +fi + +# If the user did not specify an X authorization file to use, set up a temporary +# directory to house one. +if [ -z "$AUTHFILE" ]; then + VNC_RUN_TMPDIR="$(mktemp --directory --tmpdir $PROGNAME.XXXXXX)" + AUTHFILE=$(mktemp -p "$VNC_RUN_TMPDIR" Xauthority.XXXXXX) +fi + +# Start VNC. +MCOOKIE=$(mcookie) + +XAUTHORITY=$AUTHFILE xauth source - << EOF >>"$ERRORFILE" 2>&1 +add :$SERVERNUM $XAUTHPROTO $MCOOKIE +EOF +XAUTHORITY=$AUTHFILE vncserver ":$SERVERNUM" -noxstartup >>"$ERRORFILE" 2>&1 & +VNCPID=$! +sleep "$STARTWAIT" + +# Start the command and save its exit status. +set +e +DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1 +RETVAL=$? +set -e + +# Kill VNC now that the command has exited. +vncserver -kill ":$SERVERNUM" + +# Clean up. +XAUTHORITY=$AUTHFILE xauth remove ":$SERVERNUM" >"$ERRORFILE" 2>&1 +if [ -n "$VNC_RUN_TMPDIR" ]; then + if ! rm -r "$VNC_RUN_TMPDIR"; then + error "problem while cleaning up temporary directory" + exit 5 + fi +fi + +# Return the executed command's exit status. +exit $RETVAL + diff --git a/vnc.sh b/vnc.sh new file mode 100755 index 000000000..57102df99 --- /dev/null +++ b/vnc.sh @@ -0,0 +1,4 @@ +#!/bin/bash -e + +export PATH=/dn23/NEWGEOM/NEWGEOM_JENKINS_BUILD_AREA/tools:/opt/TurboVNC/bin:${PATH} +./vnc-run vglrun "$@" -- 2.39.2