Salome HOME
Improve SQUISH test scripts
authorspo <sergey.pokhodenko@opencascade.com>
Thu, 20 Aug 2015 11:38:50 +0000 (14:38 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Thu, 20 Aug 2015 12:42:22 +0000 (15:42 +0300)
squishide_run.sh
test.squish/suite_ISSUES_SALOME/shared/scripts/common.py
test.squish/suite_ISSUES_SALOME/tst_sketch_004/test.py
test_squish-vnc.sh [new file with mode: 0755]
test_squish.sh
vnc-run [new file with mode: 0755]
vnc.sh [new file with mode: 0755]

index 5f3922959039ad8975350bbda102af9c5c600627..75627af13ded1e2a61ab13642d185773c1bc20d4 100755 (executable)
@@ -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
index d0662530023d7fbb7eb66de99151bd191fc355df..60dc3d80d9f52787b579b4c868f93e66726d454c 100644 (file)
@@ -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):
index 601a25bec0a366b964353450faed1e1e921297de..5c6a7fe1a8df3a899fd341ccbe63ec02ddaf8ba1 100644 (file)
@@ -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 (executable)
index 0000000..1afa548
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+a_dir=$(dirname $0)
+
+cd ${a_dir}
+
+${a_dir}/vnc.sh ${a_dir}/test_squish.sh
+
index cda872e27456892a89b86c92b0d0672fb8eeb54e..ddb66a092bb9d3c9477bb0e82d8fab25964e25f3 100755 (executable)
@@ -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 (executable)
index 0000000..9e730ce
--- /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 <<EOF
+Usage: $PROGNAME [OPTION ...] COMMAND
+Run COMMAND (usually an X client) in a virtual X server environment.
+Options:
+-a        --auto-servernum          try to get a free server number, starting at
+                                    --server-num
+-e FILE   --error-file=FILE         file used to store xauth errors and VNC
+                                    output (default: $ERRORFILE)
+-f FILE   --auth-file=FILE          file used to store auth cookie
+                                    (default: ./.Xauthority)
+-h        --help                    display this usage message and exit
+-n NUM    --server-num=NUM          server number to use (default: $SERVERNUM)
+-l        --listen-tcp              enable TCP port listening in the X server
+-p PROTO  --xauth-protocol=PROTO    X authority protocol name to use
+                                    (default: xauth command's default)
+-s ARGS   --server-args=ARGS        arguments (other than server number and
+                                    "-nolisten tcp") to pass to the VNC server
+                                    (default: "$VNCARGS")
+-w DELAY  --wait=DELAY              delay in seconds to wait for VNC to start
+                                    before running COMMAND (default: $STARTWAIT)
+EOF
+}
+
+# Find a free server number by looking at .X*-lock files in /tmp.
+find_free_servernum() {
+    # Sadly, the "local" keyword is not POSIX.  Leave the next line commented in
+    # the hope Debian Policy eventually changes to allow it in /bin/sh scripts
+    # anyway.
+    #local i
+
+    i=$SERVERNUM
+    while [ -f /tmp/.X$i-lock ]; do
+        i=$(($i + 1))
+    done
+    echo $i
+}
+
+# Parse the command line.
+ARGS=$(getopt --options +ae:f:hn:lp:s:w: \
+       --long auto-servernum,error-file:auth-file:,help,server-num:,listen-tcp,xauth-protocol:,server-args:,wait: \
+       --name "$PROGNAME" -- "$@")
+GETOPT_STATUS=$?
+
+if [ $GETOPT_STATUS -ne 0 ]; then
+    error "internal error; getopt exited with status $GETOPT_STATUS"
+    exit 6
+fi
+
+eval set -- "$ARGS"
+
+while :; do
+    case "$1" in
+        -a|--auto-servernum) SERVERNUM=$(find_free_servernum) ;;
+        -e|--error-file) ERRORFILE="$2"; shift ;;
+        -f|--auth-file) AUTHFILE="$2"; shift ;;
+        -h|--help) SHOWHELP="yes" ;;
+        -n|--server-num) SERVERNUM="$2"; shift ;;
+        -l|--listen-tcp) LISTENTCP="" ;;
+        -p|--xauth-protocol) XAUTHPROTO="$2"; shift ;;
+        -s|--server-args) VNCARGS="$2"; shift ;;
+        -w|--wait) STARTWAIT="$2"; shift ;;
+        --) shift; break ;;
+        *) error "internal error; getopt permitted \"$1\" unexpectedly"
+           exit 6
+           ;;
+    esac
+    shift
+done
+
+if [ "$SHOWHELP" ]; then
+    usage
+    exit 0
+fi
+
+if [ -z "$*" ]; then
+    usage "need a command to run" >&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 (executable)
index 0000000..57102df
--- /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 "$@"