about summary refs log tree commit diff
path: root/test/targa-roundtrip.test
blob: 2dd04e9147d5518c05d7a93078c67d73321c14da (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#! /bin/bash
# This script tests: pamtotga tgatoppm
# Also requires: ppmtopgm pgmtopbm pamchannel pnmquant pamdepth

tmpdir=${tmpdir:-/tmp}

echo "Test 1:  Should print 281226646 481 ten times"

for mode in "-mono" "-mono -norle" \
            "-cmap" "-cmap -norle" "-cmap16" "-cmap16 -norle" \
            "-rgb"  "-rgb  -norle" "" "-norle"
  do
  pamtotga ${mode} maze.pbm | \
    tgatoppm | ppmtopgm | \
    pgmtopbm -threshold -val 0.5 | cksum
  done

echo "Test 2:  Should produce 1571496937 33838 ten times"

test_pam=${tmpdir}/testimg.pgm
pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 > ${test_pam} 

for mode in "-mono" "-mono -norle" \
            "-cmap" "-cmap -norle" "-cmap16" "-cmap16 -norle" \
            "-rgb"  "-rgb  -norle" "" "-norle"
  do
  pamtotga ${mode} ${test_pam} | tgatoppm | ppmtopgm | cksum
  done

rm ${test_pam}

echo "Test 3.  Should print 1926073387 101484 four times"

for mode in "-rgb" "-rgb -norle" "" "-norle"
  do
  pamtotga ${mode} testimg.ppm | tgatoppm | cksum
  done

echo "Test 4.  Should print 0 0 0 : 0 six times"

test256_ppm=${tmpdir}/test256.ppm
pnmquant 256 testimg.ppm > ${test256_ppm} || echo "pnmquant failed"
# test image may have less than 256 colors

for mode in "-rgb" "-rgb -norle" "-cmap" "-cmap -norle" "" "-norle"
  do
  pamtotga ${mode} ${test256_ppm} | tgatoppm | cmp -s - ${test256_ppm}
  echo ${PIPESTATUS[@]} ":" $?
done

echo "Test 4.  Should print 0 0 0 : 0 twice, then 0 0 0 0 : 0 six times"

test256_31_ppm=${tmpdir}/test256-31.ppm
pamdepth 31 ${test256_ppm} > ${test256_31_ppm} || echo "pamdepth failed"
rm ${test256_ppm}

for mode in "-cmap16" "-cmap16 -norle"
  do pamtotga ${mode} ${test256_31_ppm} | tgatoppm | cmp -s - ${test256_31_ppm}
  echo ${PIPESTATUS[@]} ":" $?
  done

for mode in  "-rgb" "-rgb -norle" "-cmap" "-cmap -norle" "" "-norle"
  do pamtotga ${mode} ${test256_31_ppm} | tgatoppm | \
     pamdepth 31 | cmp -s - ${test256_31_ppm}
  echo ${PIPESTATUS[@]} ":" $?
  done

rm ${test256_31_ppm}