From e8ff5004071257018463afc85302783d50eca980 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 28 Apr 2016 18:01:48 -0400 Subject: [PATCH] ripped out smoke testing of suma from neurodebian pkg cmake infrastructure --- CMakeLists.txt | 14 ++++++++++++ tests/CMakeLists.txt | 20 +++++++++++++++++ tests/xvfb-driver | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 tests/CMakeLists.txt create mode 100755 tests/xvfb-driver diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..b96e4a950 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +## Rudimentary cmake setup for now just to run tests + +PROJECT(AFNI) + +## +## Define options to customize the build-process +## + +OPTION(AFNI_BUILD_TESTS + "Enable testing and build available tests" + OFF) + +ADD_SUBDIRECTORY(tests) + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..8d3501a87 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,20 @@ +PROJECT(TESTS) +# +# Tests -- building/running is aggregated within a separate directory +# so they do not interact/pollute main build space +# +# yoh: for some reason WORKING_DIRECTORY is not quite working for me +# says BAD_COMMAND for the binary to be executed. That is why +# this solution with tests/ directory +# + +ADD_TEST(afni:start ../../tests/xvfb-driver -- afni -com "OPEN_WINDOW axialimage; SAVE_JPEG axialimage test1; QUIT") + +# TODO: figure out how to reference it correctly, or just copy to this +# target tests/ build directory +# Allow for 1 error and 2 failures reported -- due to the ones upon exit +ADD_TEST(do.examples ../../tests/xvfb-driver -e 0 -f 0 -- @DO.examples -auto_test) +SET_TESTS_PROPERTIES(do.examples PROPERTIES LABELS GLX) + + + diff --git a/tests/xvfb-driver b/tests/xvfb-driver new file mode 100755 index 000000000..5bbb213e3 --- /dev/null +++ b/tests/xvfb-driver @@ -0,0 +1,62 @@ +#!/bin/bash +set -u + +# Parse cmdline + +CLOPTS=`getopt -o e:,f: --long errors:,failures: -n 'xvfb-driver' -- "$@"` +if [ $? != 0 ] ; then + echo "Terminating..." >&2 + exit 1 +fi +eval set -- "$CLOPTS" + +# Defaults +errors=0 # # of errors expected +failures=0 # # of reported failures expected + +while true ; do + case "$1" in + -e|--errors) shift; errors=$1; shift;; + -f|--failures) shift; failures=$1; shift;; + --) shift ; break ;; + *) echo "Internal error! ($1)"; exit 1;; + esac +done + +# Deduce paths + +srcdir=$(readlink -f `dirname $0`/..) +builddir=$(readlink -f $PWD/..) +tempdir=`mktemp -d` + +cleanup() { rm -r "$tempdir"; } +trap 'cleanup' EXIT HUP + +echo "I: builddir=$builddir srcdir=$srcdir tempdir=$tempdir" +cd $tempdir +ln -s $srcdir/faces pics + +AFNI_DETACH=NO AFNI_SYSTEM_AFNIRC=/dev/null \ +AFNI_PLUGINPATH=$builddir PATH=$builddir:$builddir/SUMA:$srcdir:$PATH \ + xvfb-run --auto-servernum --server-num=20 -s "-screen 0 1024x768x24 -ac +extension GLX +render -noreset" \ + "$@" 2>&1 | tee __outputlog.txt +code=${PIPESTATUS[0]} + +if [ "$code" != "0" ]; then + echo "E: Testing $@ failed. Exit code was $code" + exit 1 +fi + +cmd="$@" +errors_=`grep Error __*log.txt| grep -v -e "Out of Cheese Error" -e SUMA_PositionWindowRelative_current | wc -l` +if [ $errors -lt $errors_ ]; then + echo "E: Testing '$cmd' failed due to presence of $errors_ Error messages when up to $errors were expected" >&2 + exit 1 +fi + +failures_=`grep '^Failed to' __*log.txt| grep -v -e "window attributes" | wc -l` +if [ $failures -lt $failures_ ]; then + echo "E: Testing '$cmd' failed due to presence of $failures_ 'Failed to ...' messages when up to $failures were expected" >&2 + exit 1 +fi +