* close #195. (#196)
* Update HDF5PluginMacros.cmake
* Update HDF5PluginMacros.cmake
* Modify temporary rpath for testing in java example scripts. (#230)
* Fix undefined left shifting of negative numbers (#338)
Undefined Bahavior Sanitizer errored here about left shifting negative numbers.
* Update license url (#332)
* Modify temporary rpath for testing in java example scripts.
* Update URL in source file Copyright headers for web copy of COPYING
file - src and test directories.
* Simplified hl parsing (#399)
* Stop using global variables to share parse context with the lexer.
The lexer uses an unconventional strategy for parsing lexical categories
NUMBER (decimal numbers) and STRING (double-quoted strings) that involves
sharing the parse context with the lexer using global variables. There
are a couple of problems with that. First, the lexer is too complicated
for the simple tokenization it performs—it's hard to tell if it is
correct. Second, as @seanm points out, the shared global variables
spill into the namespace shared by other libraries and application
programs—e.g., VTK.
* Regenerate source files from *.[yl].
* Replace strndup, which isn't available on Windows, with a custom
routine, `trim_quotes`, that produces a copy of its `const char *`
argument with leading and trailing double quotes ('"') removed.
While I am here, remove the unnecessary statement `BEGIN INITIAL;`,
which I should have deleted in a previous commit.
* Regenerate .c from .l.
* You haven't programmed in C until you have programmed in High-Definition
(HD) C.
* \#include "H5private.h" for HD* definitions.
* Regenerate *.[ch] from *.[yl].
* Removed workarounds for pre-standard inline keyword (#423)
Fixes -Wreserved-identifier warnings due to multiple underscores in H5_HAVE___INLINE.
* Replaces checks for fork, etc. with checks for unistd.h (#457)
* Replaces checks for fork, etc. with H5_HAVE_UNISTD_H
Code previously checked for individual POSIX API calls using
H5_HAVE_FORK, etc. The calls we use have been standardized for
decades and available via unistd.h.
Some test messages that were missing when tests are skipped
due to a lack of unistd.h were also added.
The configure checks for individual POSIX API calls will be
removed in a later commit.
* Stupid formatter
* Update h5LT files with latest flex and Bison available on jelly (#502)
* Modify temporary rpath for testing in java example scripts.
* Update URL in source file Copyright headers for web copy of COPYING (license) file.
* Add release_docs/code-conventions.md file.
* Add script to test h5py.
* Fix script error.
* Add file h5pytest.yml.
* Test declaration of counter variables in for loops.
* Committing clang-format changes
* Committing clang-format changes
* Added [] to line 126 of H5LTanalyze.l.
Ran bin/genparser with flex v2.6.4 and Bison v3.0.4 on jelly.
* Revert "Added [] to line 126 of H5LTanalyze.l."
This reverts commit e4a9cee441.
* Revert extra commits to match canonical develop.
* Added [] to H5LTanalyze.l line 126 to eliminate warning "rule could not be
matched".
Ran bin/genparser hl/src with flex v2.6.4 and Bison v3.0.4 on jelly.
* Added HD to strdup in H5LTparse.y line 338.
Ran bin/genparser hlsrc again.
* Removed line 126 from H5LTanalyze.l - previous line matches.
Added previously removed line 318 of H5LTparse.y to fix hl_test_lite
failure.
Ran bin/genparser.
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Add cmake variable HDF5_LIB_INFIX (#7)
* Add cmake variable HDF5_LIB_INFIX
This infix is added to all library names after 'hdf5'.
e.g. the infix '_openmpi' results in the library name 'libhdf5_openmpi.so'
This name is used in packages on debian based systems.
(see https://packages.debian.org/jessie/amd64/libhdf5-openmpi-8/filelist)
This option is useful when testing projects on debian based systems with
custom builds of hdf5 while trying to minimize differences between the
custom setup and the environment created by installing system packages.
* Added RELEASE.txt entry for HDF5_LIB_INFIX.
Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
* Update test/accum.c to correct merge for replacing checks for fork, etc. with checks for unistd.h (#457)
* Committing clang-format changes
Co-authored-by: H. Joe Lee <hyoklee@hdfgroup.org>
Co-authored-by: Sean McBride <sean@rogue-research.com>
Co-authored-by: David Young <dyoung@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: Raphael Grimm <barcode@users.noreply.github.com>
283 lines
9.6 KiB
C
283 lines
9.6 KiB
C
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
* 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 *
|
|
* 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. *
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
* Use Case 1.7 Appending a single chunk
|
|
* Description:
|
|
* Appending a single chunk of raw data to a dataset along an unlimited
|
|
* dimension within a pre-created file and reading the new data back.
|
|
* Goal:
|
|
* Read data appended by the Writer to a pre-existing dataset in a
|
|
* file. The dataset has one or more unlimited dimensions. The data is
|
|
* appended by a hyperslab that is contained in one chunk (for example,
|
|
* appending 2-dim planes along the slowest changing dimension in the
|
|
* 3-dim dataset).
|
|
* Level:
|
|
* User Level
|
|
* Guarantees:
|
|
* o Readers will see the modified dimension sizes after the Writer
|
|
* finishes HDF5 metadata updates and issues H5Fflush or H5Oflush calls.
|
|
* o Readers will see newly appended data after the Writer finishes
|
|
* the flush operation.
|
|
*
|
|
* Preconditions:
|
|
* o Readers are not allowed to modify the file.
|
|
* o All datasets that are modified by the Writer exist when the Writer
|
|
* opens the file.
|
|
* o All datasets that are modified by the Writer exist when a Reader
|
|
* opens the file.
|
|
* o Data is written by a hyperslab contained in one chunk.
|
|
*
|
|
* Main Success Scenario:
|
|
* 1. An application creates a file with required objects (groups,
|
|
* datasets, and attributes).
|
|
* 2. The Writer application opens the file and datasets in the file
|
|
* and starts adding data along the unlimited dimension using a hyperslab
|
|
* selection that corresponds to an HDF5 chunk.
|
|
* 3. A Reader opens the file and a dataset in a file, and queries
|
|
* the sizes of the dataset; if the extent of the dataset has changed,
|
|
* reads the appended data back.
|
|
*
|
|
* Discussion points:
|
|
* 1. Since the new data is written to the file, and metadata update
|
|
* operation of adding pointer to the newly written chunk is atomic and
|
|
* happens after the chunk is on the disk, only two things may happen
|
|
* to the Reader:
|
|
* o The Reader will not see new data.
|
|
* o The Reader will see all new data written by Writer.
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
/* Created: Albert Cheng, 2013/5/28 */
|
|
|
|
#include "h5test.h"
|
|
|
|
/* This test uses many POSIX things that are not available on
|
|
* Windows.
|
|
*/
|
|
#ifdef H5_HAVE_UNISTD_H
|
|
|
|
#include "use.h"
|
|
|
|
#define USE_APPEND_CHUNK_PROGNAME "use_append_chunk"
|
|
|
|
static options_t UC_opts; /* Use Case Options */
|
|
|
|
/* Setup parameters for the use case.
|
|
* Return: 0 succeed; -1 fail.
|
|
*/
|
|
int
|
|
setup_parameters(int argc, char *const argv[], options_t *opts)
|
|
{
|
|
/* use case defaults */
|
|
HDmemset(opts, 0, sizeof(options_t));
|
|
opts->chunksize = Chunksize_DFT;
|
|
opts->use_swmr = TRUE; /* use swmr open */
|
|
opts->iterations = 1;
|
|
opts->chunkplanes = 1;
|
|
opts->progname = USE_APPEND_CHUNK_PROGNAME;
|
|
|
|
if (parse_option(argc, argv, opts) < 0)
|
|
return (-1);
|
|
|
|
opts->chunkdims[0] = opts->chunkplanes;
|
|
opts->chunkdims[1] = opts->chunkdims[2] = opts->chunksize;
|
|
|
|
opts->dims[0] = 0;
|
|
opts->max_dims[0] = H5S_UNLIMITED;
|
|
opts->dims[1] = opts->dims[2] = opts->max_dims[1] = opts->max_dims[2] = opts->chunksize;
|
|
|
|
if (opts->nplanes == 0)
|
|
opts->nplanes = (hsize_t)opts->chunksize;
|
|
|
|
show_parameters(opts);
|
|
return (0);
|
|
} /* setup_parameters() */
|
|
|
|
/* Overall Algorithm:
|
|
* Parse options from user;
|
|
* Generate/pre-created test files needed and close it;
|
|
* fork: child process becomes the reader process;
|
|
* while parent process continues as the writer process;
|
|
* both run till ending conditions are met.
|
|
*/
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
pid_t childpid = 0;
|
|
pid_t mypid, tmppid;
|
|
int child_status;
|
|
int child_wait_option = 0;
|
|
int ret_value = 0;
|
|
int child_ret_value;
|
|
hbool_t send_wait = FALSE;
|
|
hid_t fapl = -1; /* File access property list */
|
|
hid_t fid = -1; /* File ID */
|
|
|
|
if (setup_parameters(argc, argv, &UC_opts) < 0) {
|
|
Hgoto_error(1);
|
|
}
|
|
|
|
/* Determine the need to send/wait message file*/
|
|
if (UC_opts.launch == UC_READWRITE) {
|
|
HDunlink(WRITER_MESSAGE);
|
|
send_wait = TRUE;
|
|
}
|
|
|
|
/* ==============================================================*/
|
|
/* UC_READWRITE: create datafile, launch both reader and writer. */
|
|
/* UC_WRITER: create datafile, skip reader, launch writer. */
|
|
/* UC_READER: skip create, launch reader, exit. */
|
|
/* ==============================================================*/
|
|
/* =========== */
|
|
/* Create file */
|
|
/* =========== */
|
|
if (UC_opts.launch != UC_READER) {
|
|
HDprintf("Creating skeleton data file for test...\n");
|
|
if ((UC_opts.fapl_id = h5_fileaccess()) < 0) {
|
|
HDfprintf(stderr, "can't create creation FAPL\n");
|
|
Hgoto_error(1);
|
|
}
|
|
if (H5Pset_libver_bounds(UC_opts.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
|
|
HDfprintf(stderr, "can't set creation FAPL libver bounds\n");
|
|
Hgoto_error(1);
|
|
}
|
|
if (create_uc_file(&UC_opts) < 0) {
|
|
HDfprintf(stderr, "***encounter error\n");
|
|
Hgoto_error(1);
|
|
}
|
|
else {
|
|
HDprintf("File created.\n");
|
|
}
|
|
/* Close FAPL to prevent issues with forking later */
|
|
if (H5Pclose(UC_opts.fapl_id) < 0) {
|
|
HDfprintf(stderr, "can't close creation FAPL\n");
|
|
Hgoto_error(1);
|
|
}
|
|
UC_opts.fapl_id = H5I_INVALID_HID;
|
|
}
|
|
|
|
/* ============ */
|
|
/* Fork process */
|
|
/* ============ */
|
|
if (UC_opts.launch == UC_READWRITE) {
|
|
if ((childpid = HDfork()) < 0) {
|
|
HDperror("fork");
|
|
Hgoto_error(1);
|
|
}
|
|
}
|
|
mypid = HDgetpid();
|
|
|
|
/* ============= */
|
|
/* launch reader */
|
|
/* ============= */
|
|
if (UC_opts.launch != UC_WRITER) {
|
|
/* child process launch the reader */
|
|
if (0 == childpid) {
|
|
HDprintf("%d: launch reader process\n", mypid);
|
|
if ((UC_opts.fapl_id = h5_fileaccess()) < 0) {
|
|
HDfprintf(stderr, "can't create read FAPL\n");
|
|
HDexit(EXIT_FAILURE);
|
|
}
|
|
if (read_uc_file(send_wait, &UC_opts) < 0) {
|
|
HDfprintf(stderr, "read_uc_file encountered error\n");
|
|
HDexit(EXIT_FAILURE);
|
|
}
|
|
if (H5Pclose(UC_opts.fapl_id) < 0) {
|
|
HDfprintf(stderr, "can't close read FAPL\n");
|
|
HDexit(EXIT_FAILURE);
|
|
}
|
|
HDexit(EXIT_SUCCESS);
|
|
}
|
|
}
|
|
|
|
/* ============= */
|
|
/* launch writer */
|
|
/* ============= */
|
|
/* this process continues to launch the writer */
|
|
HDprintf("%d: continue as the writer process\n", mypid);
|
|
|
|
if ((fapl = h5_fileaccess()) < 0) {
|
|
HDfprintf(stderr, "can't create write FAPL\n");
|
|
Hgoto_error(1);
|
|
}
|
|
|
|
if (UC_opts.use_swmr) {
|
|
if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
|
|
HDfprintf(stderr, "can't set write FAPL libver bounds\n");
|
|
Hgoto_error(1);
|
|
}
|
|
}
|
|
|
|
if ((fid = H5Fopen(UC_opts.filename, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) <
|
|
0) {
|
|
HDfprintf(stderr, "H5Fopen failed\n");
|
|
Hgoto_error(1);
|
|
}
|
|
|
|
if (write_uc_file(send_wait, fid, &UC_opts) < 0) {
|
|
HDfprintf(stderr, "write_uc_file encountered error\n");
|
|
Hgoto_error(1);
|
|
}
|
|
|
|
if (H5Fclose(fid) < 0) {
|
|
HDfprintf(stderr, "Failed to close write\n");
|
|
Hgoto_error(1);
|
|
}
|
|
|
|
if (H5Pclose(fapl) < 0) {
|
|
HDfprintf(stderr, "can't close write FAPL\n");
|
|
Hgoto_error(1);
|
|
}
|
|
|
|
/* ================================================ */
|
|
/* If readwrite, collect exit code of child process */
|
|
/* ================================================ */
|
|
if (UC_opts.launch == UC_READWRITE) {
|
|
if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) {
|
|
HDperror("waitpid");
|
|
Hgoto_error(1);
|
|
}
|
|
|
|
if (WIFEXITED(child_status)) {
|
|
if ((child_ret_value = WEXITSTATUS(child_status)) != 0) {
|
|
HDprintf("%d: child process exited with non-zero code (%d)\n", mypid, child_ret_value);
|
|
Hgoto_error(2);
|
|
}
|
|
}
|
|
else {
|
|
HDprintf("%d: child process terminated abnormally\n", mypid);
|
|
Hgoto_error(2);
|
|
}
|
|
}
|
|
|
|
done:
|
|
if (ret_value != 0) {
|
|
HDprintf("Error(s) encountered\n");
|
|
}
|
|
else {
|
|
HDprintf("All passed\n");
|
|
}
|
|
|
|
return (ret_value);
|
|
}
|
|
|
|
#else /* H5_HAVE_UNISTD_H */
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
HDfprintf(stderr, "Non-POSIX platform. Skipping.\n");
|
|
return EXIT_SUCCESS;
|
|
} /* end main() */
|
|
|
|
#endif /* H5_HAVE_UNISTD_H */
|