Files
hdf5/test/dtransform.c
Larry Knox e2578640fe Merge issue 839 changes to hdf5 1 10 (#841)
* Revert addition of & to 2 parameters in DSetCreatPropList::setVirtual to
maintain binary compatibility.

* Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625)

* Removes gratuitous (double)x.yF casts (#632)

* Committing clang-format changes

* Removes gratuitous (double)x.yF casts

* Committing clang-format changes

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

* Cleans up a const warning left over from previous constification (#633)

* Committing clang-format changes

* Adds consts to a few global variables

* Cleans up a const warning left over from previous constification

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

* Purges UFAIL from the library (#637)

* Committing clang-format changes

* Purges UFAIL from the library

* H5HL_insert change requested in PR

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

* Bmr dev hdffv 11223 (#640)

* Fixed HDFFV-11223 (CVE-2018-14460)

Description
    - Added checks against buffer size to prevent segfault, in case of data
      corruption, for sdim->size and sdim->max.
    - Renamed data files in an existing test to shorten their length
      as agreed with other developers previously.
Platforms tested:
    Linux/64 (jelly)

* Committing clang-format changes

* Updated for test files

* Updated for HDFFV-11223

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

* Committing clang-format changes

* Restore "error:" in line 2666.

* Revert "Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625)"

This reverts commit 426b504848.

* Snapshot version 1.10 release 8-1. Update version to 1.10.8-2.

Squashed commit of the following:

commit 60734e63fe
Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Date:   Thu Jun 24 14:20:39 2021 -0500

    Hdf5 1 10 Fix tools test (#796)

    * HDFFV-10865 - merge from dev, HDFArray perf fix.

    * Remove duplicate setting

    * Whitespace changes after clang format

    * Undo version 11 clang format changes

    * Merge CMake changes from develop

    * test testing script merge from develop

    * Update supported platforms

    * PR#3 merge from develop

    * Merge gcc 10 diagnostics option from develop

    * Merge #318 OSX changes from develop

    * Merge small changes from develop

    * Minor non-space formatting changes

    * #386 copyright corrections for java folder

    * Merges from develop

    #358 patches from vtk
    #361 fix header guard spelling

    * Merge updates

    #358 patches from vtk
    #361 fix header guard spelling

    * format fix

    * Fix missing underscore and make H5public.h closer to dev

    * Merges from develop

    #340 clang -Wformat-security warnings
    #360 Fixed uninitialized warnings
    header guard underscore cleanup
    JNI cleanup

    * format alignment

    * Add missing test ref file

    * Merge #380 from develop

    * Finish java merges from develop

    * Fix java issues with tests and javadoc

    * Correct use of attribute access plist

    * Remove debug code

    * Remove unused variable

    * Change file access to read only for java tests

    * Split clang format operations.

    * More javadoc comments

    * Remove pre-split setting

    * format source

    * Change windows TS to use older VS.

    * Mostly all javadoc fixes, one argument rename.

    * synch file

    * Merge of long double fix and compiler flags

    * HDFFV-11229 merge changes from develop

    * HDFFV-11229 correct test script

    * HDFFV-11229 update autotools test script for two ref files

    * HDFFV-11229 merge dev changes for long double display in tools

    * Committing clang-format changes

    * minor whitespace

    * remove unneeded macro

    * Committing clang-format changes

    * Add "option" command for clang options

    * Rework CMake add_custom to use the BYPRODUCTS argument

    Update pkgconfig scripts for parallel builds.
    Fix install COPYING file reference.
    Remove unused round defines.
    Change CMake default setting of BUILD_CPP to off.

    * Fortran target depends

    * Remove incorrect source attribute

    * Revert define removal

    * printf specifiers and VS2015 min changes

    * Committing clang-format changes

    * Add time struct

    * TRILAB-227 and tools debug merges from develop

    * Merge various changes from dev

    * Issue #669 remove version from pkgcfg filename

    * remove version from h5cc script

    * doxygen changes merged from develop

    * Committing clang-format changes

    * Merge CMake fortran ninja changes from dev

    * Enable fortran to gcc yaml

    * Refactor Fortran CMake config tests and CMake test args

    * Merge warnings files fixes from develop

    * Fix cmake configure path

    * Update missing release note info.

    * Update code owners

    * Add known problem

    * Use only core library for testing dynamic plugins.

    CMake uses H5_HAVE_DIRECT instead of DIRECT_VFD

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

commit bfb780a444
Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Date:   Wed Jun 23 14:11:46 2021 -0500

    Hdf5 1 10 Release Note (#786)

    * HDFFV-10865 - merge from dev, HDFArray perf fix.

    * Remove duplicate setting

    * Whitespace changes after clang format

    * Undo version 11 clang format changes

    * Merge CMake changes from develop

    * test testing script merge from develop

    * Update supported platforms

    * PR#3 merge from develop

    * Merge gcc 10 diagnostics option from develop

    * Merge #318 OSX changes from develop

    * Merge small changes from develop

    * Minor non-space formatting changes

    * #386 copyright corrections for java folder

    * Merges from develop

    #358 patches from vtk
    #361 fix header guard spelling

    * Merge updates

    #358 patches from vtk
    #361 fix header guard spelling

    * format fix

    * Fix missing underscore and make H5public.h closer to dev

    * Merges from develop

    #340 clang -Wformat-security warnings
    #360 Fixed uninitialized warnings
    header guard underscore cleanup
    JNI cleanup

    * format alignment

    * Add missing test ref file

    * Merge #380 from develop

    * Finish java merges from develop

    * Fix java issues with tests and javadoc

    * Correct use of attribute access plist

    * Remove debug code

    * Remove unused variable

    * Change file access to read only for java tests

    * Split clang format operations.

    * More javadoc comments

    * Remove pre-split setting

    * format source

    * Change windows TS to use older VS.

    * Mostly all javadoc fixes, one argument rename.

    * synch file

    * Merge of long double fix and compiler flags

    * HDFFV-11229 merge changes from develop

    * HDFFV-11229 correct test script

    * HDFFV-11229 update autotools test script for two ref files

    * HDFFV-11229 merge dev changes for long double display in tools

    * Committing clang-format changes

    * minor whitespace

    * remove unneeded macro

    * Committing clang-format changes

    * Add "option" command for clang options

    * Rework CMake add_custom to use the BYPRODUCTS argument

    Update pkgconfig scripts for parallel builds.
    Fix install COPYING file reference.
    Remove unused round defines.
    Change CMake default setting of BUILD_CPP to off.

    * Fortran target depends

    * Remove incorrect source attribute

    * Revert define removal

    * printf specifiers and VS2015 min changes

    * Committing clang-format changes

    * Add time struct

    * TRILAB-227 and tools debug merges from develop

    * Merge various changes from dev

    * Issue #669 remove version from pkgcfg filename

    * remove version from h5cc script

    * doxygen changes merged from develop

    * Committing clang-format changes

    * Merge CMake fortran ninja changes from dev

    * Enable fortran to gcc yaml

    * Refactor Fortran CMake config tests and CMake test args

    * Merge warnings files fixes from develop

    * Fix cmake configure path

    * Update missing release note info.

    * Update code owners

    * Add known problem

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

commit 9f50407368
Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Date:   Tue Jun 22 07:03:26 2021 -0500

    Hdf5 1 10 Update missing release note info. (#778)

    * HDFFV-10865 - merge from dev, HDFArray perf fix.

    * Remove duplicate setting

    * Whitespace changes after clang format

    * Undo version 11 clang format changes

    * Merge CMake changes from develop

    * test testing script merge from develop

    * Update supported platforms

    * PR#3 merge from develop

    * Merge gcc 10 diagnostics option from develop

    * Merge #318 OSX changes from develop

    * Merge small changes from develop

    * Minor non-space formatting changes

    * #386 copyright corrections for java folder

    * Merges from develop

    #358 patches from vtk
    #361 fix header guard spelling

    * Merge updates

    #358 patches from vtk
    #361 fix header guard spelling

    * format fix

    * Fix missing underscore and make H5public.h closer to dev

    * Merges from develop

    #340 clang -Wformat-security warnings
    #360 Fixed uninitialized warnings
    header guard underscore cleanup
    JNI cleanup

    * format alignment

    * Add missing test ref file

    * Merge #380 from develop

    * Finish java merges from develop

    * Fix java issues with tests and javadoc

    * Correct use of attribute access plist

    * Remove debug code

    * Remove unused variable

    * Change file access to read only for java tests

    * Split clang format operations.

    * More javadoc comments

    * Remove pre-split setting

    * format source

    * Change windows TS to use older VS.

    * Mostly all javadoc fixes, one argument rename.

    * synch file

    * Merge of long double fix and compiler flags

    * HDFFV-11229 merge changes from develop

    * HDFFV-11229 correct test script

    * HDFFV-11229 update autotools test script for two ref files

    * HDFFV-11229 merge dev changes for long double display in tools

    * Committing clang-format changes

    * minor whitespace

    * remove unneeded macro

    * Committing clang-format changes

    * Add "option" command for clang options

    * Rework CMake add_custom to use the BYPRODUCTS argument

    Update pkgconfig scripts for parallel builds.
    Fix install COPYING file reference.
    Remove unused round defines.
    Change CMake default setting of BUILD_CPP to off.

    * Fortran target depends

    * Remove incorrect source attribute

    * Revert define removal

    * printf specifiers and VS2015 min changes

    * Committing clang-format changes

    * Add time struct

    * TRILAB-227 and tools debug merges from develop

    * Merge various changes from dev

    * Issue #669 remove version from pkgcfg filename

    * remove version from h5cc script

    * doxygen changes merged from develop

    * Committing clang-format changes

    * Merge CMake fortran ninja changes from dev

    * Enable fortran to gcc yaml

    * Refactor Fortran CMake config tests and CMake test args

    * Merge warnings files fixes from develop

    * Fix cmake configure path

    * Update missing release note info.

    * Update code owners

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

commit 2e80c9cdec
Author: Dana Robinson <43805+derobins@users.noreply.github.com>
Date:   Fri Jun 18 06:42:23 2021 -0700

    Brings hash table IDs feature from develop/1.12 (#768)

    * Brings updated tid test from develop

    * Adds empty H5Iint.c and H5Idbg.c files

    * H5I renaming to match 1.12/develop

    * Splits off H5I debug code to H5Idbg.c

    * Splits internal H5I.c functionality to H5Iint.c

    * Header cleanup

    * More renaming cleanup to match develop/1.12

    * Adds "save last ID" optimization

    * Adds uthash.h

    * Adds hash table IDs from develop/1.12

    * Committing clang-format changes

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

commit 1e29bcbfe2
Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Date:   Thu Jun 17 11:21:43 2021 -0500

    Hdf5 1 10 Fix cmake configure path (#762)

    * HDFFV-10865 - merge from dev, HDFArray perf fix.

    * Remove duplicate setting

    * Whitespace changes after clang format

    * Undo version 11 clang format changes

    * Merge CMake changes from develop

    * test testing script merge from develop

    * Update supported platforms

    * PR#3 merge from develop

    * Merge gcc 10 diagnostics option from develop

    * Merge #318 OSX changes from develop

    * Merge small changes from develop

    * Minor non-space formatting changes

    * #386 copyright corrections for java folder

    * Merges from develop

    #358 patches from vtk
    #361 fix header guard spelling

    * Merge updates

    #358 patches from vtk
    #361 fix header guard spelling

    * format fix

    * Fix missing underscore and make H5public.h closer to dev

    * Merges from develop

    #340 clang -Wformat-security warnings
    #360 Fixed uninitialized warnings
    header guard underscore cleanup
    JNI cleanup

    * format alignment

    * Add missing test ref file

    * Merge #380 from develop

    * Finish java merges from develop

    * Fix java issues with tests and javadoc

    * Correct use of attribute access plist

    * Remove debug code

    * Remove unused variable

    * Change file access to read only for java tests

    * Split clang format operations.

    * More javadoc comments

    * Remove pre-split setting

    * format source

    * Change windows TS to use older VS.

    * Mostly all javadoc fixes, one argument rename.

    * synch file

    * Merge of long double fix and compiler flags

    * HDFFV-11229 merge changes from develop

    * HDFFV-11229 correct test script

    * HDFFV-11229 update autotools test script for two ref files

    * HDFFV-11229 merge dev changes for long double display in tools

    * Committing clang-format changes

    * minor whitespace

    * remove unneeded macro

    * Committing clang-format changes

    * Add "option" command for clang options

    * Rework CMake add_custom to use the BYPRODUCTS argument

    Update pkgconfig scripts for parallel builds.
    Fix install COPYING file reference.
    Remove unused round defines.
    Change CMake default setting of BUILD_CPP to off.

    * Fortran target depends

    * Remove incorrect source attribute

    * Revert define removal

    * printf specifiers and VS2015 min changes

    * Committing clang-format changes

    * Add time struct

    * TRILAB-227 and tools debug merges from develop

    * Merge various changes from dev

    * Issue #669 remove version from pkgcfg filename

    * remove version from h5cc script

    * doxygen changes merged from develop

    * Committing clang-format changes

    * Merge CMake fortran ninja changes from dev

    * Enable fortran to gcc yaml

    * Refactor Fortran CMake config tests and CMake test args

    * Merge warnings files fixes from develop

    * Fix cmake configure path

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

commit 475cdaf431
Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Date:   Wed Jun 16 15:45:58 2021 -0500

    Hdf5 1 10 merge warnings changes (#756)

    * HDFFV-10865 - merge from dev, HDFArray perf fix.

    * Remove duplicate setting

    * Whitespace changes after clang format

    * Undo version 11 clang format changes

    * Merge CMake changes from develop

    * test testing script merge from develop

    * Update supported platforms

    * PR#3 merge from develop

    * Merge gcc 10 diagnostics option from develop

    * Merge #318 OSX changes from develop

    * Merge small changes from develop

    * Minor non-space formatting changes

    * #386 copyright corrections for java folder

    * Merges from develop

    #358 patches from vtk
    #361 fix header guard spelling

    * Merge updates

    #358 patches from vtk
    #361 fix header guard spelling

    * format fix

    * Fix missing underscore and make H5public.h closer to dev

    * Merges from develop

    #340 clang -Wformat-security warnings
    #360 Fixed uninitialized warnings
    header guard underscore cleanup
    JNI cleanup

    * format alignment

    * Add missing test ref file

    * Merge #380 from develop

    * Finish java merges from develop

    * Fix java issues with tests and javadoc

    * Correct use of attribute access plist

    * Remove debug code

    * Remove unused variable

    * Change file access to read only for java tests

    * Split clang format operations.

    * More javadoc comments

    * Remove pre-split setting

    * format source

    * Change windows TS to use older VS.

    * Mostly all javadoc fixes, one argument rename.

    * synch file

    * Merge of long double fix and compiler flags

    * HDFFV-11229 merge changes from develop

    * HDFFV-11229 correct test script

    * HDFFV-11229 update autotools test script for two ref files

    * HDFFV-11229 merge dev changes for long double display in tools

    * Committing clang-format changes

    * minor whitespace

    * remove unneeded macro

    * Committing clang-format changes

    * Add "option" command for clang options

    * Rework CMake add_custom to use the BYPRODUCTS argument

    Update pkgconfig scripts for parallel builds.
    Fix install COPYING file reference.
    Remove unused round defines.
    Change CMake default setting of BUILD_CPP to off.

    * Fortran target depends

    * Remove incorrect source attribute

    * Revert define removal

    * printf specifiers and VS2015 min changes

    * Committing clang-format changes

    * Add time struct

    * TRILAB-227 and tools debug merges from develop

    * Merge various changes from dev

    * Issue #669 remove version from pkgcfg filename

    * remove version from h5cc script

    * doxygen changes merged from develop

    * Committing clang-format changes

    * Merge CMake fortran ninja changes from dev

    * Enable fortran to gcc yaml

    * Refactor Fortran CMake config tests and CMake test args

    * Merge warnings files fixes from develop

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

commit e25980e7f3
Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Date:   Tue Jun 8 14:37:13 2021 -0500

    Hdf5 1 10 merges of CMake changes (#738)

    * HDFFV-10865 - merge from dev, HDFArray perf fix.

    * Remove duplicate setting

    * Whitespace changes after clang format

    * Undo version 11 clang format changes

    * Merge CMake changes from develop

    * test testing script merge from develop

    * Update supported platforms

    * PR#3 merge from develop

    * Merge gcc 10 diagnostics option from develop

    * Merge #318 OSX changes from develop

    * Merge small changes from develop

    * Minor non-space formatting changes

    * #386 copyright corrections for java folder

    * Merges from develop

    #358 patches from vtk
    #361 fix header guard spelling

    * Merge updates

    #358 patches from vtk
    #361 fix header guard spelling

    * format fix

    * Fix missing underscore and make H5public.h closer to dev

    * Merges from develop

    #340 clang -Wformat-security warnings
    #360 Fixed uninitialized warnings
    header guard underscore cleanup
    JNI cleanup

    * format alignment

    * Add missing test ref file

    * Merge #380 from develop

    * Finish java merges from develop

    * Fix java issues with tests and javadoc

    * Correct use of attribute access plist

    * Remove debug code

    * Remove unused variable

    * Change file access to read only for java tests

    * Split clang format operations.

    * More javadoc comments

    * Remove pre-split setting

    * format source

    * Change windows TS to use older VS.

    * Mostly all javadoc fixes, one argument rename.

    * synch file

    * Merge of long double fix and compiler flags

    * HDFFV-11229 merge changes from develop

    * HDFFV-11229 correct test script

    * HDFFV-11229 update autotools test script for two ref files

    * HDFFV-11229 merge dev changes for long double display in tools

    * Committing clang-format changes

    * minor whitespace

    * remove unneeded macro

    * Committing clang-format changes

    * Add "option" command for clang options

    * Rework CMake add_custom to use the BYPRODUCTS argument

    Update pkgconfig scripts for parallel builds.
    Fix install COPYING file reference.
    Remove unused round defines.
    Change CMake default setting of BUILD_CPP to off.

    * Fortran target depends

    * Remove incorrect source attribute

    * Revert define removal

    * printf specifiers and VS2015 min changes

    * Committing clang-format changes

    * Add time struct

    * TRILAB-227 and tools debug merges from develop

    * Merge various changes from dev

    * Issue #669 remove version from pkgcfg filename

    * remove version from h5cc script

    * doxygen changes merged from develop

    * Committing clang-format changes

    * Merge CMake fortran ninja changes from dev

    * Enable fortran to gcc yaml

    * Refactor Fortran CMake config tests and CMake test args

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

commit 061b23ac00
Author: Larry Knox <lrknox@hdfgroup.org>
Date:   Thu Jun 3 16:07:23 2021 -0500

    Partial merge issue #642 develop branch PRs to Hdf5 1 10 (#718)

    * Revert addition of & to 2 parameters in DSetCreatPropList::setVirtual to
    maintain binary compatibility.

    * Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625)

    * Removes gratuitous (double)x.yF casts (#632)

    * Committing clang-format changes

    * Removes gratuitous (double)x.yF casts

    * Committing clang-format changes

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

    * Cleans up a const warning left over from previous constification (#633)

    * Committing clang-format changes

    * Adds consts to a few global variables

    * Cleans up a const warning left over from previous constification

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

    * Purges UFAIL from the library (#637)

    * Committing clang-format changes

    * Purges UFAIL from the library

    * H5HL_insert change requested in PR

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

    * Bmr dev hdffv 11223 (#640)

    * Fixed HDFFV-11223 (CVE-2018-14460)

    Description
        - Added checks against buffer size to prevent segfault, in case of data
          corruption, for sdim->size and sdim->max.
        - Renamed data files in an existing test to shorten their length
          as agreed with other developers previously.
    Platforms tested:
        Linux/64 (jelly)

    * Committing clang-format changes

    * Updated for test files

    * Updated for HDFFV-11223

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

    * Committing clang-format changes

    * Restore "error:" in line 2666.

    * Revert "Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625)"

    This reverts commit 426b504848.

    Co-authored-by: jhendersonHDF <jhenderson@hdfgroup.org>
    Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
    Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
    Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>

* (fix) Segmentation fault when using a compound type. (#143)

* (fix) Segmentation fault when using a compound type.

In the case when a compounded attribute is written to dataset
followed by writing the data with a data transform function
to the dataset will result in a segmentation fault. It turns out
the data is classified as compounded while it is not. Now, the
state is always reset first to not compounded followed by the
existing check if the variable is compounded.

* (fix) Removed undesired comment lines.

* (fix) Segmentation fault when using a compound type: added test.

* (fix) Added the missing cmpd_transform.c file to MANIFEST.

* (fix) cmpd_dtransform test: autotools and source header.

Added the cmp_dtransform test to the autotools configuration and
updated the HDF Group copyright header.

Co-authored-by: Jan-Willem Blokland <Jan-Willem.Blokland@Shell.com>

* (fix) H5Z_xform_create function and scientific notation (#144)

* (fix) H5Z_xform_create function and scientific notation

Implemented a more sophisticated check to support scientific notation
in the expression of the H5Zset_data_transform function.

* (fix) H5Z_xform_create and scientific notation: Added test.

Added a test to demonstrate that the parsing of expression
which includes scientific notation works correctly. Improved
inline comment.

Co-authored-by: Jan-Willem Blokland <Jan-Willem.Blokland@Shell.com>

* Adds const to a few global variables (#623)

* Committing clang-format changes

* Adds consts to a few global variables

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

* Made private my_yyinput function static (#618)

This prevents it being exported as a public symbol.

* Reduces overly-pedantic casting in the public headers (#644)

* Committing clang-format changes

* Fixes overly pedantic casting in public headers

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

* Use internal version of H5Eprint2 to avoid possible stack overflow (#661)

* Fixes for a couple of trivial warnings (#676)

* Committing clang-format changes

* Trivial warning fixes:

* Removes an unused done target in H5Tbit.c
* Add (void) to quiet "ignored return value" warnings in the generators
  (which generally ignore errors)

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

* Removes alternative function enter/leave macro scheme (#678)

* Committing clang-format changes

* Converted BEGIN_FUNC, etc. macros to FUNC_ENTER

* Rips out the BEGIN_FUNC, etc. macros

* Removes 'end if', etc. comments from H5HL package

* Committing clang-format changes

* Fixes an H5EA iterate issue

* Fixes an issue in the H5FA iterator code

* Further cleanup in bin/trace after macro removal

* Iterator changes in H5EA and H5FA

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

* Various CMake changes (#679)

* Committing clang-format changes

* Several CMake updates:

* Removes unused HDF5_ENABLE_HSIZET
* Switches TEST_SHELL_SCRIPTS to ON
* Sets SH_PROGRAM to bash instead of sh

* Set default build type back to RelWithDebInfo

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

* Revert "Removes alternative function enter/leave macro scheme (#678)"

This reverts commit edddb11b79.

* err_compat test cleanup (#681)

* Committing clang-format changes

* Cleans up err_compat test and output

* Formatted source

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

* Sets the memory alloc sanity check option to disabled in autotools (#686)

* Revert "Sets the memory alloc sanity check option to disabled in autotools (#686)"

This reverts commit 652ffca586.

(Only for release branch).

* Removes alternative function enter/leave macro scheme (#678)

* Committing clang-format changes

* Converted BEGIN_FUNC, etc. macros to FUNC_ENTER

* Rips out the BEGIN_FUNC, etc. macros

* Removes 'end if', etc. comments from H5HL package

* Committing clang-format changes

* Fixes an H5EA iterate issue

* Fixes an issue in the H5FA iterator code

* Further cleanup in bin/trace after macro removal

* Iterator changes in H5EA and H5FA

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

* Committing clang-format changes

Co-authored-by: jhendersonHDF <jhenderson@hdfgroup.org>
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
Co-authored-by: Jan-Willem Blokland <J.W.S.Blokland@XS4All.nl>
Co-authored-by: Jan-Willem Blokland <Jan-Willem.Blokland@Shell.com>
Co-authored-by: Sean McBride <sean@rogue-research.com>
2021-07-16 10:57:51 -05:00

949 lines
49 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5test.h"
#define ROWS 12
#define COLS 18
#define FLOAT_TOL 0.0001F
static int init_test(hid_t file_id);
static int test_copy(hid_t dxpl_id_c_to_f_copy, hid_t dxpl_id_polynomial_copy);
static int test_trivial(hid_t dxpl_id_simple);
static int test_poly(hid_t dxpl_id_polynomial);
static int test_specials(hid_t file);
static int test_set(void);
static int test_getset(hid_t dxpl_id_simple);
/* These are needed for multiple tests, so are declared here globally and are init'ed in init_test */
hid_t dset_id_int = -1;
hid_t dset_id_float = -1;
hid_t dset_id_int_chunk = -1;
hid_t dset_id_float_chunk = -1;
const float windchillFfloat[ROWS][COLS] = {
{36.0f, 31.0f, 25.0f, 19.0f, 13.0f, 7.0f, 1.0f, -5.0f, -11.0f, -16.0f, -22.0f, -28.0f, -34.0f, -40.0f,
-46.0f, -52.0f, -57.0f, -63.0f},
{34.0f, 27.0f, 21.0f, 15.0f, 9.0f, 3.0f, -4.0f, -10.0f, -16.0f, -22.0f, -28.0f, -35.0f, -41.0f, -47.0f,
-53.0f, -59.0f, -66.0f, -72.0f},
{32.0f, 25.0f, 19.0f, 13.0f, 6.0f, 0.0f, -7.0f, -13.0f, -19.0f, -26.0f, -32.0f, -39.0f, -45.0f, -51.0f,
-58.0f, -64.0f, -71.0f, -77.0f},
{30.0f, 24.0f, 17.0f, 11.0f, 4.0f, -2.0f, -9.0f, -15.0f, -22.0f, -29.0f, -35.0f, -42.0f, -48.0f, -55.0f,
-61.0f, -68.0f, -74.0f, -81.0f},
{29.0f, 23.0f, 16.0f, 9.0f, 3.0f, -4.0f, -11.0f, -17.0f, -24.0f, -31.0f, -37.0f, -44.0f, -51.0f, -58.0f,
-64.0f, -71.0f, -78.0f, -84.0f},
{28.0f, 22.0f, 15.0f, 8.0f, 1.0f, -5.0f, -12.0f, -19.0f, -26.0f, -33.0f, -39.0f, -46.0f, -53.0f, -60.0f,
-67.0f, -73.0f, -80.0f, -87.0f},
{28.0f, 21.0f, 14.0f, 7.0f, 0.0f, -7.0f, -14.0f, -21.0f, -27.0f, -34.0f, -41.0f, -48.0f, -55.0f, -62.0f,
-69.0f, -76.0f, -82.0f, -89.0f},
{27.0f, 20.0f, 13.0f, 6.0f, -1.0f, -8.0f, -15.0f, -22.0f, -29.0f, -36.0f, -43.0f, -50.0f, -57.0f, -64.0f,
-71.0f, -78.0f, -84.0f, -91.0f},
{26.0f, 19.0f, 12.0f, 5.0f, -2.0f, -9.0f, -16.0f, -23.0f, -30.0f, -37.0f, -44.0f, -51.0f, -58.0f, -65.0f,
-72.0f, -79.0f, -86.0f, -93.0f},
{26.0f, 19.0f, 12.0f, 4.0f, -3.0f, -10.0f, -17.0f, -24.0f, -31.0f, -38.0f, -45.0f, -52.0f, -60.0f, -67.0f,
-74.0f, -81.0f, -88.0f, -95.0f},
{25.0f, 18.0f, 11.0f, 4.0f, -3.0f, -11.0f, -18.0f, -25.0f, -32.0f, -39.0f, -46.0f, -54.0f, -61.0f, -68.0f,
-75.0f, -82.0f, -89.0f, -97.0f},
{25.0f, 17.0f, 10.0f, 3.0f, -4.0f, -11.0f, -19.0f, -26.0f, -33.0f, -40.0f, -48.0f, -55.0f, -62.0f, -69.0f,
-76.0f, -84.0f, -91.0f, -98.0f}};
const int transformData[ROWS][COLS] = {{36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, 28, 34, 40, 46, 52, 57, 63},
{34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 1},
{32, 25, 19, 13, 6, 2, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 5},
{30, 24, 17, 11, 4, 2, 9, 15, 22, 29, 35, 42, 48, 55, 61, 68, 2, 9},
{29, 23, 16, 9, 3, 4, 11, 17, 24, 31, 37, 44, 51, 58, 64, 71, 6, 12},
{28, 22, 15, 8, 1, 5, 12, 19, 26, 33, 39, 46, 53, 60, 67, 1, 8, 15},
{28, 21, 14, 7, 6, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 4, 10, 17},
{27, 20, 13, 6, 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 6, 12, 19},
{26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 5, 7, 14, 21},
{26, 19, 12, 4, 3, 10, 17, 24, 31, 38, 45, 52, 60, 67, 2, 9, 16, 23},
{25, 18, 11, 4, 3, 11, 18, 25, 32, 39, 46, 54, 61, 68, 3, 10, 17, 25},
{25, 17, 10, 3, 4, 11, 19, 26, 33, 40, 48, 55, 62, 69, 4, 12, 19, 26}};
#define UCOMPARE(TYPE, VAR1, VAR2, TOL) \
{ \
size_t i, j; \
\
for (i = 0; i < ROWS; i++) \
for (j = 0; j < COLS; j++) { \
if (!((((VAR1)[i][j] >= (TYPE)((VAR2)[i][j])) && \
(((VAR1)[i][j] - TOL) < (TYPE)((VAR2)[i][j]))) || \
(((VAR1)[i][j] <= (TYPE)((VAR2)[i][j])) && \
(((VAR1)[i][j] + TOL) > (TYPE)((VAR2)[i][j]))))) { \
H5_FAILED(); \
HDfprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \
goto error; \
} \
} \
PASSED(); \
}
#define COMPARE(TYPE, VAR1, VAR2, TOL) \
{ \
size_t i, j; \
\
for (i = 0; i < ROWS; i++) \
for (j = 0; j < COLS; j++) { \
if (!(((VAR1)[i][j] <= ((TYPE)(VAR2)[i][j] + TOL)) && \
((VAR1)[i][j] >= ((TYPE)(VAR2)[i][j] - TOL)))) { \
H5_FAILED(); \
HDfprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \
goto error; \
} \
} \
PASSED(); \
}
#define COMPARE_INT(VAR1, VAR2) \
{ \
size_t i, j; \
\
for (i = 0; i < ROWS; i++) \
for (j = 0; j < COLS; j++) { \
if ((VAR1)[i][j] != (VAR2)[i][j]) { \
H5_FAILED(); \
HDfprintf(stderr, " ERROR: data failed to match computed data\n"); \
goto error; \
} \
} \
}
#define TEST_TYPE_CONTIG(XFORM, TYPE, HDF_TYPE, TEST_STR, COMPARE_DATA, SIGNED) \
{ \
TYPE array[ROWS][COLS]; \
const char *f_to_c = "(5/9.0)*(x-32)"; \
/* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to \
* fit into uchar */ \
const char *utrans = "((x+100)/4)*3"; \
\
hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, dset, dset_nn, dt_nn; \
H5T_order_t order; \
hsize_t dim[2] = {ROWS, COLS}; \
\
if ((dataspace = H5Screate_simple(2, dim, NULL)) < 0) \
TEST_ERROR; \
if ((dset = H5Dcreate2(file_id, "/transformtest_" TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, \
H5P_DEFAULT, H5P_DEFAULT)) < 0) \
TEST_ERROR; \
\
if ((dt_nn = H5Tcopy(HDF_TYPE)) < 0) \
TEST_ERROR \
if ((order = H5Tget_order(dt_nn)) == H5T_ORDER_ERROR) \
TEST_ERROR \
if (H5Tset_order(dt_nn, order == H5T_ORDER_LE ? H5T_ORDER_BE : H5T_ORDER_LE) < 0) \
TEST_ERROR \
if ((dset_nn = H5Dcreate2(file_id, "/nonnative_transformtest_" TEST_STR, dt_nn, dataspace, \
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) \
TEST_ERROR \
if (H5Tclose(dt_nn) < 0) \
TEST_ERROR \
\
if (SIGNED) { \
if ((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) \
TEST_ERROR; \
if (H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) \
TEST_ERROR; \
if (H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) \
TEST_ERROR; \
if (H5Dwrite(dset_nn, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) \
TEST_ERROR; \
if (H5Pclose(dxpl_id_f_to_c) < 0) \
TEST_ERROR; \
} \
else { \
if ((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) \
TEST_ERROR; \
if (H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) \
TEST_ERROR; \
if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData) < 0) \
TEST_ERROR; \
if (H5Dwrite(dset_nn, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData) < 0) \
TEST_ERROR; \
if (H5Pclose(dxpl_id_utrans) < 0) \
TEST_ERROR; \
} \
\
TESTING("contiguous, no data type conversion (" TEST_STR "->" TEST_STR ")") \
\
if (H5Dread(dset, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) \
TEST_ERROR; \
if (SIGNED) \
COMPARE(TYPE, array, COMPARE_DATA, 2) \
else \
UCOMPARE(TYPE, array, COMPARE_DATA, 4) \
\
TESTING("contiguous, byte order conversion (" TEST_STR "->" TEST_STR ")") \
\
if (H5Dread(dset_nn, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) \
TEST_ERROR; \
if (SIGNED) \
COMPARE(TYPE, array, COMPARE_DATA, 2) \
else \
UCOMPARE(TYPE, array, COMPARE_DATA, 4) \
\
if (SIGNED) { \
TESTING("contiguous, with type conversion (float->" TEST_STR ")") \
\
if (H5Dread(dset_id_float, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) \
TEST_ERROR; \
COMPARE(TYPE, array, COMPARE_DATA, 2) \
} \
\
if (H5Dclose(dset) < 0) \
TEST_ERROR; \
if (H5Sclose(dataspace) < 0) \
TEST_ERROR; \
}
#define TEST_TYPE_CHUNK(XFORM, TYPE, HDF_TYPE, TEST_STR, COMPARE_DATA, SIGNED) \
{ \
TYPE array[ROWS][COLS]; \
const char *f_to_c = "(5/9.0)*(x-32)"; \
/* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to \
* fit into uchar */ \
const char *utrans = "((x+100)/4)*3"; \
\
hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, memspace, dset_chunk, filespace; \
hsize_t dim[2] = {ROWS, COLS}; \
hsize_t offset[2] = {0, 0}; \
\
if ((dataspace = H5Screate_simple(2, dim, NULL)) < 0) \
TEST_ERROR; \
\
if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) \
TEST_ERROR; \
if (H5Pset_chunk(cparms, 2, dim) < 0) \
TEST_ERROR; \
\
if ((dset_chunk = H5Dcreate2(file_id, "/transformtest_chunk_" TEST_STR, HDF_TYPE, dataspace, \
H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) \
TEST_ERROR; \
if ((filespace = H5Dget_space(dset_chunk)) < 0) \
TEST_ERROR \
if ((memspace = H5Screate_simple(2, dim, NULL)) < 0) \
TEST_ERROR \
if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0) \
TEST_ERROR; \
\
if (SIGNED) { \
if ((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) \
TEST_ERROR; \
if (H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) \
TEST_ERROR; \
if (H5Dwrite(dset_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, \
windchillFfloat) < 0) \
TEST_ERROR; \
if (H5Pclose(dxpl_id_f_to_c) < 0) \
TEST_ERROR; \
} \
else { \
if ((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) \
TEST_ERROR; \
if (H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) \
TEST_ERROR; \
if (H5Dwrite(dset_chunk, H5T_NATIVE_INT, dataspace, filespace, dxpl_id_utrans, transformData) < \
0) \
TEST_ERROR; \
if (H5Pclose(dxpl_id_utrans) < 0) \
TEST_ERROR; \
} \
\
TESTING("chunked, no data type conversion (" TEST_STR "->" TEST_STR ")") \
\
if (H5Dread(dset_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) \
TEST_ERROR; \
if (SIGNED) \
COMPARE(TYPE, array, COMPARE_DATA, 2) \
else \
UCOMPARE(TYPE, array, COMPARE_DATA, 4) \
\
if (SIGNED) { \
TESTING("chunked, with type conversion (float->" TEST_STR ")") \
\
if (H5Dread(dset_id_float_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) \
TEST_ERROR; \
COMPARE(TYPE, array, COMPARE_DATA, 2) \
} \
\
if (H5Pclose(cparms) < 0) \
TEST_ERROR; \
if (H5Dclose(dset_chunk) < 0) \
TEST_ERROR; \
if (H5Sclose(dataspace) < 0) \
TEST_ERROR; \
if (H5Sclose(memspace) < 0) \
TEST_ERROR; \
}
#define INVALID_SET_TEST(TRANSFORM) \
{ \
if (H5Pset_data_transform(dxpl_id, TRANSFORM) < 0) { \
PASSED(); \
} \
else { \
H5_FAILED(); \
HDfprintf(stderr, " ERROR: Data transform allowed invalid TRANSFORM transform to be set\n"); \
goto error; \
} \
}
int
main(void)
{
hid_t dxpl_id_c_to_f = -1;
hid_t dxpl_id_c_to_f_copy = 1;
hid_t dxpl_id_simple = -1;
hid_t dxpl_id_polynomial = -1;
hid_t dxpl_id_polynomial_copy = -1;
hid_t dxpl_id_utrans_inv = -1;
hid_t file_id = -1;
const char *c_to_f = "(9/5.0)*x + 32";
const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
const char *polynomial = "(2+x)* ((x-8)/2)";
/* inverses the utrans transform in init_test to get back original array */
const char *utrans_inv = "(x/3)*4 - 100";
if ((file_id = H5Fcreate("dtransform.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
if ((dxpl_id_c_to_f = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
if ((dxpl_id_simple = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
if ((dxpl_id_utrans_inv = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
if ((dxpl_id_polynomial = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
if (H5Pset_data_transform(dxpl_id_c_to_f, c_to_f) < 0)
TEST_ERROR;
if (H5Pset_data_transform(dxpl_id_polynomial, polynomial) < 0)
TEST_ERROR;
if (H5Pset_data_transform(dxpl_id_simple, simple) < 0)
TEST_ERROR;
if (H5Pset_data_transform(dxpl_id_utrans_inv, utrans_inv) < 0)
TEST_ERROR;
if ((dxpl_id_polynomial_copy = H5Pcopy(dxpl_id_polynomial)) < 0)
TEST_ERROR;
if ((dxpl_id_c_to_f_copy = H5Pcopy(dxpl_id_c_to_f)) < 0)
TEST_ERROR;
/* Run all the tests */
if (init_test(file_id) < 0)
TEST_ERROR;
if (test_set() < 0)
TEST_ERROR;
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, char, H5T_NATIVE_CHAR, "char", transformData, 0);
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned char, H5T_NATIVE_UCHAR, "uchar", transformData, 0);
TEST_TYPE_CONTIG(dxpl_id_c_to_f, signed char, H5T_NATIVE_SCHAR, "schar", windchillFfloat, 1);
TEST_TYPE_CONTIG(dxpl_id_c_to_f, short, H5T_NATIVE_SHORT, "short", windchillFfloat, 1);
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned short, H5T_NATIVE_USHORT, "ushort", transformData, 0);
TEST_TYPE_CONTIG(dxpl_id_c_to_f, int, H5T_NATIVE_INT, "int", windchillFfloat, 1);
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned int, H5T_NATIVE_UINT, "uint", transformData, 0);
TEST_TYPE_CONTIG(dxpl_id_c_to_f, long, H5T_NATIVE_LONG, "long", windchillFfloat, 1);
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned long, H5T_NATIVE_ULONG, "ulong", transformData, 0);
TEST_TYPE_CONTIG(dxpl_id_c_to_f, long long, H5T_NATIVE_LLONG, "llong", windchillFfloat, 1);
TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned long long, H5T_NATIVE_ULLONG, "ullong", transformData, 0);
TEST_TYPE_CONTIG(dxpl_id_c_to_f, float, H5T_NATIVE_FLOAT, "float", windchillFfloat, 1);
TEST_TYPE_CONTIG(dxpl_id_c_to_f, double, H5T_NATIVE_DOUBLE, "double", windchillFfloat, 1);
#if H5_SIZEOF_LONG_DOUBLE != 0
TEST_TYPE_CONTIG(dxpl_id_c_to_f, long double, H5T_NATIVE_LDOUBLE, "ldouble", windchillFfloat, 1);
#endif
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, char, H5T_NATIVE_CHAR, "char", transformData, 0);
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned char, H5T_NATIVE_UCHAR, "uchar", transformData, 0);
TEST_TYPE_CHUNK(dxpl_id_c_to_f, signed char, H5T_NATIVE_SCHAR, "schar", windchillFfloat, 1);
TEST_TYPE_CHUNK(dxpl_id_c_to_f, short, H5T_NATIVE_SHORT, "short", windchillFfloat, 1);
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned short, H5T_NATIVE_USHORT, "ushort", transformData, 0);
TEST_TYPE_CHUNK(dxpl_id_c_to_f, int, H5T_NATIVE_INT, "int", windchillFfloat, 1);
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned int, H5T_NATIVE_UINT, "uint", transformData, 0);
TEST_TYPE_CHUNK(dxpl_id_c_to_f, long, H5T_NATIVE_LONG, "long", windchillFfloat, 1);
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned long, H5T_NATIVE_ULONG, "ulong", transformData, 0);
TEST_TYPE_CHUNK(dxpl_id_c_to_f, long long, H5T_NATIVE_LLONG, "llong", windchillFfloat, 1);
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned long long, H5T_NATIVE_ULLONG, "ullong", transformData, 0);
TEST_TYPE_CHUNK(dxpl_id_c_to_f, float, H5T_NATIVE_FLOAT, "float", windchillFfloat, 1);
TEST_TYPE_CHUNK(dxpl_id_c_to_f, double, H5T_NATIVE_DOUBLE, "double", windchillFfloat, 1);
#if H5_SIZEOF_LONG_DOUBLE != 0
TEST_TYPE_CHUNK(dxpl_id_c_to_f, long double, H5T_NATIVE_LDOUBLE, "ldouble", windchillFfloat, 1);
#endif
if (test_copy(dxpl_id_c_to_f_copy, dxpl_id_polynomial_copy) < 0)
TEST_ERROR;
if (test_trivial(dxpl_id_simple) < 0)
TEST_ERROR;
if (test_poly(dxpl_id_polynomial) < 0)
TEST_ERROR;
if (test_getset(dxpl_id_c_to_f) < 0)
TEST_ERROR;
if (test_specials(file_id) < 0)
TEST_ERROR;
/* Close the objects we opened/created */
if (H5Dclose(dset_id_int) < 0)
TEST_ERROR;
if (H5Dclose(dset_id_int_chunk) < 0)
TEST_ERROR;
if (H5Dclose(dset_id_float) < 0)
TEST_ERROR;
if (H5Dclose(dset_id_float_chunk) < 0)
TEST_ERROR;
if (H5Fclose(file_id) < 0)
TEST_ERROR;
if (H5Pclose(dxpl_id_c_to_f) < 0)
TEST_ERROR;
if (H5Pclose(dxpl_id_c_to_f_copy) < 0)
TEST_ERROR;
if (H5Pclose(dxpl_id_polynomial) < 0)
TEST_ERROR;
if (H5Pclose(dxpl_id_polynomial_copy) < 0)
TEST_ERROR;
if (H5Pclose(dxpl_id_simple) < 0)
TEST_ERROR;
if (H5Pclose(dxpl_id_utrans_inv) < 0)
TEST_ERROR;
return 0;
error:
H5E_BEGIN_TRY
{
H5Dclose(dset_id_int);
H5Dclose(dset_id_int_chunk);
H5Dclose(dset_id_float);
H5Dclose(dset_id_float_chunk);
H5Fclose(file_id);
H5Pclose(dxpl_id_c_to_f);
H5Pclose(dxpl_id_c_to_f_copy);
H5Pclose(dxpl_id_polynomial);
H5Pclose(dxpl_id_polynomial_copy);
H5Pclose(dxpl_id_simple);
H5Pclose(dxpl_id_utrans_inv);
}
H5E_END_TRY
return -1;
}
static int
init_test(hid_t file_id)
{
const char *f_to_c = "(5/9.0)*(x-32)";
/* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit
* into uchar */
const char *utrans = "((x+100)/4)*3";
hid_t dataspace = -1;
hid_t dxpl_id_f_to_c = -1;
hid_t dxpl_id_utrans = -1;
hid_t cparms = -1;
hid_t filespace = -1;
hsize_t dim[2] = {ROWS, COLS};
hsize_t offset[2] = {0, 0};
if ((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR
if ((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR
if (H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0)
TEST_ERROR
if (H5Pset_data_transform(dxpl_id_utrans, utrans) < 0)
TEST_ERROR
cparms = H5Pcreate(H5P_DATASET_CREATE);
if (H5Pset_chunk(cparms, 2, dim) < 0)
TEST_ERROR
if ((dataspace = H5Screate_simple(2, dim, NULL)) < 0)
TEST_ERROR
TESTING("Intializing test...")
if ((dset_id_int = H5Dcreate2(file_id, "/default_int", H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR
if (H5Dwrite(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0)
TEST_ERROR
if ((dset_id_float = H5Dcreate2(file_id, "/default_float", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT,
H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR
if (H5Dwrite(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0)
TEST_ERROR
if ((dset_id_int_chunk = H5Dcreate2(file_id, "/default_chunk_int", H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
cparms, H5P_DEFAULT)) < 0)
TEST_ERROR
if ((filespace = H5Dget_space(dset_id_int_chunk)) < 0)
TEST_ERROR
if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0)
TEST_ERROR
if (H5Dwrite(dset_id_int_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat) <
0)
TEST_ERROR
if ((dset_id_float_chunk = H5Dcreate2(file_id, "/default_chunk_float", H5T_NATIVE_FLOAT, dataspace,
H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
TEST_ERROR
if (H5Dwrite(dset_id_float_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c,
windchillFfloat) < 0)
TEST_ERROR
if (H5Pclose(cparms) < 0)
TEST_ERROR
if (H5Pclose(dxpl_id_f_to_c) < 0)
TEST_ERROR
if (H5Pclose(dxpl_id_utrans) < 0)
TEST_ERROR
if (H5Sclose(dataspace) < 0)
TEST_ERROR
if (H5Sclose(filespace) < 0)
TEST_ERROR
PASSED();
return 0;
error:
H5E_BEGIN_TRY
{
H5Pclose(cparms);
H5Pclose(dxpl_id_f_to_c);
H5Pclose(dxpl_id_utrans);
H5Sclose(dataspace);
H5Sclose(filespace);
}
H5E_END_TRY
return -1;
}
static int
test_poly(const hid_t dxpl_id_polynomial)
{
float polyflres[ROWS][COLS];
int polyintread[ROWS][COLS];
float polyflread[ROWS][COLS];
int windchillC;
int row, col;
for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++) {
windchillC = (int)((5.0f / 9.0f) * (windchillFfloat[row][col] - 32));
polyflres[row][col] = ((2.0f + (float)windchillC) * (((float)windchillC - 8.0f) / 2.0f));
}
TESTING("data transform, polynomial transform (int->float)")
if (H5Dread(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyflread) < 0)
TEST_ERROR
COMPARE(float, polyflread, polyflres, 2.0f)
for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++) {
windchillC = (int)((5.0f / 9.0f) * (windchillFfloat[row][col] - 32));
polyflres[row][col] = (float)((2 + windchillC) * ((windchillC - 8) / 2));
}
TESTING("data transform, polynomial transform (float->int)")
if (H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyintread) < 0)
TEST_ERROR
COMPARE(int, polyintread, polyflres, 4)
return 0;
error:
return -1;
}
static int
test_specials(hid_t file)
{
hid_t dxpl_id, dset_id, dataspace;
hsize_t dim[2] = {ROWS, COLS};
int read_buf[ROWS][COLS];
int data_res[ROWS][COLS];
int row, col;
const char *special1 = "x*-100";
const char *special2 = "100-x";
const char *special3 = "1000/x";
const char *special4 = "-x";
const char *special5 = "+x";
const char *special6 = "2e+1*x";
TESTING("data transform of some special cases")
if ((dataspace = H5Screate_simple(2, dim, NULL)) < 0)
TEST_ERROR
if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
/*-----------------------------
* Operation 1: x*-100
*----------------------------*/
if (H5Pset_data_transform(dxpl_id, special1) < 0)
TEST_ERROR;
for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++)
data_res[row][col] = transformData[row][col] * -100;
if ((dset_id = H5Dcreate2(file, "/special1", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT)) < 0)
TEST_ERROR
if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0)
TEST_ERROR
if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0)
TEST_ERROR
COMPARE_INT(read_buf, data_res)
if (H5Dclose(dset_id) < 0)
TEST_ERROR
/*-----------------------------
* Operation 2: 100-x
*----------------------------*/
if (H5Pset_data_transform(dxpl_id, special2) < 0)
TEST_ERROR;
for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++)
data_res[row][col] = 100 - transformData[row][col];
if ((dset_id = H5Dcreate2(file, "/special2", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT)) < 0)
TEST_ERROR
if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0)
TEST_ERROR
if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0)
TEST_ERROR
COMPARE_INT(read_buf, data_res)
if (H5Dclose(dset_id) < 0)
TEST_ERROR
/*-----------------------------
* Operation 3: 1000/x
*----------------------------*/
if (H5Pset_data_transform(dxpl_id, special3) < 0)
TEST_ERROR;
for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++)
data_res[row][col] = 1000 / transformData[row][col];
if ((dset_id = H5Dcreate2(file, "/special3", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT)) < 0)
TEST_ERROR
if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0)
TEST_ERROR
if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0)
TEST_ERROR
COMPARE_INT(read_buf, data_res)
if (H5Dclose(dset_id) < 0)
TEST_ERROR
/*-----------------------------
* Operation 4: -x
*----------------------------*/
if (H5Pset_data_transform(dxpl_id, special4) < 0)
TEST_ERROR;
for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++)
data_res[row][col] = -1 * transformData[row][col];
if ((dset_id = H5Dcreate2(file, "/special4", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT)) < 0)
TEST_ERROR
if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0)
TEST_ERROR
if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0)
TEST_ERROR
COMPARE_INT(read_buf, data_res)
if (H5Dclose(dset_id) < 0)
TEST_ERROR
/*-----------------------------
* Operation 5: +x
*----------------------------*/
if (H5Pset_data_transform(dxpl_id, special5) < 0)
TEST_ERROR;
for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++)
data_res[row][col] = transformData[row][col];
if ((dset_id = H5Dcreate2(file, "/special5", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT)) < 0)
TEST_ERROR
if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0)
TEST_ERROR
if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0)
TEST_ERROR
COMPARE_INT(read_buf, data_res)
if (H5Dclose(dset_id) < 0)
TEST_ERROR
/*-----------------------------
* Operation 6: 2e+1*x
*----------------------------*/
if (H5Pset_data_transform(dxpl_id, special6) < 0)
TEST_ERROR;
for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++)
data_res[row][col] = transformData[row][col] * 20;
if ((dset_id = H5Dcreate2(file, "/special6", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT)) < 0)
TEST_ERROR
if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0)
TEST_ERROR
if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0)
TEST_ERROR
COMPARE_INT(read_buf, data_res)
if (H5Dclose(dset_id) < 0)
TEST_ERROR
if (H5Pclose(dxpl_id) < 0)
TEST_ERROR
if (H5Sclose(dataspace) < 0)
TEST_ERROR
PASSED();
return 0;
error:
return -1;
}
static int
test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy)
{
int windchillC;
float polyflres[ROWS][COLS];
int polyintread[ROWS][COLS];
int windchillFintread[ROWS][COLS];
int row, col;
for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++) {
windchillC = (int)((5.0f / 9.0f) * (windchillFfloat[row][col] - 32));
polyflres[row][col] = (float)((2 + windchillC) * ((windchillC - 8) / 2));
}
TESTING("data transform, linear transform w/ copied property")
if (H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f_copy, windchillFintread) < 0)
TEST_ERROR
COMPARE(int, windchillFintread, windchillFfloat, 2)
TESTING("data transform, polynomial transform w/ copied property")
if (H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial_copy, polyintread) < 0)
TEST_ERROR
COMPARE(int, polyintread, polyflres, 2)
return 0;
error:
return -1;
}
static int
test_trivial(const hid_t dxpl_id_simple)
{
float windchillFfloatread[ROWS][COLS];
int windchillFintread[ROWS][COLS];
int row, col;
TESTING("data transform, trivial transform, without type conversion")
if (H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFfloatread) < 0)
TEST_ERROR
for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++) {
if ((windchillFfloatread[row][col] - 4.8f) > FLOAT_TOL)
FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n");
}
PASSED();
TESTING("data transform, trivial transform, with type conversion")
if (H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFintread) < 0)
TEST_ERROR
for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++) {
if (windchillFintread[row][col] != 4)
FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n")
}
PASSED();
return 0;
error:
return -1;
}
static int
test_getset(const hid_t dxpl_id_c_to_f)
{
int row;
int col;
float windchillFfloatread[ROWS][COLS];
const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
const char *c_to_f = "(9/5.0)*x + 32";
char * ptrgetTest = NULL;
TESTING("H5Pget_data_transform")
if (NULL == (ptrgetTest = (char *)HDmalloc(HDstrlen(simple) + 1)))
TEST_ERROR
if (H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(c_to_f) + 1) < 0)
TEST_ERROR
if (HDstrcmp(c_to_f, ptrgetTest) != 0)
FAIL_PUTS_ERROR(" ERROR: Data transform failed to match what was set\n")
PASSED();
HDfree(ptrgetTest);
ptrgetTest = NULL;
TESTING("data transform, read after resetting of transform property")
if (H5Pset_data_transform(dxpl_id_c_to_f, simple) < 0)
TEST_ERROR
if (H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFfloatread) < 0)
TEST_ERROR
for (row = 0; row < ROWS; row++)
for (col = 0; col < COLS; col++) {
if ((windchillFfloatread[row][col] - 4.8f) > FLOAT_TOL)
FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n")
}
PASSED();
TESTING("H5Pget_data_transform, after resetting transform property")
if (NULL == (ptrgetTest = (char *)HDcalloc((size_t)1, HDstrlen(simple) + 1)))
TEST_ERROR
if (H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(simple) + 1) < 0)
TEST_ERROR
if (HDstrcmp(simple, ptrgetTest) != 0)
FAIL_PUTS_ERROR(" ERROR: Data transform failed to match what was set\n")
PASSED();
HDfree(ptrgetTest);
ptrgetTest = NULL;
return 0;
error:
if (ptrgetTest)
HDfree(ptrgetTest);
return -1;
}
static int
test_set(void)
{
hid_t dxpl_id = -1;
H5E_auto2_t func;
const char *str = "(9/5.0)*x + 32";
char * ptrgetTest = NULL;
TESTING("H5Pget_data_transform (get before set)")
if (NULL == (ptrgetTest = (char *)HDmalloc(HDstrlen(str) + 1)))
TEST_ERROR
if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR
/* Test get before set */
H5Eget_auto2(H5E_DEFAULT, &func, NULL);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
if (H5Pget_data_transform(dxpl_id, ptrgetTest, HDstrlen(str) + 1) < 0)
PASSED();
else
FAIL_PUTS_ERROR(" ERROR: Data transform get before set succeeded (it shouldn't have)\n");
HDfree(ptrgetTest);
ptrgetTest = NULL;
TESTING("H5Pset_data_transform (set with NULL transform)");
INVALID_SET_TEST(NULL);
TESTING("H5Pset_data_transform (set with invalid transform 1)")
INVALID_SET_TEST("\0");
TESTING("H5Pset_data_transform (set with invalid transform 2)")
INVALID_SET_TEST(" ");
TESTING("H5Pset_data_transform (set with invalid transform 3)")
INVALID_SET_TEST("x+");
TESTING("H5Pset_data_transform (set with invalid transform 4)")
INVALID_SET_TEST("(x+5");
TESTING("H5Pset_data_transform (set with invalid transform 5)")
INVALID_SET_TEST("+");
TESTING("H5Pset_data_transform (set with invalid transform 6)")
INVALID_SET_TEST("(9/5)*x + x**2");
TESTING("H5Pset_data_transform (set with invalid transform 7)")
INVALID_SET_TEST("(9/5)x");
TESTING("H5Pset_data_transform (set with invalid transform 8)")
INVALID_SET_TEST("(9/5)*x + x^2");
H5Eset_auto2(H5E_DEFAULT, func, NULL);
if (H5Pclose(dxpl_id) < 0)
TEST_ERROR
return 0;
error:
if (ptrgetTest)
HDfree(ptrgetTest);
H5E_BEGIN_TRY
{
H5Pclose(dxpl_id);
}
H5E_END_TRY
return -1;
}