Skip to content

Commit

Permalink
Replaces checks for fork, etc. with checks for unistd.h (#457)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
derobins authored Mar 11, 2021
1 parent a78aae1 commit 6f760f2
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 67 deletions.
6 changes: 3 additions & 3 deletions test/accum.c
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,7 @@ HDfprintf(stderr, "Random # seed was: %u\n", seed);
unsigned
test_swmr_write_big(hbool_t newest_format)
{
#if defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID) && defined(H5_HAVE_UNISTD_H)
#ifdef H5_HAVE_UNISTD_H
hid_t fid = -1; /* File ID */
hid_t fapl = -1; /* File access property list */
H5F_t * rf = NULL; /* File pointer */
Expand Down Expand Up @@ -2287,11 +2287,11 @@ test_swmr_write_big(hbool_t newest_format)

return 1;

#else
#else /* H5_HAVE_UNISTD_H */
SKIPPED();
HDputs(" Test skipped due to fork, waitpid, or pid_t not defined.");
return 0;
#endif /* defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID) && defined(H5_HAVE_UNISTD_H) */
#endif /* H5_HAVE_UNISTD_H */

} /* end test_swmr_write_big() */

Expand Down
12 changes: 6 additions & 6 deletions test/dt_arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static int skip_overflow_tests_g = 0;
* be allowed to continue (cf. Posix signals) so in order to recover from a
* SIGFPE we run tests that might generate one in a child process.
*/
#if defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID)
#ifdef H5_HAVE_UNISTD_H
#define HANDLE_SIGFPE
#endif

Expand Down Expand Up @@ -556,7 +556,7 @@ some_dummy_func(float x)
static void
generates_sigfpe(void)
{
#if defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID)
#ifdef H5_HAVE_UNISTD_H
pid_t pid;
int status;
size_t i, j;
Expand Down Expand Up @@ -592,12 +592,12 @@ generates_sigfpe(void)
/* delete the core dump file that SIGFPE may have created */
HDunlink("core");
}
#else
HDputs("Cannot determine if floating-point overflows generate a SIGFPE;");
HDputs("assuming yes.");
#else /* H5_HAVE_UNISTD_H */
HDputs("Cannot determine if floating-point overflows generate a SIGFPE");
HDputs("due to a lack of fork(2) - assuming yes.");
HDputs("Overflow cases will not be tested.");
skip_overflow_tests_g = TRUE;
#endif
#endif /* H5_HAVE_UNISTD_H */
}

/*-------------------------------------------------------------------------
Expand Down
68 changes: 45 additions & 23 deletions test/swmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2341,17 +2341,24 @@ test_err_start_swmr_write(hid_t in_fapl, hbool_t new_format)
* (5) Parent: open a file with write access; enable SWMR writing mode
* Child: concurrent open of the file with write and SWMR write access (fail)
*/
#if !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID))
#ifndef H5_HAVE_UNISTD_H

static int
test_start_swmr_write_concur(hid_t H5_ATTR_UNUSED in_fapl, hbool_t H5_ATTR_UNUSED new_format)
test_start_swmr_write_concur(hid_t H5_ATTR_UNUSED in_fapl, hbool_t new_format)
{
if (new_format) {
TESTING("H5Fstart_swmr_write()--concurrent access for latest format");
}
else {
TESTING("H5Fstart_swmr_write()--concurrent access for non-latest-format");
}

SKIPPED();
HDputs(" Test skipped due to fork or waitpid not defined.");
HDputs(" Test skipped due to a lack of unistd.h functionality.");
return 0;
} /* test_start_swmr_write_concur() */

#else /* defined(H5_HAVE_FORK && defined(H5_HAVE_WAITPID) */
#else /* H5_HAVE_UNISTD_H */

static int
test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format)
Expand Down Expand Up @@ -2383,7 +2390,7 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format)
}
else {
TESTING("H5Fstart_swmr_write()--concurrent access for non-latest-format");
} /* end if */
}

if ((fapl = H5Pcopy(in_fapl)) < 0)
FAIL_STACK_ERROR
Expand Down Expand Up @@ -2944,7 +2951,7 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format)
return -1;

} /* test_start_swmr_write_concur() */
#endif /* !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID)) */
#endif /* H5_HAVE_UNISTD_H */

/*
* test_start_swmr_write_stress_ohdr():
Expand Down Expand Up @@ -4675,20 +4682,20 @@ test_file_lock_swmr_same(hid_t in_fapl)
** This is for concurrent access.
**
*****************************************************************/
#if !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID) && defined(H5_HAVE_FLOCK))
#ifndef H5_HAVE_UNISTD_H

static int
test_file_lock_concur(hid_t H5_ATTR_UNUSED in_fapl)
{
/* Output message about test being performed */
TESTING("File open with different combinations of flags--concurrent access");
SKIPPED();
HDputs(" Test skipped due to fork, waitpid, or flock not defined.");
HDputs(" Test skipped due to a lack of unistd.h functionality.");
return 0;

} /* end test_file_lock_concur() */

#else
#else /* H5_HAVE_UNISTD_H */

static int
test_file_lock_concur(hid_t in_fapl)
Expand Down Expand Up @@ -5046,7 +5053,7 @@ test_file_lock_concur(hid_t in_fapl)

} /* end test_file_lock_concur() */

#endif /* !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID) && defined(H5_HAVE_FLOCK)) */
#endif /* H5_HAVE_UNISTD_H */

/****************************************************************
**
Expand All @@ -5056,20 +5063,20 @@ test_file_lock_concur(hid_t in_fapl)
** This is for concurrent access.
**
*****************************************************************/
#if !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID))
#ifndef H5_HAVE_UNISTD_H

static int
test_file_lock_swmr_concur(hid_t H5_ATTR_UNUSED in_fapl)
{
/* Output message about test being performed */
TESTING("File open with different combintations of flags + SWMR flags--concurrent access");
SKIPPED();
HDputs(" Test skipped due to fork or waitpid not defined.");
HDputs(" Test skipped due to a lack of unistd.h functionality.");
return 0;

} /* end test_file_lock_swmr_concur() */

#else
#else /* H5_HAVE_UNISTD_H */

static int
test_file_lock_swmr_concur(hid_t in_fapl)
Expand Down Expand Up @@ -6036,7 +6043,7 @@ test_file_lock_swmr_concur(hid_t in_fapl)

} /* end test_file_lock_swmr_concur() */

#endif /* !(defined(H5_HAVE_FORK && defined(H5_HAVE_WAITPID)) */
#endif /* H5_HAVE_UNISTD_H */

/****************************************************************
**
Expand All @@ -6048,11 +6055,19 @@ test_file_lock_swmr_concur(hid_t in_fapl)
static int
test_file_locking(hid_t in_fapl, hbool_t turn_locking_on, hbool_t env_var_override)
{
#if !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID))
#ifndef H5_HAVE_UNISTD_H
if (turn_locking_on && env_var_override)
TESTING("File locking: ON w/ env var override")
else if (turn_locking_on && !env_var_override)
TESTING("File locking: ON")
else if (!turn_locking_on && env_var_override)
TESTING("File locking: OFF w/ env var override")
else
TESTING("File locking: OFF")
SKIPPED();
HDputs(" Test skipped due to fork or waitpid not defined.");
HDputs(" Test skipped due to a lack of unistd.h functionality.");
return 0;
#else
#else /* H5_HAVE_UNISTD_H */
hid_t fid = -1; /* File ID */
hid_t fapl = -1; /* File access property list */
char filename[NAME_BUF_SIZE]; /* file name */
Expand Down Expand Up @@ -6218,7 +6233,7 @@ test_file_locking(hid_t in_fapl, hbool_t turn_locking_on, hbool_t env_var_overri

return -1;

#endif /* !(defined(H5_HAVE_FORK && defined(H5_HAVE_WAITPID)) */
#endif /* H5_HAVE_UNISTD_H */

} /* end test_file_locking() */

Expand Down Expand Up @@ -6498,17 +6513,24 @@ test_bug_refresh(hid_t in_fapl)
* (7) Refresh the dataset
* (8) Verify the dataset's dimension and data are correct
*/
#if !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID))
#ifndef H5_HAVE_UNISTD_H

static int
test_refresh_concur(hid_t H5_ATTR_UNUSED in_fapl, hbool_t H5_ATTR_UNUSED new_format)
test_refresh_concur(hid_t H5_ATTR_UNUSED in_fapl, hbool_t new_format)
{
if (new_format) {
TESTING("H5Drefresh()--concurrent access for latest format");
}
else {
TESTING("H5Drefresh()--concurrent access for non-latest-format");
}

SKIPPED();
HDputs(" Test skipped due to fork or waitpid not defined.");
HDputs(" Test skipped due to a lack of unistd.h functionality.");
return 0;
} /* test_refresh_concur() */

#else /* defined(H5_HAVE_FORK && defined(H5_HAVE_WAITPID) */
#else /* H5_HAVE_UNISTD_H */

static int
test_refresh_concur(hid_t in_fapl, hbool_t new_format)
Expand Down Expand Up @@ -6808,7 +6830,7 @@ test_refresh_concur(hid_t in_fapl, hbool_t new_format)
return -1;

} /* test_refresh_concur() */
#endif /* !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID)) */
#endif /* H5_HAVE_UNISTD_H */

/*
* test_multiple_same():
Expand Down
10 changes: 4 additions & 6 deletions test/twriteorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@
#include "h5test.h"

/* This test uses many POSIX things that are not available on
* Windows. We're using a check for fork(2) here as a proxy for
* all POSIX/Unix/Linux things until this test can be made
* more platform-independent.
* Windows.
*/
#ifdef H5_HAVE_FORK
#ifdef H5_HAVE_UNISTD_H

#define DATAFILE "twriteorder.dat"
/* #define READERS_MAX 10 */ /* max number of readers */
Expand Down Expand Up @@ -468,7 +466,7 @@ main(int argc, char *argv[])
return ret_value;
}

#else /* H5_HAVE_FORK */
#else /* H5_HAVE_UNISTD_H */

int
main(void)
Expand All @@ -477,4 +475,4 @@ main(void)
return EXIT_SUCCESS;
} /* end main() */

#endif /* H5_HAVE_FORK */
#endif /* H5_HAVE_UNISTD_H */
10 changes: 4 additions & 6 deletions test/use_append_chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@
#include "h5test.h"

/* This test uses many POSIX things that are not available on
* Windows. We're using a check for fork(2) here as a proxy for
* all POSIX/Unix/Linux things until this test can be made
* more platform-independent.
* Windows.
*/
#ifdef H5_HAVE_FORK
#ifdef H5_HAVE_UNISTD_H

#include "use.h"

Expand Down Expand Up @@ -272,7 +270,7 @@ main(int argc, char *argv[])
return (ret_value);
}

#else /* H5_HAVE_FORK */
#else /* H5_HAVE_UNISTD_H */

int
main(void)
Expand All @@ -281,4 +279,4 @@ main(void)
return EXIT_SUCCESS;
} /* end main() */

#endif /* H5_HAVE_FORK */
#endif /* H5_HAVE_UNISTD_H */
10 changes: 4 additions & 6 deletions test/use_append_chunk_mirror.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@
#include "use.h"

/* This test uses many POSIX things that are not available on
* Windows. We're using a check for fork(2) here as a proxy for
* all POSIX/Unix/Linux things until this test can be made
* more platform-independent.
* Windows.
*/
#ifdef H5_HAVE_FORK
#ifdef H5_HAVE_UNISTD_H

#ifdef H5_HAVE_MIRROR_VFD

Expand Down Expand Up @@ -391,7 +389,7 @@ main(void)

#endif /* H5_HAVE_MIRROR_VFD */

#else /* H5_HAVE_FORK */
#else /* H5_HAVE_UNISTD_H */

int
main(void)
Expand All @@ -400,4 +398,4 @@ main(void)
return EXIT_SUCCESS;
} /* end main() */

#endif /* H5_HAVE_FORK */
#endif /* H5_HAVE_UNISTD_H */
10 changes: 4 additions & 6 deletions test/use_append_mchunks.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@
#include "h5test.h"

/* This test uses many POSIX things that are not available on
* Windows. We're using a check for fork(2) here as a proxy for
* all POSIX/Unix/Linux things until this test can be made
* more platform-independent.
* Windows.
*/
#ifdef H5_HAVE_FORK
#ifdef H5_HAVE_UNISTD_H

#include "use.h"

Expand Down Expand Up @@ -267,7 +265,7 @@ main(int argc, char *argv[])
return (ret_value);
} /* end main() */

#else /* H5_HAVE_FORK */
#else /* H5_HAVE_UNISTD_H */

int
main(void)
Expand All @@ -276,4 +274,4 @@ main(void)
return EXIT_SUCCESS;
} /* end main() */

#endif /* H5_HAVE_FORK */
#endif /* H5_HAVE_UNISTD_H */
8 changes: 3 additions & 5 deletions test/use_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
#include "h5test.h"

/* This test uses many POSIX things that are not available on
* Windows. We're using a check for fork(2) here as a proxy for
* all POSIX/Unix/Linux things until this test can be made
* more platform-independent.
* Windows.
*/
#ifdef H5_HAVE_FORK
#ifdef H5_HAVE_UNISTD_H

#include "use.h"

Expand Down Expand Up @@ -613,4 +611,4 @@ read_uc_file(hbool_t towait, options_t *opts)
return 0;
} /* end read_uc_file() */

#endif /* H5_HAVE_FORK */
#endif /* H5_HAVE_UNISTD_H */
Loading

0 comments on commit 6f760f2

Please sign in to comment.