summaryrefslogtreecommitdiffstats
path: root/hl/tools/gif2h5/h52giftest.sh.in
blob: 4f4057fed32aa2ef425da06c7db63cf51f3c4b33 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
#
# Copyright by The HDF Group.
# Copyright by the Board of Trustees of the University of Illinois.
# All rights reserved.
#
# This file is part of HDF5.  The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
# HDF Utilities Test script


TESTFILE1="$srcdir/testfiles/h52giftst.h5"
TESTFILE2="$srcdir/testfiles/image1.gif"
TESTFILE3="$srcdir/testfiles/ex_image2.h5"

# initialize errors variable
errors=0

TESTING() {
   SPACES="                                                               "
   echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
}



# Verify the test runs with success (return code is 0)
TOOLTEST()
{
    # for now, discard any error messages generated.
    $RUNSERIAL $*  > /dev/null 2>&1

    RET=$?
    if [ $RET = 0 ] ; then
	echo " PASSED"
    else
	echo "*FAILED*"
	errors="` expr $errors + 1 `";
    fi

}

# Verify the test runs with failure (return code is not 0)
# Use for testing if tool can handle error conditions like
# illegal input, bad arguments, exceeding limits, ...
TOOLTESTFAIL()
{
    # for now, discard any error messages generated.
    $RUNSERIAL $* > /dev/null 2>&1

    RET=$?
    if [ $RET != 0 ] ; then
	echo " PASSED"
    else
	echo "*FAILED*"
	errors="` expr $errors + 1 `";
    fi
}


# Positive tests for gif2h5
echo "**validate the gif2h5 tool processes input correctly..."
TESTING "./gif2h5 image1.gif image1.h5"
TOOLTEST ./gif2h5 $TESTFILE2 image1.h5
echo ""

# Positive tests for h52gif
echo "**validate the h52gif tool processes input correctly..."
TESTING "./h52gif h52giftst.h5 image1.gif -i image"
TOOLTEST ./h52gif $TESTFILE1 image1.gif -i image
echo ""

# Negative tests.
echo "**verify that the h52gif tool handles error conditions correctly..."
# nonexisting dataset name
TESTING "./h52gif h52giftst.h5 image.gif -i nosuch_image"
TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i nosuch_image"
# this test should have failed but it did not. Comment it out for now.
#TESTING "./h52gif h52giftst.h5 image.gif -i palette"
#TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i palette"
TESTING "./h52gif h52giftst.h5 image24.gif -i image24bitpixel"
TOOLTESTFAIL "./h52gif $TESTFILE3 image24.gif -i image24bitpixel"
echo ""

# all done. summarize results.
if test $errors -eq 0 ; then
    echo "All gif2h5 and h52gif tests passed."
    exit 0
else
    echo "Some gif2h5 or h52gif tests failed with $errors errors."
    exit 1
fi