summaryrefslogtreecommitdiffstats
path: root/ue2/imgsynth2/test/test.sh
blob: 5d760b9d2d27ef0c3ff4394f211d2508f97e54b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash

inputs=( $(ls test/input_* | sort -n) )

for input in ${inputs[@]}
do
  echo "Testing $input ..."

  files=()
  for tag in "#in: " "#out: " "#ref: "
  do
    tmp=$(grep "$tag" "$input")
    if [ -z "$tmp" ]
    then
      echo "  ERROR: Tag '$tag' missing"
      exit 1
    fi

    tmp=${tmp:${#tag}}
    #if [ ! -e "$tmp" ]
    #then
    #  echo "  ERROR: File '$tmp' doesn't exist"
    #  exit 1
    #fi

    files+=("$tmp")
  done

  rm -f "${files[1]}"
  ./imgsynth2 -i "$input"
  ret=$?
  if [ $ret -ne 0 ]
  then
    echo "  ERROR: Script didn't exit properly"
    exit 1
  fi

  md5_1=$(md5sum < "${files[1]}")
  md5_2=$(md5sum < "${files[2]}")
  if [ "$md5_1" != "$md5_2" ]
  then
    echo "  ERROR: ${files[1]} and ${files[2]} differ"
    exit 1
  else
    echo "  Test successful"
  fi
done