Files
hdf5/test/h5test.h
Dana Robinson eebaee6529 VFD SWMR: sync with develop (#830)
* Normalization with develop

* Removes checks and work-arounds for strtoll and strtoull (#769)

* Removes checks for (v)snprintf, which are C99 (#772)

* Update missing release note info. (#776)

* Replaces the H5_OVERRIDE macro with override (#773)

The macro is no longer necessary now that we require C++11.

* Cleans up some POSIX header bits in H5private.h (#783)

* Removes outdated checks for ways inline might be defined (#781)

These are obsolete now that we require C99.

* Removes checks for system(), which is C89/90 (#782)

* Removes C++ dependency on H5private.h (#774)

* Removes C++ dependency on H5private.h

Most C API calls have been removed, aside from a few uses of free,
where we just dropped the 'HD'. A couple of H5_ATTR_UNUSED macros
were also replaced with (void) statements.

* Committing clang-format changes

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Further simplifies Autotools type size checks (#789)

Also fixes an issue where clock_gettime and difftime are not detected
due to earlier simplifications of this code.

* Release Note (#784)

* Normalization of CMake H5pubconf.h with Autotools (#791)

Mostly just moving things around and changing the comments to keep the
delta small. The only symbol change is that for curl/curl.h which I
changed to H5_HAVE_CURL_CURL_H to match the Autotools. This symbol
is not used in the library and is just an artifact of the checks.

* Fix tools test (#794)

* Removes ancient Autotools cruft (#790)

* Reorganization of C and POSIX headers in H5public.h & H5private.h (#793)

* Reorganization of C and POSIX headers in H5public.h & H5private.h

Consolidated and removed duplicates

* It turns out Windows has sys/types.h

Co-authored-by: Larry Knox <lrknox@hdfgroup.org>

* Removes checks for signal and set/longjmp, which are C89 (#798)

Also removes checks for setjmp.h and stddef.h

* Assume frexpl/f and fabsl/f, which are C99 (#799)

* Assume the library has C99 types in C++ type code (#806)

* Assume the library has C99 types in C++ type code

* Committing clang-format changes

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Removes obsolete equivalents of C99's __func__ (#800)

* Cleans up POSIX/C bits in H5private.h (#804)

* Cleans up POSIX/C bits in H5private.h

* Assume difftime exists (C89)
* Reorg AC_CHECK_HEADERS so headers are in alphabetical order
* Split off networking-related AC_CHECK_HEADERS
* Remove unused UNAME_CYGWIN from configure.ac
* Remove checks for unused sys/timeb.h
* Tidying pass over H5private.h HD prefix macros
* Tidy H5win32defs.h
* Add HD prefix to various scanf calls

* Committing clang-format changes

* Fixes to the alarm(2) code used in the tests to make Windows happy

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Brings the tools getopt(3) replacement into the main library (#803)

* Moves get_option from the tools library to the C library

* Adds H5 prefix to get_option call and variables

* Renames the H5_get_option long options struct and enum

* Removes type guesses when C99 types are missing (#807)

* Assume C99 types exist in H5detect.c (#808)

* Fixes parallel issues from recent C99 changes

* Adds MPE FUNC --> __func__ changes missed in earlier PRs

* Fix typo

* Fixes parallel issues from recent C99 changes (#809)

* Fixes parallel issues from recent C99 changes

* Adds MPE FUNC --> __func__ changes missed in earlier PRs

* Even more missed FUNC --> __func__ macros

* Removes remaining H5_TIME_WITH_SYS_TIME cruft (#810)

Mostly from CMake

* Merges with develop

* Committing clang-format changes

* Normalization with develop

* direct_chunk test and H5Dget_chunk_storage_size changes
* Removes unused H5O call

* Brings some dataspace changes from the combo branch merge

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
2021-07-12 13:30:20 -07:00

321 lines
17 KiB
C

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Programmer: Robb Matzke
* Friday, November 20, 1998
*
* Purpose: Test support stuff.
*/
#ifndef H5TEST_H
#define H5TEST_H
/*
* Include required headers. This file tests internal library functions,
* so we include the private headers here.
*/
#include "hdf5.h"
#include "H5private.h"
#include "H5Eprivate.h"
/*
* Predefined test verbosity levels.
*
* Convention:
*
* The higher the verbosity value, the more information printed.
* So, output for higher verbosity also include output of all lower
* verbosity.
*
* Value Description
* 0 None: No informational message.
* 1 "All tests passed"
* 2 Header of overall test
* 3 Default: header and results of individual test
* 4
* 5 Low: Major category of tests.
* 6
* 7 Medium: Minor category of tests such as functions called.
* 8
* 9 High: Highest level. All information.
*/
#define VERBO_NONE 0 /* None */
#define VERBO_DEF 3 /* Default */
#define VERBO_LO 5 /* Low */
#define VERBO_MED 7 /* Medium */
#define VERBO_HI 9 /* High */
/*
* Verbose queries
* Only None needs an exact match. The rest are at least as much.
*/
/* A macro version of HDGetTestVerbosity(). */
/* Should be used internally by the libtest.a only. */
#define HDGetTestVerbosity() (TestVerbosity)
#define VERBOSE_NONE (HDGetTestVerbosity() == VERBO_NONE)
#define VERBOSE_DEF (HDGetTestVerbosity() >= VERBO_DEF)
#define VERBOSE_LO (HDGetTestVerbosity() >= VERBO_LO)
#define VERBOSE_MED (HDGetTestVerbosity() >= VERBO_MED)
#define VERBOSE_HI (HDGetTestVerbosity() >= VERBO_HI)
/*
* Test controls definitions.
*/
#define SKIPTEST 1 /* Skip this test */
#define ONLYTEST 2 /* Do only this test */
#define BEGINTEST 3 /* Skip all tests before this test */
/*
* This contains the filename prefix specified as command line option for
* the parallel test files.
*/
H5TEST_DLLVAR char *paraprefix;
#ifdef H5_HAVE_PARALLEL
H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */
#endif
/*
* Print the current location on the standard output stream.
*/
#define AT() HDprintf(" at %s:%d in %s()...\n", __FILE__, __LINE__, __func__);
/*
* The name of the test is printed by saying TESTING("something") which will
* result in the string `Testing something' being flushed to standard output.
* If a test passes, fails, or is skipped then the PASSED(), H5_FAILED(), or
* SKIPPED() macro should be called. After H5_FAILED() or SKIPPED() the caller
* should print additional information to stdout indented by at least four
* spaces. If the h5_errors() is used for automatic error handling then
* the H5_FAILED() macro is invoked automatically when an API function fails.
*/
#define TESTING(WHAT) \
{ \
HDprintf("Testing %-62s", WHAT); \
HDfflush(stdout); \
}
#define TESTING_2(WHAT) \
{ \
HDprintf(" Testing %-60s", WHAT); \
HDfflush(stdout); \
}
#define PASSED() \
do { \
HDputs(" PASSED"); \
HDfflush(stdout); \
} while (0)
#define H5_FAILED() \
{ \
HDputs("*FAILED*"); \
HDfflush(stdout); \
}
#define H5_WARNING() \
{ \
HDputs("*WARNING*"); \
HDfflush(stdout); \
}
#define SKIPPED() \
{ \
HDputs(" -SKIP-"); \
HDfflush(stdout); \
}
#define PUTS_ERROR(s) \
{ \
HDputs(s); \
AT(); \
goto error; \
}
#define TEST_ERROR \
{ \
H5_FAILED(); \
AT(); \
goto error; \
}
#define STACK_ERROR \
{ \
H5Eprint2(H5E_DEFAULT, stdout); \
goto error; \
}
#define FAIL_STACK_ERROR \
{ \
H5_FAILED(); \
AT(); \
H5Eprint2(H5E_DEFAULT, stdout); \
goto error; \
}
#define FAIL_PUTS_ERROR(s) \
{ \
H5_FAILED(); \
AT(); \
HDputs(s); \
goto error; \
}
/* Number of seconds to wait before killing a test (requires alarm(2)) */
#define H5_ALARM_SEC 1200 /* default is 20 minutes */
/* Flags for h5_fileaccess_flags() */
#define H5_FILEACCESS_VFD 0x01
#define H5_FILEACCESS_LIBVER 0x02
/* Macros to create and fill 2D arrays with a single heap allocation.
* These can be used to replace large stack and global arrays which raise
* warnings.
*
* The macros make a single heap allocation large enough to hold all the
* pointers and the data elements. The first part of the allocation holds
* the pointers, and the second part holds the data as a contiguous block
* in row-major order.
*
* To pass the data block to calls like H5Dread(), pass a pointer to the
* first array element as the data pointer (e.g., array[0] in a 2D array).
*
* The fill macro just fills the array with an increasing count value.
*
* Usage:
*
* int **array;
*
* H5TEST_ALLOCATE_2D_ARRAY(array, int, 5, 10);
*
* H5TEST_FILL_2D_ARRAY(array, int, 5, 10);
*
* (do stuff)
*
* HDfree(array);
*/
#define H5TEST_ALLOCATE_2D_ARRAY(ARR, TYPE, DIMS_I, DIMS_J) \
do { \
/* Prefix with h5taa to avoid shadow warnings */ \
size_t h5taa_pointers_size = 0; \
size_t h5taa_data_size = 0; \
int h5taa_i; \
\
h5taa_pointers_size = (DIMS_I) * sizeof(TYPE *); \
h5taa_data_size = (DIMS_I) * (DIMS_J) * sizeof(TYPE); \
\
ARR = (TYPE **)HDmalloc(h5taa_pointers_size + h5taa_data_size); \
\
ARR[0] = (TYPE *)(ARR + (DIMS_I)); \
\
for (h5taa_i = 1; h5taa_i < (DIMS_I); h5taa_i++) \
ARR[h5taa_i] = ARR[h5taa_i - 1] + (DIMS_J); \
} while (0)
#define H5TEST_FILL_2D_ARRAY(ARR, TYPE, DIMS_I, DIMS_J) \
do { \
/* Prefix with h5tfa to avoid shadow warnings */ \
int h5tfa_i = 0; \
int h5tfa_j = 0; \
TYPE h5tfa_count = 0; \
\
for (h5tfa_i = 0; h5tfa_i < (DIMS_I); h5tfa_i++) \
for (h5tfa_j = 0; h5tfa_j < (DIMS_J); h5tfa_j++) { \
ARR[h5tfa_i][h5tfa_j] = h5tfa_count; \
h5tfa_count++; \
} \
} while (0)
#ifdef __cplusplus
extern "C" {
#endif
/* Generally useful testing routines */
H5TEST_DLL void h5_clean_files(const char *base_name[], hid_t fapl);
H5TEST_DLL int h5_cleanup(const char *base_name[], hid_t fapl);
H5TEST_DLL char * h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size);
H5TEST_DLL char * h5_fixname_superblock(const char *base_name, hid_t fapl, char *fullname, size_t size);
H5TEST_DLL char * h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size);
H5TEST_DLL char * h5_fixname_printf(const char *base_name, hid_t fapl, char *fullname, size_t size);
H5TEST_DLL hid_t h5_fileaccess(void);
H5TEST_DLL hid_t h5_fileaccess_flags(unsigned flags);
H5TEST_DLL void h5_no_hwconv(void);
H5TEST_DLL const char *h5_rmprefix(const char *filename);
H5TEST_DLL void h5_reset(void);
H5TEST_DLL void h5_restore_err(void);
H5TEST_DLL void h5_show_hostname(void);
H5TEST_DLL h5_stat_size_t h5_get_file_size(const char *filename, hid_t fapl);
H5TEST_DLL int print_func(const char *format, ...);
H5TEST_DLL int h5_make_local_copy(const char *origfilename, const char *local_copy_name);
H5TEST_DLL herr_t h5_verify_cached_stabs(const char *base_name[], hid_t fapl);
H5TEST_DLL H5FD_class_t *h5_get_dummy_vfd_class(void);
H5TEST_DLL H5VL_class_t *h5_get_dummy_vol_class(void);
H5TEST_DLL const char * h5_get_version_string(H5F_libver_t libver);
H5TEST_DLL int h5_compare_file_bytes(char *fname1, char *fname2);
H5TEST_DLL int h5_duplicate_file_by_bytes(const char *orig, const char *dest);
H5TEST_DLL herr_t h5_check_if_file_locking_enabled(hbool_t *are_enabled);
/* Functions that will replace components of a FAPL */
H5TEST_DLL herr_t h5_get_vfd_fapl(hid_t fapl_id);
H5TEST_DLL herr_t h5_get_libver_fapl(hid_t fapl_id);
/* h5_clean_files() replacements */
H5TEST_DLL void h5_delete_test_file(const char *base_name, hid_t fapl);
H5TEST_DLL void h5_delete_all_test_files(const char *base_name[], hid_t fapl);
/* h5_reset() replacement */
H5TEST_DLL void h5_test_init(void);
/* h5_cleanup() replacement */
H5TEST_DLL void h5_test_shutdown(void);
/* Routines for operating on the list of tests (for the "all in one" tests) */
H5TEST_DLL void TestUsage(void);
H5TEST_DLL void AddTest(const char *TheName, void (*TheCall)(void), void (*Cleanup)(void),
const char *TheDescr, const void *Parameters);
H5TEST_DLL void TestInfo(const char *ProgName);
H5TEST_DLL void TestParseCmdLine(int argc, char *argv[]);
H5TEST_DLL void PerformTests(void);
H5TEST_DLL void TestSummary(void);
H5TEST_DLL void TestCleanup(void);
H5TEST_DLL void TestShutdown(void);
H5TEST_DLL void TestInit(const char *ProgName, void (*private_usage)(void),
int (*private_parser)(int ac, char *av[]));
H5TEST_DLL int GetTestVerbosity(void);
H5TEST_DLL int SetTestVerbosity(int newval);
H5TEST_DLL int GetTestSummary(void);
H5TEST_DLL int GetTestCleanup(void);
H5TEST_DLL int SetTestNoCleanup(void);
H5TEST_DLL int GetTestExpress(void);
H5TEST_DLL int SetTestExpress(int newval);
H5TEST_DLL void ParseTestVerbosity(char *argv);
H5TEST_DLL int GetTestNumErrs(void);
H5TEST_DLL void IncTestNumErrs(void);
H5TEST_DLL const void *GetTestParameters(void);
H5TEST_DLL int TestErrPrintf(const char *format, ...) H5_ATTR_FORMAT(printf, 1, 2);
H5TEST_DLL void SetTest(const char *testname, int action);
H5TEST_DLL void TestAlarmOn(void);
H5TEST_DLL void TestAlarmOff(void);
#ifdef H5_HAVE_FILTER_SZIP
H5TEST_DLL int h5_szip_can_encode(void);
#endif /* H5_HAVE_FILTER_SZIP */
#ifdef H5_HAVE_PARALLEL
H5TEST_DLL int h5_set_info_object(void);
H5TEST_DLL void h5_dump_info_object(MPI_Info info);
H5TEST_DLL char *getenv_all(MPI_Comm comm, int root, const char *name);
#endif
/* Extern global variables */
H5TEST_DLLVAR int TestVerbosity;
H5TEST_DLL void h5_send_message(const char *file, const char *arg1, const char *arg2);
H5TEST_DLL herr_t h5_wait_message(const char *file);
#ifdef __cplusplus
}
#endif
#endif