2007-04-11 13:17:13 +08:00
|
|
|
#! /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 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 for the h5cc compiler tool
|
2008-09-27 17:13:02 +08:00
|
|
|
# Created: Albert Cheng, 2007/4/11
|
2007-04-11 13:17:13 +08:00
|
|
|
#
|
|
|
|
# Modification:
|
2008-09-27 17:13:02 +08:00
|
|
|
# Albert Cheng, 2008/9/27
|
|
|
|
# Added -shlib tests and verbose control.
|
2009-10-28 15:26:27 +08:00
|
|
|
# Albert Cheng, 2009/10/28
|
|
|
|
# Added version compatibility tests.
|
2007-04-11 13:17:13 +08:00
|
|
|
#
|
|
|
|
|
|
|
|
# Initializations
|
2009-12-26 18:12:49 +08:00
|
|
|
TESTNAME=h5cc
|
|
|
|
EXIT_SUCCESS=0
|
|
|
|
EXIT_FAILURE=1
|
|
|
|
|
2007-04-11 13:17:13 +08:00
|
|
|
# Where the tool is installed.
|
2007-05-31 03:25:08 +08:00
|
|
|
prefix="${prefix:-@prefix@}"
|
2007-04-11 13:17:13 +08:00
|
|
|
PARALLEL=@PARALLEL@ # Am I in parallel mode?
|
2009-04-23 05:06:24 +08:00
|
|
|
AR="@AR@"
|
|
|
|
RANLIB="@RANLIB@"
|
2007-04-11 13:17:13 +08:00
|
|
|
if [ "$PARALLEL" = no ]; then
|
|
|
|
H5TOOL="h5cc" # The tool name
|
|
|
|
else
|
|
|
|
H5TOOL="h5pcc" # The tool name
|
|
|
|
fi
|
|
|
|
H5TOOL_BIN="${prefix}/bin/${H5TOOL}" # The path of the tool binary
|
|
|
|
|
|
|
|
CMP='cmp -s'
|
|
|
|
DIFF='diff -c'
|
|
|
|
|
2009-12-26 18:12:49 +08:00
|
|
|
nerrors=$EXIT_SUCCESS
|
2008-09-27 17:13:02 +08:00
|
|
|
verbose=${HDF5_VERBOSE:-1} # 0: none; 1: default; 2: chatty; 3: everything
|
|
|
|
test $verbose -gt 2 && set -x
|
2009-10-28 15:26:27 +08:00
|
|
|
H5_NO_DEPRECATED_SYMBOLS=`grep '#define H5_NO_DEPRECATED_SYMBOLS ' ../src/H5pubconf.h`
|
|
|
|
H5_USE_16_API_DEFAULT=`grep '#define H5_USE_16_API_DEFAULT ' ../src/H5pubconf.h`
|
2007-04-11 13:17:13 +08:00
|
|
|
|
2007-04-12 05:31:10 +08:00
|
|
|
# setup my machine information.
|
|
|
|
myos=`uname -s`
|
|
|
|
myhostnama=`uname -n`
|
|
|
|
|
2007-04-11 13:17:13 +08:00
|
|
|
# The build (current) directory might be different than the source directory.
|
|
|
|
if test -z "$srcdir"; then
|
|
|
|
srcdir=.
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Generate some source files and library for tests.
|
2007-04-12 05:31:10 +08:00
|
|
|
suffix=c # source file suffix
|
|
|
|
hdf5main=${H5TOOL}_hdf5main.$suffix
|
2007-04-11 13:17:13 +08:00
|
|
|
hdf5main_o=${H5TOOL}_hdf5main.o
|
2009-10-28 15:26:27 +08:00
|
|
|
v16main=${H5TOOL}_v16main.$suffix
|
|
|
|
v16main_o=${H5TOOL}_v16main.o
|
|
|
|
v18main=${H5TOOL}_v18main.$suffix
|
|
|
|
v18main_o=${H5TOOL}_v18main.o
|
2007-04-12 05:31:10 +08:00
|
|
|
appmain=${H5TOOL}_appmain.$suffix
|
2007-04-11 13:17:13 +08:00
|
|
|
appmain_o=${H5TOOL}_appmain.o
|
2007-04-12 05:31:10 +08:00
|
|
|
prog1=${H5TOOL}_prog1.$suffix
|
2007-04-11 13:17:13 +08:00
|
|
|
prog1_o=${H5TOOL}_prog1.o
|
2007-04-12 05:31:10 +08:00
|
|
|
prog2=${H5TOOL}_prog2.$suffix
|
2007-04-11 13:17:13 +08:00
|
|
|
prog2_o=${H5TOOL}_prog2.o
|
|
|
|
applib=libapp${H5TOOL}.a
|
|
|
|
|
|
|
|
# short hands
|
2007-07-11 04:26:42 +08:00
|
|
|
# Caution: if some *.h5 files must be cleaned here, list them by names.
|
|
|
|
# Don't use the wildcard form of *.h5 as it will wipe out even *.h5 generated
|
|
|
|
# by otehr test programs. This will cause a racing condition error when
|
|
|
|
# parallel make (e.g., gmake -j 4) is used.
|
2009-10-28 15:26:27 +08:00
|
|
|
temp_SRC="$hdf5main $v16main $v18main $appmain $prog1 $prog2"
|
2007-04-12 05:31:10 +08:00
|
|
|
temp_OBJ=`echo $temp_SRC | sed -e "s/\.${suffix}/.o/g"`
|
2007-07-11 04:26:42 +08:00
|
|
|
temp_FILES="a.out $applib"
|
2007-04-11 13:17:13 +08:00
|
|
|
|
|
|
|
# Generate appmain:
|
|
|
|
# An application Main that calls hdf5 and application's own functions.
|
|
|
|
cat > $appmain <<EOF
|
|
|
|
#include "hdf5.h"
|
|
|
|
#define H5FILE_NAME "tmp.h5"
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
hid_t file; /* file and dataset handles */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a new file using H5F_ACC_TRUNC access,
|
|
|
|
* default file creation properties, and default file
|
|
|
|
* access properties.
|
|
|
|
*/
|
|
|
|
sub1();
|
|
|
|
sub2();
|
|
|
|
file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
H5Fclose(file);
|
|
|
|
|
|
|
|
printf("HDF5 C Sample program ran successfully. File %s generated.\n", H5FILE_NAME);
|
|
|
|
remove(H5FILE_NAME);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# generate prog1
|
|
|
|
cat > $prog1 <<EOF
|
|
|
|
sub1(void)
|
|
|
|
{
|
|
|
|
printf("in sub1\n");
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# generate prog2
|
|
|
|
cat > $prog2 <<EOF
|
|
|
|
sub2(void)
|
|
|
|
{
|
|
|
|
printf("in sub2\n");
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Generate HDF5 Main Program:
|
|
|
|
# An HDF5 sample program that calls hdf5 functions.
|
|
|
|
cat > $hdf5main <<EOF
|
2009-10-20 13:07:04 +08:00
|
|
|
#include "hdf5.h"
|
2007-04-11 13:17:13 +08:00
|
|
|
#define H5FILE_NAME "tmp.h5"
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
hid_t file; /* file and dataset handles */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a new file using H5F_ACC_TRUNC access,
|
|
|
|
* default file creation properties, and default file
|
|
|
|
* access properties.
|
|
|
|
*/
|
|
|
|
file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
H5Fclose(file);
|
|
|
|
|
|
|
|
printf("HDF5 C Sample program ran successfully. File %s generated.\n", H5FILE_NAME);
|
|
|
|
remove(H5FILE_NAME);
|
2008-10-25 03:12:21 +08:00
|
|
|
|
2007-04-11 13:17:13 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2009-10-28 15:26:27 +08:00
|
|
|
# Generate HDF5 v1.6 Main Program:
|
|
|
|
# This makes unique V1.6 API calls.
|
|
|
|
cat > $v16main <<EOF
|
|
|
|
/* This is a V1.6 API calls example Program. */
|
|
|
|
#include "hdf5.h"
|
|
|
|
#define H5FILE_NAME "tmp.h5"
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
hid_t file, group, group1; /* file and group handles */
|
|
|
|
|
|
|
|
file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
group = H5Gcreate(file, "/Group", 0);
|
|
|
|
group1 = H5Gcreate1(file, "/Group1.6", 0);
|
|
|
|
H5Gclose(group1);
|
|
|
|
H5Gclose(group);
|
|
|
|
H5Fclose(file);
|
|
|
|
|
|
|
|
printf("HDF5 C program created with V1.6 API ran successfully. "
|
|
|
|
"File %s generated.\n", H5FILE_NAME);
|
|
|
|
remove(H5FILE_NAME);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Generate HDF5 v1.8 Main Program:
|
|
|
|
# This makes unique V1.8 API calls.
|
|
|
|
cat > $v18main <<EOF
|
|
|
|
/* This is a V1.8 API calls example Program. */
|
|
|
|
#include "hdf5.h"
|
|
|
|
#define H5FILE_NAME "tmp.h5"
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
hid_t file, group, group2; /* file and group handles */
|
|
|
|
|
|
|
|
file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
group = H5Gcreate(file, "/Group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
group2 = H5Gcreate2(file, "/Group1.8", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
H5Gclose(group2);
|
|
|
|
H5Gclose(group);
|
|
|
|
H5Fclose(file);
|
|
|
|
|
|
|
|
printf("HDF5 C program created with V1.8 API ran successfully. "
|
|
|
|
"File %s generated.\n", H5FILE_NAME);
|
|
|
|
remove(H5FILE_NAME);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2007-04-11 13:17:13 +08:00
|
|
|
|
|
|
|
# Parse option
|
|
|
|
# None
|
|
|
|
|
|
|
|
# Print a line-line message left justified in a field of 70 characters
|
|
|
|
# beginning with the word "Testing".
|
|
|
|
#
|
|
|
|
TESTING() {
|
|
|
|
SPACES=" "
|
|
|
|
echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Debug printing
|
|
|
|
# Change : to echo to print the debug statement
|
|
|
|
DPRINT() {
|
|
|
|
: $*
|
|
|
|
}
|
|
|
|
|
|
|
|
# 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
|
|
|
|
# failed output. The actual output is not removed if $HDF5_NOCLEANUP is
|
|
|
|
# defined.
|
|
|
|
#
|
|
|
|
TOOLTEST() {
|
|
|
|
out=test_$H5TOOL_$$.out
|
|
|
|
err=test_$H5TOOL_$$.err
|
|
|
|
|
|
|
|
# Run test.
|
|
|
|
TESTING $H5TOOL $@
|
|
|
|
$H5TOOL_BIN $@ > $out 2>&1
|
|
|
|
result=$?
|
|
|
|
if [ $result = 0 ]; then
|
|
|
|
echo " PASSED"
|
2008-09-27 17:13:02 +08:00
|
|
|
test $verbose -gt 1 && \
|
|
|
|
( echo "========== results ==========="; cat $out;
|
|
|
|
echo "===============================================") |sed 's/^/ /'
|
2007-04-11 13:17:13 +08:00
|
|
|
else
|
|
|
|
echo "*FAILED*"
|
|
|
|
nerrors="`expr $nerrors + 1`"
|
2008-09-27 17:13:02 +08:00
|
|
|
test $verbose -gt 0 && \
|
2007-04-11 13:17:13 +08:00
|
|
|
( echo "========== results ==========="; cat $out;
|
|
|
|
echo "===============================================") |sed 's/^/ /'
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Clean up output file
|
|
|
|
if test -z "$HDF5_NOCLEANUP"; then
|
|
|
|
rm -f $out
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Print a "SKIP" message
|
|
|
|
SKIP() {
|
|
|
|
TESTING $H5TOOL $@
|
|
|
|
echo " -SKIP-"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
### T H E T E S T S ###
|
|
|
|
##############################################################################
|
|
|
|
#
|
2008-09-27 17:13:02 +08:00
|
|
|
# Group 1: HDF5 program that calls HDF5 APIs.
|
2007-04-11 13:17:13 +08:00
|
|
|
echo "***"Simple Compile and Link in one step.
|
|
|
|
TOOLTEST $hdf5main
|
|
|
|
# Application program that calls HDF5 and its own functions.
|
|
|
|
TOOLTEST $appmain $prog1 $prog2
|
2008-09-27 17:13:02 +08:00
|
|
|
# Repeat with -shlib option
|
|
|
|
echo "***"Simple Compile and Link with -shlib in one step.
|
|
|
|
TOOLTEST -shlib $hdf5main
|
|
|
|
# Application program that calls HDF5 and its own functions.
|
|
|
|
TOOLTEST -shlib $appmain $prog1 $prog2
|
2007-04-11 13:17:13 +08:00
|
|
|
|
2008-09-27 17:13:02 +08:00
|
|
|
# Group 2: Compile, then link.
|
2007-04-11 13:17:13 +08:00
|
|
|
echo "***"Compile and Link in two steps.
|
|
|
|
TOOLTEST -c $hdf5main
|
|
|
|
TOOLTEST $hdf5main_o
|
|
|
|
TOOLTEST -c $appmain $prog1 $prog2
|
|
|
|
TOOLTEST $appmain_o $prog1_o $prog2_o
|
2008-09-27 17:13:02 +08:00
|
|
|
# Repeat with -shlib option
|
|
|
|
echo "***"Compile and Link with -shlib in two steps.
|
|
|
|
TOOLTEST -c $hdf5main
|
|
|
|
TOOLTEST -shlib $hdf5main_o
|
|
|
|
TOOLTEST -c $appmain $prog1 $prog2
|
|
|
|
TOOLTEST -shlib $appmain_o $prog1_o $prog2_o
|
2007-04-11 13:17:13 +08:00
|
|
|
|
2008-09-27 17:13:02 +08:00
|
|
|
# Group3: Build external library, then link with it.
|
2007-04-11 13:17:13 +08:00
|
|
|
echo "***"Build external library and link with it.
|
|
|
|
TOOLTEST -c $prog1 $prog2
|
|
|
|
$AR cru $applib $prog1_o $prog2_o
|
|
|
|
$RANLIB $applib
|
|
|
|
TOOLTEST $appmain $applib
|
|
|
|
TOOLTEST $appmain_o $applib
|
2008-09-27 17:13:02 +08:00
|
|
|
# Repeat with -shlib option
|
|
|
|
echo "***"Build external library and link with it using -shlib.
|
|
|
|
TOOLTEST -c $prog1 $prog2
|
|
|
|
$AR cru $applib $prog1_o $prog2_o
|
|
|
|
$RANLIB $applib
|
|
|
|
TOOLTEST -shlib $appmain $applib
|
|
|
|
TOOLTEST -shlib $appmain_o $applib
|
2007-04-11 13:17:13 +08:00
|
|
|
|
2008-09-27 17:13:02 +08:00
|
|
|
# Group 4: Just preprocess, no compile, no link.
|
2007-04-12 05:31:10 +08:00
|
|
|
echo "***"Just preprocess, no compile, no link.
|
2007-04-11 13:17:13 +08:00
|
|
|
TOOLTEST -E $hdf5main
|
|
|
|
TOOLTEST -E $appmain $prog1 $prog2
|
|
|
|
|
2009-10-28 15:26:27 +08:00
|
|
|
# Group5: Version compatibility tests.
|
|
|
|
echo "***"Version compatibility tests.
|
|
|
|
# Test these two cases now. More later.
|
|
|
|
# If H5_NO_DEPRECATED_SYMBOLS;
|
|
|
|
# then only v18main works.
|
|
|
|
# else if H5_USE_16_API_DEFAULT;
|
|
|
|
# then v16main works and -DH5_NO_DEPRECATED_SYMBOLS v18main also works.
|
|
|
|
# else v18main works and -DH5_USE_16_API_DEFAULT v16main also works.
|
|
|
|
#
|
|
|
|
if [ -n "$H5_USE_16_API_DEFAULT" ]; then
|
|
|
|
echo "H5_USE_16_API_DEFAULT is defined."
|
|
|
|
else
|
|
|
|
echo "H5_USE_16_API_DEFAULT is not defined."
|
|
|
|
fi
|
|
|
|
if [ -n "$H5_NO_DEPRECATED_SYMBOLS" ]; then
|
|
|
|
echo "H5_NO_DEPRECATED_SYMBOLS is defined."
|
|
|
|
else
|
|
|
|
echo "H5_NO_DEPRECATED_SYMBOLS is not defined."
|
|
|
|
fi
|
|
|
|
if [ -n "$H5_NO_DEPRECATED_SYMBOLS" ]; then
|
|
|
|
echo "Skipping $v16main test"
|
|
|
|
TOOLTEST $v18main
|
|
|
|
elif [ -n "$H5_USE_16_API_DEFAULT" ]; then
|
|
|
|
TOOLTEST $v16main
|
|
|
|
TOOLTEST -DH5_NO_DEPRECATED_SYMBOLS $v18main
|
|
|
|
else
|
|
|
|
TOOLTEST -DH5_USE_16_API_DEFAULT $v16main
|
|
|
|
TOOLTEST $v18main
|
|
|
|
fi
|
|
|
|
|
2007-04-11 13:17:13 +08:00
|
|
|
##############################################################################
|
|
|
|
# END
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
# Clean up file
|
|
|
|
if test -z "$HDF5_NOCLEANUP"; then
|
|
|
|
rm -f $temp_SRC $temp_OBJ $temp_FILES
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test $nerrors -eq 0 ; then
|
2009-12-26 18:12:49 +08:00
|
|
|
echo "All $TESTNAME tests passed."
|
|
|
|
exit $EXIT_SUCCESS
|
|
|
|
else
|
|
|
|
echo "$TESTNAME tests failed with $nerrors errors."
|
|
|
|
exit $EXIT_FAILURE
|
2007-04-11 13:17:13 +08:00
|
|
|
fi
|