1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group.                                               *
3  * Copyright by the Board of Trustees of the University of Illinois.         *
4  * All rights reserved.                                                      *
5  *                                                                           *
6  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
7  * terms governing use, modification, and redistribution, is contained in    *
8  * the COPYING file, which can be found at the root of the source code       *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
10  * If you do not have access to either file, you may request a copy from     *
11  * help@hdfgroup.org.                                                        *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*****************************************************************************
15    FILE
16    testhdf5.cpp - HDF5 testing framework main file.
17 
18    REMARKS
19    General test wrapper for HDF5 C++ library test programs
20 
21    DESIGN
22    Each test function should be implemented as function having no
23    parameters and returning void (i.e. no return value).  They should be put
24    into the list of AddTest() calls in main() below.  Functions which depend
25    on other functionality should be placed below the AddTest() call for the
26    base functionality testing.
27 
28    EXTERNAL ROUTINES/VARIABLES:
29         TestInit(...) -- Initialize testing framework
30         TestInfo(...) -- Print test info
31         AddTest(...)  -- Setup a test function and add it to the list of tests
32         TestParseCmdLine(...) -- Parse command line arguments
33         PerformTests() -- Perform requested testing
34         GetTestSummary() -- Retrieve Summary request value
35         TestSummary() -- Display test summary
36         GetTestCleanup() -- Retrieve Cleanup request value
37         TestCleanup() -- Clean up files from testing
38         GetTestNumErrs() -- Retrieve the number of testing errors
39 
40  ***************************************************************************/
41 #ifdef OLD_HEADER_FILENAME
42 #include <iostream.h>
43 #else
44 #include <iostream>
45 #endif
46 using std::cerr;
47 using std::endl;
48 
49 #include <string>
50 #include "H5Cpp.h"      // C++ API header file
51 using namespace H5;
52 
53 #include "h5test.h"
54 #include "h5cpputil.h"  // C++ utilility header file
55 
56 int
main(int argc,char * argv[])57 main(int argc, char *argv[])
58 {
59     try
60     {
61         // Turn of the auto-printing when failure occurs so that we can
62         // handle the errors appropriately since sometime failures are
63         // caused deliberately and expected.
64         Exception::dontPrint();
65         /* Initialize testing framework */
66         TestInit(argv[0], NULL, NULL);
67 
68         // testing file creation and opening in tfile.cpp
69         AddTest("tfile", test_file, cleanup_file, "File I/O Operations", NULL);
70         // testing dataset functionalities in dset.cpp
71         AddTest("dsets", test_dset, cleanup_dsets, "Dataset I/O Operations", NULL);
72         // testing dataspace functionalities in th5s.cpp
73         AddTest("th5s",  test_h5s,  cleanup_h5s,  "Dataspaces", NULL);
74         // testing attribute functionalities in tattr.cpp
75         AddTest("tattr", test_attr, cleanup_attr,  "Attributes", NULL);
76         // testing object functionalities in tobject.cpp
77         AddTest("tobject", test_object, cleanup_object,  "Objects", NULL);
78         // testing reference functionalities in trefer.cpp
79         AddTest("trefer", test_reference, cleanup_reference,  "References", NULL);
80         // testing variable-length strings in tvlstr.cpp
81         AddTest("tvlstr", test_vlstrings, cleanup_vlstrings,  "Variable-Length Strings", NULL);
82         AddTest("ttypes", test_types, cleanup_types,  "Generic Data Types", NULL);
83         AddTest("tarray", test_array, cleanup_array,  "Array Datatypes", NULL);
84         AddTest("tcompound", test_compound, cleanup_compound,  "Compound Data Types", NULL);
85         AddTest("tdspl", test_dsproplist, cleanup_dsproplist,  "Dataset Property List", NULL);
86         AddTest("tfilter", test_filters, cleanup_filters,  "Various Filters", NULL);
87         AddTest("tlinks", test_links, cleanup_links,  "Various Links", NULL);
88 /* Comment out tests that are not done yet. - BMR, Feb 2001
89         AddTest("select", test_select, cleanup_select,  "Selections", NULL);
90         AddTest("time", test_time, cleanup_time,  "Time Datatypes", NULL);
91         AddTest("vltypes", test_vltypes, cleanup_vltypes,  "Variable-Length Datatypes", NULL);
92 */
93         AddTest("iterate", test_iterate, cleanup_iterate,  "Group & Attribute Iteration", NULL);
94 /*
95         AddTest("genprop", test_genprop, cleanup_genprop,  "Generic Properties", NULL);
96         AddTest("id", test_ids, NULL,  "User-Created Identifiers", NULL);
97 
98 Comment out tests that are not done yet */
99 
100 /* Tentative - BMR 2007/1/12
101         AddTest("enum", test_enum, cleanup_enum,  "Enum Data Types", NULL);
102 */
103     }
104     catch (Exception& E)
105     {
106         issue_fail_msg("Tests failed", __LINE__, __FILE__, E.getCDetailMsg());
107     }
108 
109     /* Display testing information */
110     TestInfo(argv[0]);
111 
112     /* Parse command line arguments */
113     TestParseCmdLine(argc,argv);
114 
115     /* Perform requested testing */
116     PerformTests();
117 
118     /* Display test summary, if requested */
119     if (GetTestSummary())
120         TestSummary();
121 
122     /* Clean up test files, if allowed */
123     if (GetTestCleanup() && !getenv("HDF5_NOCLEANUP"))
124         TestCleanup();
125 
126     /* Release test infrastructure */
127     TestShutdown();
128 
129     return (GetTestNumErrs());
130 }
131 
132