File: compare-create-image

package info (click to toggle)
xplanet 1.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 7,280 kB
  • sloc: cpp: 24,219; ansic: 6,553; sh: 3,426; makefile: 350
file content (38 lines) | stat: -rwxr-xr-x 1,483 bytes parent folder | download
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
#!/bin/sh

oneTimeSetUp () {

  # ensure temporary directory exists
  if [ -z "$AUTOPKGTEST_TMP" ] ; then
    AUTOPKGTEST_TMP=$( mktemp -d )
  fi

  # setup test environment
  cp -r debian/tests/expected $AUTOPKGTEST_TMP
  mkdir -p $HOME/.xplanet/images
  cp debian/tests/clouds.jpg $HOME/.xplanet/images


  ## generate new images
  for conf in /etc/xplanet/config/* ; do
    filename=${conf##*/}
    xplanet -geometry 1024x768 -config $conf -date 20220826.163000 -num_times 1 -fontsize=36 -font=FreeMonoBold.ttf -output $AUTOPKGTEST_TMP/$filename.jpeg
    xplanet -geometry 1024x768 -config $conf -date 20220826.163000 -num_times 1 -fontsize=36 -font=FreeMonoBold.ttf -output $AUTOPKGTEST_TMP/$filename.png
  done
}


# then we check the created images with the ones we created and verified earlier
test_compare_images () {
  for conf in /etc/xplanet/config/* ; do
    filename=${conf##*/}
    # Comparing for equal images fails on some architectures (endianess? 32/64bit?). Hence we "just" compare for very similar images.
    result_jpg="$( compare -metric ncc $AUTOPKGTEST_TMP/expected/$filename.jpeg $AUTOPKGTEST_TMP/$filename.jpeg $AUTOPKGTEST_TMP/diff.jpg 2>&1 )"
    result_png="$( compare -metric ncc $AUTOPKGTEST_TMP/expected/$filename.png $AUTOPKGTEST_TMP/$filename.png $AUTOPKGTEST_TMP/diff.png 2>&1 )"
    assertTrue "Comparing $filename.jpg" "expr '0.99' '<' '$result_jpg'"
    assertTrue "Comparing $filename.png" "expr '0.99' '<' '$result_png'"
  done
}

. shunit2