File: test_usecases.sh.in

package info (click to toggle)
hdf5 1.10.0-patch1+docs-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 143,572 kB
  • ctags: 38,562
  • sloc: ansic: 472,614; f90: 28,734; java: 27,116; xml: 17,791; sh: 16,757; cpp: 14,937; makefile: 1,769; perl: 1,339; yacc: 338; lex: 184; ruby: 24
file content (170 lines) | stat: -rw-r--r-- 4,650 bytes parent folder | download | duplicates (2)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#! /bin/bash
#
# Copyright by The HDF Group.
# 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 files COPYING and Copyright.html.  COPYING can be found at the root
# of the source code distribution tree; Copyright.html can be found at the
# root level of an installed copy of the electronic HDF5 document set and
# is linked from the top-level documents page.  It can also be found at
# http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have
# access to either file, you may request a copy from help@hdfgroup.org.
#
# Tests the use cases of swmr features.
#
# Created:
#   Albert Cheng, 2013/06/01.
# Modified:
#

# This is work in progress.
# For now, it shows how to run the test cases programs. It only verifies the
# exit codes are okay (0).

srcdir=@srcdir@

# Check to see if the VFD specified by the HDF5_DRIVER environment variable
# supports SWMR.
./swmr_check_compat_vfd
rc=$?
if [[ $rc != 0 ]] ; then
    echo
    echo "The VFD specified by the HDF5_DRIVER environment variable"
    echo "does not support SWMR"
    echo
    echo "SWMR use case tests skipped"
    echo
    exit 0
fi

# Define symbols
EXIT_SUCCESS=0
EXIT_FAILURE=1
EXIT_VALUE=$EXIT_SUCCESS	# Default all tests succeed
RESULT_PASSED=" PASSED"
RESULT_FAILED="*FAILED*"
RESULT_SKIP="-SKIP-"
USECASES_PROGRAMS="use_append_chunk use_append_mchunks"
TESTNAME="Use Case"

# Define variables
nerrors=0
verbose=yes

# Source in the output filter function definitions.
. $srcdir/../bin/output_filter.sh

# Define functions
# Print a line-line message left justified in a field of 72 characters.
# Results can be " PASSED", "*FAILED*", "-SKIP-", up to 8 characters
# wide.
# SPACES should be at least 71 spaces. ($* + ' ' + 71 + 8 >= 80)
#
TESTING() {
   SPACES="                                                                        "
   echo "$* $SPACES" | cut -c1-72 | tr -d '\012'
}

# Run a test and print PASS or *FAIL*.  If a test fails then increment
# the `nerrors' global variable and (if $verbose is set) display the
# difference between the actual output and the expected output. The
# expected output is given as the first argument to this function and
# the actual output file is calculated by replacing the `.ddl' with
# `.out'.  The actual output is not removed if $HDF5_NOCLEANUP has a
# non-zero value.
# ADD_H5_TEST
TOOLTEST() {
    program=$1
    shift

    actual="$program.out"
    actual_err="$program.err"
    actual_sav=${actual}-sav
    actual_err_sav=${actual_err}-sav

    # Run test.
    TESTING $program $@
    (
      $RUNSERIAL ./$program "$@"
    ) >$actual 2>$actual_err
    exit_code=$?

    # save actual and actual_err in case they are needed later.
    cp $actual $actual_sav
    STDOUT_FILTER $actual
    cp $actual_err $actual_err_sav
    STDERR_FILTER $actual_err
    cat $actual_err >> $actual

    if [ $exit_code -eq 0 ];then
	echo "$RESULT_PASSED"
	test yes = "$verbose" && sed 's/^/    /' < $actual
    else
	echo "$RESULT_FAILED"
	nerrors="`expr $nerrors + 1`"
	test yes = "$verbose" && sed 's/^/    /' < $actual
    fi

    # Clean up output file
    if test -z "$HDF5_NOCLEANUP"; then
	rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext
    fi
}

# run tests for H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled here temporary
USECORK=use_disable_mdc_flushes
for p in $USECORK; do
    TOOLTEST $p
    TOOLTEST $p -y 3
    TOOLTEST $p -n 3000
    TOOLTEST $p -n 5000
done

# run write order test here temporary
WRITEORDER=twriteorder
for p in $WRITEORDER; do
    TOOLTEST $p
    TOOLTEST $p -b 1000
    TOOLTEST $p -p 3000
    TOOLTEST $p -n 2000
    TOOLTEST $p -l w
    TOOLTEST $p -l r
done

# Report test results
if test $nerrors -eq 0 ; then
    echo "$WRITEORDER test passed."
else
    echo "$WRITEORDER test failed with $nerrors errors."
    EXIT_VALUE=$EXIT_FAILURE
    nerrors=0           # reset nerror for the regular tests below.
fi

# main body
for p in $USECASES_PROGRAMS; do
    TOOLTEST ./$p
    TOOLTEST ./$p -z 256
    tmpfile=/tmp/datatfile.$$
    TOOLTEST ./$p -f $tmpfile; rm -f $tmpfile
    TOOLTEST ./$p -l w
    TOOLTEST ./$p -l r
    # use case 1.9, testing with multi-planes chunks
    TOOLTEST ./$p -z 256 -y 5	# 5 planes chunks
    # cleanup temp datafile
    if test -z "$HDF5_NOCLEANUP"; then
	rm -f $p.h5
    fi
done


# Report test results and exit
if test $nerrors -eq 0 ; then
    echo "All $TESTNAME tests passed."
else
    echo "$TESTNAME tests failed with $nerrors errors."
    EXIT_VALUE=$EXIT_FAILURE
fi

exit $EXIT_VALUE