#!/bin/bash

## We will work in the tmp directory :
cd $AUTOPKGTEST_TMP

## ## Getting data by cloning git :
## git clone https://plmlab.math.cnrs.fr/tomogroup/ufo-testing.git
##
## An execution that should not ask for an OpenCL device
## Data should now sits here : ufo-testing/sino-bin-810x1562-4.raw
## ufo-launch read path=ufo-testing/sino-bin-810x1562-4.raw raw-width=810 raw-height=1562 raw-bitdepth=32 ! \
##   monitor print=5 ! \
##   zmq-pub expected-subscribers=0
## #  write filename=sino-810x1562-4_binx8.tiff

let nb_failed=0
let nb_worked=0

tl=$(ufo-query -l)

ta=($tl)

echo "Found ${#ta[@]} filters in ufo-filters"

for t in $tl; do
    ## echo ===============================
    ## echo Parameters for task $t \(ufo-query\)
    ## echo ------------------------------
    echo -n "Testing $t : "
    ufo-query -pv $t 1> /dev/null
    es=$?
    if [ $es -eq 0 ] ; then
	echo '[OK]'
	let nb_worked=1+$nb_worked
    else
	echo '[FAILED]'
	let nb_failed=1+$nb_failed
    fi
done

echo "$nb_worked filters could be introspected"
echo "$nb_failed filters could NOT be introspected"

if [ $nb_failed -ne 0 ] ; then
    exit -1
fi
