about summary refs log tree commit diff
path: root/test/pamshuffle.test
blob: 371b65a5c915cc774f0ee29744d5f322cb15c892 (plain) (blame)
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
49
50
51
52
53
#! /bin/sh
# This script tests: pamshuffle
# Also requires: pamseq pamrestack pgmhist ppmhist pnmpsnr

tmpdir=${tmpdir:-/tmp}
seq_pam=${tmpdir}/seq.pam
seq16_pam=${tmpdir}/seq16.pam

out1_pam=${tmpdir}/out1.pam

echo "Test 1.  Should print 1081361896 1432 five times"

pgmhist -machine maze.pbm | cksum
pamshuffle -randomseed=1 maze.pbm | pgmhist -machine | cksum
pamshuffle -randomseed=2 maze.pbm | pgmhist -machine | cksum
pamshuffle -column -randomseed=3 maze.pbm | pgmhist -machine | cksum
pamrestack maze.pbm | pamshuffle -randomseed=3 | pgmhist -machine | cksum

echo "Test 2.  Should print 1936883899 143517 four times"

pamseq -tupletype="RGB" 3 15 > ${seq_pam}

ppmhist -map ${seq_pam} | cksum
pamshuffle -randomseed=2 ${seq_pam} | ppmhist -map | cksum
pamrestack -width=16 -trim=abort ${seq_pam} | tee ${seq16_pam} | \
  ppmhist -map | cksum
pamshuffle -column -randomseed=3 ${seq16_pam} | ppmhist -map | cksum

echo "Test 3.  Should print nomatch three times"

pamshuffle -randomseed=$((100 +i)) ${seq16_pam} > ${out1_pam}
pamshuffle -randomseed=${i} ${seq16_pam} | \
pnmpsnr -target=14.0 ${out1_pam} -
rm ${seq_pam} ${seq16_pam} ${out1_pam}

pamshuffle -randomseed=$((100 +i)) testimg.ppm > ${out1_pam}
pamshuffle -randomseed=${i} testimg.ppm | \
  pnmpsnr -target=14.0 ${out1_pam} -
rm ${out1_pam}

pamshuffle -randomseed=$((100 +i)) -column testimg.ppm > ${out1_pam}
pamshuffle -randomseed=${i} -column testimg.ppm | \
  pnmpsnr -target=14.0 ${out1_pam} -
rm ${out1_pam}

test_out=${tmpdir}/test_out
echo "Test Invalid."

. ${srcdir}/test-invalid.inc

invCmd "pamshuffle testimg.ppm testgrid.pbm"
invCmd "pamshuffle -randomseed -column testgrid.pbm"
invCmd "pamshuffle -randomseed=null testgrid.pbm"