summaryrefslogtreecommitdiffstats
path: root/tools/test
diff options
context:
space:
mode:
authorAllen Byrne <50328838+byrnHDF@users.noreply.github.com>2022-02-21 16:37:04 (GMT)
committerGitHub <noreply@github.com>2022-02-21 16:37:04 (GMT)
commitc7d800e5e526e2dcc2fd19cd0c75d2ef92f184bc (patch)
treeaa6df876c2d6da6f35f531fd025589e60f9e2b8d /tools/test
parent1c9f219463e236487a27cee6cb839379d670cda4 (diff)
downloadhdf5-c7d800e5e526e2dcc2fd19cd0c75d2ef92f184bc.zip
hdf5-c7d800e5e526e2dcc2fd19cd0c75d2ef92f184bc.tar.gz
hdf5-c7d800e5e526e2dcc2fd19cd0c75d2ef92f184bc.tar.bz2
1.12 Fix tools incompatibility (#1448)
* fix tools incompatibility with get_option #1443 * Fix get_option function * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'tools/test')
-rw-r--r--tools/test/h5jam/getub.c16
-rw-r--r--tools/test/h5jam/tellub.c12
-rw-r--r--tools/test/perform/pio_standalone.c57
-rw-r--r--tools/test/perform/pio_standalone.h11
-rw-r--r--tools/test/perform/sio_standalone.c57
-rw-r--r--tools/test/perform/sio_standalone.h11
-rw-r--r--tools/test/perform/zip_perf.c30
7 files changed, 101 insertions, 93 deletions
diff --git a/tools/test/h5jam/getub.c b/tools/test/h5jam/getub.c
index 4e67e98..562a6b9 100644
--- a/tools/test/h5jam/getub.c
+++ b/tools/test/h5jam/getub.c
@@ -21,9 +21,9 @@ void parse_command_line(int argc, const char *const *argv);
#define PROGRAM_NAME "getub"
char *nbytes = NULL;
-static const char * s_opts = "c:"; /* add more later ? */
-static struct h5_long_options l_opts[] = {{"c", require_arg, 'c'}, /* input file */
- {NULL, 0, '\0'}};
+static const char * s_opts = "c:"; /* add more later ? */
+static struct long_options l_opts[] = {{"c", require_arg, 'c'}, /* input file */
+ {NULL, 0, '\0'}};
/*-------------------------------------------------------------------------
* Function: usage
@@ -57,10 +57,10 @@ parse_command_line(int argc, const char *const *argv)
int opt;
/* parse command line options */
- while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch ((char)opt) {
case 'c':
- nbytes = HDstrdup(H5_optarg);
+ nbytes = HDstrdup(opt_arg);
break;
case '?':
default:
@@ -69,7 +69,7 @@ parse_command_line(int argc, const char *const *argv)
} /* end switch */
} /* end while */
- if (argc <= H5_optind) {
+ if (argc <= opt_ind) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
HDexit(EXIT_FAILURE);
@@ -100,13 +100,13 @@ main(int argc, char *argv[])
goto error;
} /* end if */
- if (argc <= (H5_optind)) {
+ if (argc <= (opt_ind)) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
goto error;
} /* end if */
- filename = HDstrdup(argv[H5_optind]);
+ filename = HDstrdup(argv[opt_ind]);
size = 0;
if (EOF == (res = HDsscanf(nbytes, "%u", &size))) {
diff --git a/tools/test/h5jam/tellub.c b/tools/test/h5jam/tellub.c
index f264d9b..d608df5 100644
--- a/tools/test/h5jam/tellub.c
+++ b/tools/test/h5jam/tellub.c
@@ -24,8 +24,8 @@
* parameters. The long-named ones can be partially spelled. When
* adding more, make sure that they don't clash with each other.
*/
-static const char * s_opts = "h";
-static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"hel", no_arg, 'h'}, {NULL, 0, '\0'}};
+static const char * s_opts = "h";
+static struct long_options l_opts[] = {{"help", no_arg, 'h'}, {"hel", no_arg, 'h'}, {NULL, 0, '\0'}};
/*-------------------------------------------------------------------------
* Function: usage
@@ -61,7 +61,7 @@ parse_command_line(int argc, const char *const *argv)
int opt;
/* parse command line options */
- while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch ((char)opt) {
case 'h':
usage(h5tools_getprogname());
@@ -75,7 +75,7 @@ parse_command_line(int argc, const char *const *argv)
}
/* check for file name to be processed */
- if (argc <= H5_optind) {
+ if (argc <= opt_ind) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
@@ -118,14 +118,14 @@ main(int argc, char *argv[])
/* enable error reporting if command line option */
h5tools_error_report();
- if (argc <= (H5_optind)) {
+ if (argc <= (opt_ind)) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- ifname = HDstrdup(argv[H5_optind]);
+ ifname = HDstrdup(argv[opt_ind]);
testval = H5Fis_accessible(ifname, H5P_DEFAULT);
diff --git a/tools/test/perform/pio_standalone.c b/tools/test/perform/pio_standalone.c
index 9ea47d6..b4680a4 100644
--- a/tools/test/perform/pio_standalone.c
+++ b/tools/test/perform/pio_standalone.c
@@ -22,26 +22,31 @@
/* global variables */
int nCols = 80;
+/* ``get_option'' variables */
+int opt_err = 1; /*get_option prints errors if this is on */
+int opt_ind = 1; /*token pointer */
+const char *opt_arg; /*flag argument (or value) */
+
int
-get_option(int argc, char **argv, const char *opts, const struct h5_long_options *l_opts)
+get_option(int argc, const char *const *argv, const char *opts, const struct long_options *l_opts)
{
static int sp = 1; /* character index in current token */
int opt_opt = '?'; /* option character passed back to user */
if (sp == 1) {
/* check for more flag-like tokens */
- if (H5_optind >= argc || argv[H5_optind][0] != '-' || argv[H5_optind][1] == '\0') {
+ if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') {
return EOF;
}
- else if (HDstrcmp(argv[H5_optind], "--") == 0) {
- H5_optind++;
+ else if (HDstrcmp(argv[opt_ind], "--") == 0) {
+ opt_ind++;
return EOF;
}
}
- if (sp == 1 && argv[H5_optind][0] == '-' && argv[H5_optind][1] == '-') {
+ if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') {
/* long command line option */
- const char *arg = &argv[H5_optind][2];
+ const char *arg = &argv[opt_ind][2];
int i;
for (i = 0; l_opts && l_opts[i].name; i++) {
@@ -53,13 +58,13 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options
if (l_opts[i].has_arg != no_arg) {
if (arg[len] == '=') {
- H5_optarg = &arg[len + 1];
+ opt_arg = &arg[len + 1];
}
- else if (H5_optind < (argc - 1) && argv[H5_optind + 1][0] != '-') {
- H5_optarg = argv[++H5_optind];
+ else if (opt_ind < (argc - 1) && argv[opt_ind + 1][0] != '-') {
+ opt_arg = argv[++opt_ind];
}
else if (l_opts[i].has_arg == require_arg) {
- if (H5_opterr)
+ if (opt_err)
HDfprintf(stderr, "%s: option required for \"--%s\" flag\n", argv[0], arg);
opt_opt = '?';
@@ -67,13 +72,13 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options
}
else {
if (arg[len] == '=') {
- if (H5_opterr)
+ if (opt_err)
HDfprintf(stderr, "%s: no option required for \"%s\" flag\n", argv[0], arg);
opt_opt = '?';
}
- H5_optarg = NULL;
+ opt_arg = NULL;
}
break;
@@ -82,29 +87,29 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options
if (l_opts[i].name == NULL) {
/* exhausted all of the l_opts we have and still didn't match */
- if (H5_opterr)
+ if (opt_err)
HDfprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg);
opt_opt = '?';
}
- H5_optind++;
+ opt_ind++;
sp = 1;
}
else {
register char *cp; /* pointer into current token */
/* short command line option */
- opt_opt = argv[H5_optind][sp];
+ opt_opt = argv[opt_ind][sp];
if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) {
- if (H5_opterr)
+ if (opt_err)
HDfprintf(stderr, "%s: unknown option \"%c\"\n", argv[0], opt_opt);
/* if no chars left in this token, move to next token */
- if (argv[H5_optind][++sp] == '\0') {
- H5_optind++;
+ if (argv[opt_ind][++sp] == '\0') {
+ opt_ind++;
sp = 1;
}
@@ -113,32 +118,32 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options
if (*++cp == ':') {
/* if a value is expected, get it */
- if (argv[H5_optind][sp + 1] != '\0') {
+ if (argv[opt_ind][sp + 1] != '\0') {
/* flag value is rest of current token */
- H5_optarg = &argv[H5_optind++][sp + 1];
+ opt_arg = &argv[opt_ind++][sp + 1];
}
- else if (++H5_optind >= argc) {
- if (H5_opterr)
+ else if (++opt_ind >= argc) {
+ if (opt_err)
HDfprintf(stderr, "%s: value expected for option \"%c\"\n", argv[0], opt_opt);
opt_opt = '?';
}
else {
/* flag value is next token */
- H5_optarg = argv[H5_optind++];
+ opt_arg = argv[opt_ind++];
}
sp = 1;
}
else {
/* set up to look at next char in token, next time */
- if (argv[H5_optind][++sp] == '\0') {
+ if (argv[opt_ind][++sp] == '\0') {
/* no more in current token, so setup next token */
- H5_optind++;
+ opt_ind++;
sp = 1;
}
- H5_optarg = NULL;
+ opt_arg = NULL;
}
}
diff --git a/tools/test/perform/pio_standalone.h b/tools/test/perform/pio_standalone.h
index 5cc9a63..1b83e21 100644
--- a/tools/test/perform/pio_standalone.h
+++ b/tools/test/perform/pio_standalone.h
@@ -465,9 +465,9 @@ extern char * strdup(const char *s);
/** From h5tools_utils.h **/
-H5_DLLVAR int H5_opterr; /* getoption prints errors if this is on */
-H5_DLLVAR int H5_optind; /* token pointer */
-H5_DLLVAR const char *H5_optarg; /* flag argument (or value) */
+extern int opt_err; /* getoption prints errors if this is on */
+extern int opt_ind; /* token pointer */
+extern const char *opt_arg; /* flag argument (or value) */
enum h5_arg_level {
no_arg = 0, /* doesn't take an argument */
@@ -475,7 +475,7 @@ enum h5_arg_level {
optional_arg /* argument is optional */
};
-struct h5_long_options {
+struct long_options {
const char * name; /* Name of the long option */
enum h5_arg_level has_arg; /* Whether we should look for an arg */
char shortval; /* The shortname equivalent of long arg
@@ -483,8 +483,7 @@ struct h5_long_options {
*/
};
-extern int H5_get_option(int argc, const char *const *argv, const char *opt,
- const struct h5_long_options *l_opt);
+extern int get_option(int argc, const char *const *argv, const char *opt, const struct long_options *l_opt);
extern int nCols; /*max number of columns for outputting */
diff --git a/tools/test/perform/sio_standalone.c b/tools/test/perform/sio_standalone.c
index ace6b7e..21a2fb5 100644
--- a/tools/test/perform/sio_standalone.c
+++ b/tools/test/perform/sio_standalone.c
@@ -22,26 +22,31 @@
/* global variables */
int nCols = 80;
+/* ``get_option'' variables */
+int opt_err = 1; /*get_option prints errors if this is on */
+int opt_ind = 1; /*token pointer */
+const char *opt_arg; /*flag argument (or value) */
+
int
-get_option(int argc, char **argv, const char *opts, const struct h5_long_options *l_opts)
+get_option(int argc, const char *const *argv, const char *opts, const struct long_options *l_opts)
{
static int sp = 1; /* character index in current token */
int opt_opt = '?'; /* option character passed back to user */
if (sp == 1) {
/* check for more flag-like tokens */
- if (H5_optind >= argc || argv[H5_optind][0] != '-' || argv[H5_optind][1] == '\0') {
+ if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') {
return EOF;
}
- else if (HDstrcmp(argv[H5_optind], "--") == 0) {
- H5_optind++;
+ else if (HDstrcmp(argv[opt_ind], "--") == 0) {
+ opt_ind++;
return EOF;
}
}
- if (sp == 1 && argv[H5_optind][0] == '-' && argv[H5_optind][1] == '-') {
+ if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') {
/* long command line option */
- const char *arg = &argv[H5_optind][2];
+ const char *arg = &argv[opt_ind][2];
int i;
for (i = 0; l_opts && l_opts[i].name; i++) {
@@ -53,13 +58,13 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options
if (l_opts[i].has_arg != no_arg) {
if (arg[len] == '=') {
- H5_optarg = &arg[len + 1];
+ opt_arg = &arg[len + 1];
}
- else if (H5_optind < (argc - 1) && argv[H5_optind + 1][0] != '-') {
- H5_optarg = argv[++H5_optind];
+ else if (opt_ind < (argc - 1) && argv[opt_ind + 1][0] != '-') {
+ opt_arg = argv[++opt_ind];
}
else if (l_opts[i].has_arg == require_arg) {
- if (H5_opterr)
+ if (opt_err)
HDfprintf(stderr, "%s: option required for \"--%s\" flag\n", argv[0], arg);
opt_opt = '?';
@@ -67,13 +72,13 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options
}
else {
if (arg[len] == '=') {
- if (H5_opterr)
+ if (opt_err)
HDfprintf(stderr, "%s: no option required for \"%s\" flag\n", argv[0], arg);
opt_opt = '?';
}
- H5_optarg = NULL;
+ opt_arg = NULL;
}
break;
@@ -82,29 +87,29 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options
if (l_opts[i].name == NULL) {
/* exhausted all of the l_opts we have and still didn't match */
- if (H5_opterr)
+ if (opt_err)
HDfprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg);
opt_opt = '?';
}
- H5_optind++;
+ opt_ind++;
sp = 1;
}
else {
register char *cp; /* pointer into current token */
/* short command line option */
- opt_opt = argv[H5_optind][sp];
+ opt_opt = argv[opt_ind][sp];
if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) {
- if (H5_opterr)
+ if (opt_err)
HDfprintf(stderr, "%s: unknown option \"%c\"\n", argv[0], opt_opt);
/* if no chars left in this token, move to next token */
- if (argv[H5_optind][++sp] == '\0') {
- H5_optind++;
+ if (argv[opt_ind][++sp] == '\0') {
+ opt_ind++;
sp = 1;
}
@@ -113,32 +118,32 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options
if (*++cp == ':') {
/* if a value is expected, get it */
- if (argv[H5_optind][sp + 1] != '\0') {
+ if (argv[opt_ind][sp + 1] != '\0') {
/* flag value is rest of current token */
- H5_optarg = &argv[H5_optind++][sp + 1];
+ opt_arg = &argv[opt_ind++][sp + 1];
}
- else if (++H5_optind >= argc) {
- if (H5_opterr)
+ else if (++opt_ind >= argc) {
+ if (opt_err)
HDfprintf(stderr, "%s: value expected for option \"%c\"\n", argv[0], opt_opt);
opt_opt = '?';
}
else {
/* flag value is next token */
- H5_optarg = argv[H5_optind++];
+ opt_arg = argv[opt_ind++];
}
sp = 1;
}
else {
/* set up to look at next char in token, next time */
- if (argv[H5_optind][++sp] == '\0') {
+ if (argv[opt_ind][++sp] == '\0') {
/* no more in current token, so setup next token */
- H5_optind++;
+ opt_ind++;
sp = 1;
}
- H5_optarg = NULL;
+ opt_arg = NULL;
}
}
diff --git a/tools/test/perform/sio_standalone.h b/tools/test/perform/sio_standalone.h
index 2fc644f..cadc00d 100644
--- a/tools/test/perform/sio_standalone.h
+++ b/tools/test/perform/sio_standalone.h
@@ -480,9 +480,9 @@ extern char * strdup(const char *s);
/** From h5tools_utils.h **/
-H5_DLLVAR int H5_opterr; /* getoption prints errors if this is on */
-H5_DLLVAR int H5_optind; /* token pointer */
-H5_DLLVAR const char *H5_optarg; /* flag argument (or value) */
+extern int opt_err; /* getoption prints errors if this is on */
+extern int opt_ind; /* token pointer */
+extern const char *opt_arg; /* flag argument (or value) */
enum h5_arg_level {
no_arg = 0, /* doesn't take an argument */
@@ -490,7 +490,7 @@ enum h5_arg_level {
optional_arg /* argument is optional */
};
-struct h5_long_options {
+struct long_options {
const char * name; /* Name of the long option */
enum h5_arg_level has_arg; /* Whether we should look for an arg */
char shortval; /* The shortname equivalent of long arg
@@ -498,8 +498,7 @@ struct h5_long_options {
*/
};
-extern int H5_get_option(int argc, const char *const *argv, const char *opt,
- const struct h5_long_options *l_opt);
+extern int get_option(int argc, const char *const *argv, const char *opt, const struct long_options *l_opt);
extern int nCols; /*max number of columns for outputting */
diff --git a/tools/test/perform/zip_perf.c b/tools/test/perform/zip_perf.c
index 5db97d1..4c7da15 100644
--- a/tools/test/perform/zip_perf.c
+++ b/tools/test/perform/zip_perf.c
@@ -64,15 +64,15 @@ static void error(const char *fmt, ...);
static void compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
/* commandline options : long and short form */
-static const char * s_opts = "hB:b:c:p:rs:0123456789";
-static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'},
- {"compressability", require_arg, 'c'},
- {"file-size", require_arg, 's'},
- {"max-buffer-size", require_arg, 'B'},
- {"min-buffer-size", require_arg, 'b'},
- {"prefix", require_arg, 'p'},
- {"random-test", no_arg, 'r'},
- {NULL, 0, '\0'}};
+static const char * s_opts = "hB:b:c:p:rs:0123456789";
+static struct long_options l_opts[] = {{"help", no_arg, 'h'},
+ {"compressability", require_arg, 'c'},
+ {"file-size", require_arg, 's'},
+ {"max-buffer-size", require_arg, 'B'},
+ {"min-buffer-size", require_arg, 'b'},
+ {"prefix", require_arg, 'p'},
+ {"random-test", no_arg, 'r'},
+ {NULL, 0, '\0'}};
/*
* Function: error
@@ -500,7 +500,7 @@ main(int argc, char *argv[])
/* Initialize h5tools lib */
h5tools_init();
- while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) > 0) {
+ while ((opt = get_option(argc, (const char *const *)argv, s_opts, l_opts)) > 0) {
switch ((char)opt) {
case '0':
case '1':
@@ -515,13 +515,13 @@ main(int argc, char *argv[])
compress_level = opt - '0';
break;
case 'B':
- max_buf_size = parse_size_directive(H5_optarg);
+ max_buf_size = parse_size_directive(opt_arg);
break;
case 'b':
- min_buf_size = parse_size_directive(H5_optarg);
+ min_buf_size = parse_size_directive(opt_arg);
break;
case 'c':
- compress_percent = (int)HDstrtol(H5_optarg, NULL, 10);
+ compress_percent = (int)HDstrtol(opt_arg, NULL, 10);
if (compress_percent < 0)
compress_percent = 0;
@@ -530,13 +530,13 @@ main(int argc, char *argv[])
break;
case 'p':
- option_prefix = H5_optarg;
+ option_prefix = opt_arg;
break;
case 'r':
random_test = TRUE;
break;
case 's':
- file_size = parse_size_directive(H5_optarg);
+ file_size = parse_size_directive(opt_arg);
break;
case '?':
usage();