Commit 35c1f4e7 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

NEW config test (using bash if available)

caveat: this test will not be run on windows...
parent 2d46ba06
......@@ -11,4 +11,10 @@ else()
endif()
# Recursively update the shiboken path variable containing the CamiTK SDK tree structure
set(SHIBOKEN_CAMITK_SDK_PATH ${SHIBOKEN_CAMITK_SDK_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
\ No newline at end of file
set(SHIBOKEN_CAMITK_SDK_PATH ${SHIBOKEN_CAMITK_SDK_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
# Add config test
find_program (BASH_PROGRAM bash)
if (BASH_PROGRAM)
add_test(config-test ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/resources/config-test.sh -inbuild ${PROJECT_BINARY_DIR})
endif (BASH_PROGRAM)
#!/bin/sh
#
# Testing the installation: the version, paths and number of extensions should be correct
# This test entirely depends on the CamitK version (version string, number of extensions...)
# (see the expectedConfigOutput)
#
# For a CamiTK major or minor version update:
# - update getExpectedValue for "sid"
# - update checkInstalledVersion for "sid"
# - update getExpectedExtensionCount for "sid"
#
# For a CamiTK hotfix update:
# - update checkInstalledVersion for "sid"
#
# echo $? get the last returned value of the script
# a return value of 0 indicates success (by convention)
# The value return by this script corresponds to the config test that failed
# (see log for config test id)
#
set -e
# cleanup on exit
cleanup() {
# backup the current exit status
currentExitValue=$?
# kill the xfvb
kill $xvfbPid
# cleanup current dir (but not build dir!)
if [ "$inBuild" == "0" ] ; then
rm -rf $workingDir
fi
# use the backup value (otherwise the result of the "rm -rf" command above will
# be used, and that's probably always 0 !)
exit $currentExitValue
}
# if a problem occurs, call the clean method
trap "cleanup" 0 INT QUIT ABRT PIPE TERM EXIT
# --------------------------------------------------------------------------
#
# Get ready
#
# --------------------------------------------------------------------------
echo "========== checking camitk configuration =========="
exitStatus=0 # nothing bad. By convention exit 0 indicates success
if [ $# -lt 1 -o "$1" != "-inbuild" ] ; then
echo "===== Creating temporary directory ====="
inBuild=0
workingDir=$(mktemp --tmpdir -d camitk-test-tmp.XXXXXXXXXX)
cd $workingDir
else
# if -inbuild option is specified, then the next argument should be the build dir (as set by ${PROJECT_BINARY_DIR} by cmake
workingDir=$2
echo "===== Testing in build dir $workingDir ====="
inBuild=1
cd $workingDir
fi
echo "===== Configuring xvfb ====="
# Starts the server first (to avoid a distracting warning output due to OpenGL context)
Xvfb :5 -screen 0 1600x1200x24 -ac +extension GLX +render -noreset -v -fbdir $workingDir/ &
xvfbPid=$!
echo "PID of Xvfb: $xvfbPid"
export DISPLAY=:5
export XAUTHORITY=/dev/null
echo "===== Get CamiTK configuration ====="
if [ "$inBuild" == "0" ] ; then
camitk-config --config > ./config-output 2>&1
else
bin/camitk-config --config > ./config-output 2>&1
fi
camitkConfig=$(cat config-output)
echo "===== config-output ====="
cat ./config-output
echo "===== camitkConfig ====="
echo $camitkConfig
# ---------------------- expected value ----------------------
getExpectedValue() {
case "$1" in
"CamiTK Short Version")
case "$version" in
"upstream")
echo "camitk-4.1"
;;
"jessie")
echo "camitk-3.3"
;;
"sid" | *)
echo "camitk-4.0"
;;
esac
;;
"CamiTK Global Installation Directory")
case "$version" in
"upstream")
echo $(pwd) # upstream is tested in build dir
;;
*)
# for package test: it should always be /usr
echo "/usr"
;;
esac
;;
"Number of Component Extensions")
case "$version" in
"upstream")
echo "13" # 13 in sdk, imaging and modeling and 2 in tutorials
;;
"jessie")
echo "12"
;;
"sid" | *)
echo "11"
;;
esac
;;
"Number of Action Extensions")
case "$version" in
"upstream")
echo "27" # 19 in sdk, imaging and modeling and 8 in tutorials
;;
"jessie")
echo "71"
;;
"sid" | *)
echo "19"
;;
esac
;;
"Number of File Extensions Supported")
case "$version" in
"upstream")
echo "37" # 35 in sdk, imaging and modeling and 2 in tutorials
;;
"jessie" | "sid" | *)
echo "35"
;;
esac
;;
"Number of Actions")
case "$version" in
"upstream")
echo "104" # 91 in sdk, imaging and modeling and 13 in tutorials
;;
"jessie")
echo "81"
;;
"sid" | *)
echo "91"
;;
esac
;;
esac
}
# ---------------------- installed version ----------------------
getInstalledVersion() {
echo $(echo $camitkConfig | cut -f2 -d" ")
}
checkInstalledVersion() {
case "$1" in
"4.0.4")
echo "sid"
;;
"3.3.2")
echo "jessie"
;;
*)
# try harder
numberedVersion=$(echo $camitkConfig | cut -f2 -d" " | cut -f1-3 -d".")
case "$numberedVersion" in
"4.1.0")
echo "upstream"
;;
*)
echo "unknown version"
;;
esac
;;
esac
}
# ---------------------- extension count ----------------------
getExtensionCount() {
echo $(echo "$camitkConfig" | grep "\[G\]" | wc -l)
}
getExpectedExtensionCount() {
case "$1" in
"upstream")
echo "40" # 30 extensions in sdk, imaging and modeling and 10 extensions in tutorials
;;
"jessie")
echo "83"
;;
"sid" | *)
echo "30"
;;
esac
}
# ---------------------- get config ----------------------
# get a specific value from config, text to parse from
# camitk-config --config is the first parameter of the function
# get the value after the string "... " and before the first space
getConfigValue() {
echo $(echo "$camitkConfig" | grep "$1" | sed 's/^.*\.\.\. //g' | cut -f1 -d" ")
}
# ---------------------- check value ----------------------
# use camitk-config to check a value and compare to
# expected value
checkValue() {
checkedValue="$1"
value=$(getConfigValue "$checkedValue")
echo "===== $checkValueId- $checkedValue: $value ====="
expected=$(getExpectedValue "$checkedValue")
if [ "$value" != "$expected" ]; then
echo "Error: unexpected $checkedValue ($value != $expected)"
exitStatus=$checkValueId
else
echo "OK"
fi
# increase id
checkValueId=$((checkValueId+1))
}
# --------------------------------------------------------------------------
#
# All tests are here
#
# --------------------------------------------------------------------------
installedVersion=$(getInstalledVersion)
echo "===== 1- Detected installed CamiTK version is: [$installedVersion] ====="
version=$(checkInstalledVersion $installedVersion)
if [ "$version" = "unknown version" ]; then
echo -n "Error: unexpected version "
exitStatus=1
else
echo -n "OK "
fi
echo "($version)"
value=$(getExtensionCount)
echo "===== 2- Number of extensions: $value ====="
expected=$(getExpectedExtensionCount $version)
if [ "$value" -ne "$expected" ]; then
echo "Error: unexpected number of globally installed extensions ($value != $expected)"
exitStatus=1
else
echo "OK"
fi
# init the id (next test is the third test)
checkValueId=3
checkValue "CamiTK Short Version"
checkValue "CamiTK Global Installation Directory"
checkValue "Number of Component Extensions"
checkValue "Number of Action Extensions"
checkValue "Number of File Extensions Supported"
checkValue "Number of Actions"
exit $exitStatus
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment