File indexing completed on 2024-04-28 16:22:07

0001 #! /bin/sh
0002 # test_messages:
0003 # $1: program
0004 # $2: version
0005 # $3: input file
0006 # $4: data output directory
0007 
0008 # check input parameters
0009 
0010 prog=$(command -v "$1")
0011 
0012 if ! echo "x_$prog" | grep -Fxq "x_$1"; then
0013     echo "FAIL  Cannot find correct program: $1, found: $prog"
0014     echo "Note: $1 must be installed to run this test."
0015     echo "      E.g: 'make install && ctest'"
0016     exit 1;
0017 fi
0018 
0019 if test -z "$3"; then
0020     echo "FAIL  Called without input file"
0021     exit 1
0022 fi
0023 
0024 if ! test -f "$3"; then
0025     echo "FAIL  $3 is not a file"
0026     exit 1
0027 fi
0028 
0029 if test -z "$4"; then
0030     echo "FAIL Called without data output directory"
0031     exit 1
0032 fi
0033 if ! test -d "$4"; then
0034     echo "FAIL $4 is not a directory"
0035     exit 1
0036 fi
0037 
0038 
0039 version=$("$prog" --version | cut -d ' ' -f 2)
0040 echo "Testing: $prog version: $version"
0041 if echo "$version" | grep -Fxq "$2"; then
0042     if ! $("$prog" --benchmark-loading '$3'); then
0043         echo "FAIL $prog failed"
0044         exit 1
0045     fi
0046 else
0047     echo "FAIL Not correct version: $2"
0048     exit 1
0049 fi
0050 
0051 exit 0