2007-04-11 13:17:13 +08:00
|
|
|
#! /bin/sh
|
|
|
|
#
|
|
|
|
# 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
|
2017-04-18 03:32:16 +08:00
|
|
|
# the COPYING file, which can be found at the root of the source code
|
2021-02-17 22:52:36 +08:00
|
|
|
# distribution tree, or in https://www.hdfgroup.org/licenses.
|
2017-04-18 03:32:16 +08:00
|
|
|
# If you do not have access to either file, you may request a copy from
|
|
|
|
# help@hdfgroup.org.
|
2007-04-11 13:17:13 +08:00
|
|
|
#
|
|
|
|
# Tests for the h5c++ compiler tool
|
|
|
|
|
2012-08-24 00:07:43 +08:00
|
|
|
srcdir=@srcdir@
|
|
|
|
|
2007-04-11 13:17:13 +08:00
|
|
|
# Initializations
|
2009-12-26 18:12:49 +08:00
|
|
|
TESTNAME=h5c++
|
|
|
|
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@}"
|
2009-04-23 05:06:24 +08:00
|
|
|
AR="@AR@"
|
|
|
|
RANLIB="@RANLIB@"
|
2007-04-11 13:17:13 +08:00
|
|
|
H5TOOL="h5c++" # The tool name
|
|
|
|
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
|
2007-04-11 13:17:13 +08:00
|
|
|
verbose=yes
|
|
|
|
|
|
|
|
# setup my machine information.
|
|
|
|
myos=`uname -s`
|
|
|
|
myhostnama=`uname -n`
|
|
|
|
|
|
|
|
# Generate some source files and library for tests.
|
2007-04-12 05:31:10 +08:00
|
|
|
suffix=cpp # source file suffix
|
|
|
|
hdf5main=${H5TOOL}_hdf5main.$suffix
|
2007-04-11 13:17:13 +08:00
|
|
|
hdf5main_o=${H5TOOL}_hdf5main.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
|
2024-01-31 02:20:58 +08:00
|
|
|
args=${H5TOOL}_args.$suffix
|
|
|
|
args_o=${H5TOOL}_args.o
|
2007-04-11 13:17:13 +08:00
|
|
|
|
|
|
|
# short hands
|
2007-07-12 05:01:34 +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
|
2018-07-14 02:40:22 +08:00
|
|
|
# by other test programs. This will cause a racing condition error when
|
2007-07-12 05:01:34 +08:00
|
|
|
# parallel make (e.g., gmake -j 4) is used.
|
2007-04-11 13:17:13 +08:00
|
|
|
temp_SRC="$hdf5main $appmain $prog1 $prog2"
|
2007-04-12 05:31:10 +08:00
|
|
|
temp_OBJ=`echo $temp_SRC | sed -e "s/\.${suffix}/.o/g"`
|
2007-07-12 05:01:34 +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 <string>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "H5Cpp.h"
|
|
|
|
|
|
|
|
#ifndef H5_NO_NAMESPACE
|
|
|
|
using namespace H5;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const H5std_string FILE_NAME( "tmpapp.h5" );
|
|
|
|
int sub1(void);
|
|
|
|
int sub2(void);
|
|
|
|
|
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
sub1();
|
|
|
|
sub2();
|
|
|
|
H5File file( FILE_NAME, H5F_ACC_TRUNC );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# generate prog1
|
|
|
|
cat > $prog1 <<EOF
|
2021-03-11 01:51:45 +08:00
|
|
|
#include <iostream>
|
2007-04-11 13:17:13 +08:00
|
|
|
#include <string>
|
|
|
|
|
2021-03-11 01:51:45 +08:00
|
|
|
using std::cout;
|
|
|
|
using std::endl;
|
2007-04-11 13:17:13 +08:00
|
|
|
int sub1(void)
|
|
|
|
{
|
|
|
|
cout << "in sub1" << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# generate prog2
|
|
|
|
cat > $prog2 <<EOF
|
2021-03-11 01:51:45 +08:00
|
|
|
#include <iostream>
|
2007-04-11 13:17:13 +08:00
|
|
|
#include <string>
|
|
|
|
|
2021-03-11 01:51:45 +08:00
|
|
|
using std::cout;
|
|
|
|
using std::endl;
|
2007-04-11 13:17:13 +08:00
|
|
|
int sub2(void)
|
|
|
|
{
|
|
|
|
cout << "in sub2" << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Generate HDF5 Main Program:
|
|
|
|
# An HDF5 sample program that calls hdf5 functions.
|
|
|
|
cat > $hdf5main <<EOF
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "H5Cpp.h"
|
|
|
|
|
|
|
|
#ifndef H5_NO_NAMESPACE
|
|
|
|
using namespace H5;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const H5std_string FILE_NAME( "tmphdf5.h5" );
|
|
|
|
|
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
H5File file( FILE_NAME, H5F_ACC_TRUNC );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2024-01-31 02:20:58 +08:00
|
|
|
# Generate args:
|
|
|
|
# An application main that test misc command line arguments being passed.
|
|
|
|
cat > $args <<EOF
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include "H5Cpp.h"
|
|
|
|
#ifndef H5_NO_NAMESPACE
|
|
|
|
using namespace H5;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const H5std_string FILE_NAME( "args.h5" );
|
|
|
|
|
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
char c = SGL_QUOTE; // 'H'
|
|
|
|
char *s = DBL_QUOTE; // "HDF"
|
|
|
|
int val = MISC; // 42
|
|
|
|
|
|
|
|
H5File file( FILE_NAME, H5F_ACC_TRUNC );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2007-04-11 13:17:13 +08:00
|
|
|
|
|
|
|
# Parse option
|
|
|
|
# None
|
|
|
|
|
2024-01-31 02:20:58 +08:00
|
|
|
# Print a line-line message left justified in a field of 74 characters
|
2007-04-11 13:17:13 +08:00
|
|
|
# beginning with the word "Testing".
|
|
|
|
#
|
|
|
|
TESTING() {
|
|
|
|
SPACES=" "
|
2024-01-31 02:20:58 +08:00
|
|
|
echo "Testing $* $SPACES" | cut -c1-74 | tr -d '\012'
|
2007-04-11 13:17:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# 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"
|
|
|
|
else
|
|
|
|
echo "*FAILED*"
|
|
|
|
nerrors="`expr $nerrors + 1`"
|
|
|
|
test yes = "$verbose" && \
|
|
|
|
( 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 ###
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# HDF5 program that calls HDF5 APIs.
|
|
|
|
echo "***"Simple Compile and Link in one step.
|
|
|
|
TOOLTEST $hdf5main
|
|
|
|
# Application program that calls HDF5 and its own functions.
|
|
|
|
TOOLTEST $appmain $prog1 $prog2
|
|
|
|
|
|
|
|
# Compile, then link.
|
|
|
|
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
|
|
|
|
|
|
|
|
# Build external library, then link with it.
|
|
|
|
echo "***"Build external library and link with it.
|
|
|
|
TOOLTEST -c $prog1 $prog2
|
|
|
|
rm -f $applib
|
|
|
|
$AR cru $applib $prog1_o $prog2_o
|
|
|
|
$RANLIB $applib
|
|
|
|
TOOLTEST $appmain $applib
|
|
|
|
TOOLTEST $appmain_o $applib
|
|
|
|
# This is peculiar but should work. (See bug ID 729)
|
|
|
|
TOOLTEST -c $hdf5main
|
|
|
|
rm -f $applib
|
|
|
|
$AR cru $applib $hdf5main_o
|
|
|
|
$RANLIB $applib
|
|
|
|
# SunOS does not support this. Skip it.
|
|
|
|
if [ $myos = SunOS ]; then
|
|
|
|
SKIP -o a.out $applib
|
|
|
|
else
|
|
|
|
TOOLTEST -o a.out $applib
|
|
|
|
fi
|
|
|
|
|
2007-04-12 05:31:10 +08:00
|
|
|
# Just preprocess, no compile, no link.
|
|
|
|
echo "***"Just preprocess, no compile, no link.
|
2007-04-11 13:17:13 +08:00
|
|
|
TOOLTEST -E $hdf5main
|
|
|
|
TOOLTEST -E $appmain $prog1 $prog2
|
|
|
|
|
2024-01-31 02:20:58 +08:00
|
|
|
# HDF5 program that depends on input args.
|
|
|
|
echo "***"Simple Compile and Link in one step with user-supplied arguments.
|
|
|
|
TOOLTEST -DSGL_QUOTE=\'H\' -DDBL_QUOTE=\"HDF\" -DMISC=42 $args
|
|
|
|
|
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
|