diff options
Diffstat (limited to 'test/usecase_common.c')
-rw-r--r-- | test/usecase_common.c | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/test/usecase_common.c b/test/usecase_common.c index 0230644..d2d2aa5 100644 --- a/test/usecase_common.c +++ b/test/usecase_common.c @@ -19,9 +19,11 @@ usage(const char *prog) { fprintf(stderr, "usage: %s [OPTIONS]\n", prog); fprintf(stderr, " OPTIONS\n"); - fprintf(stderr, " -h, --help Print a usage message and exit\n"); - fprintf(stderr, " -z N, --chunksize=N Chunk size [default: %d]\n", Chunksize_DFT); - fprintf(stderr, " -s N, --swmr=N Use SWMR mode (0: no, non-0: yes) default is yes\n"); + fprintf(stderr, " -h, --help Print a usage message and exit\n"); + fprintf(stderr, " -f FN Test file name [default: %s.h5]\n", prog); + fprintf(stderr, " -l w|r launch writer or reader only. [default: launch both]\n"); + fprintf(stderr, " -s N, --swmr=N Use SWMR mode (0: no, non-0: yes) default is yes\n"); + fprintf(stderr, " -z N, --chunksize=N Chunk size [default: %d]\n", Chunksize_DFT); fprintf(stderr, "\n"); } @@ -33,7 +35,7 @@ parse_option(int argc, char * const argv[]) int ret_value=0; int c; /* command line options: See function usage for a description */ - const char *nagg_options = "hs:z:"; + const char *nagg_options = "f:hl:s:z:"; /* suppress getopt from printing error */ opterr = 0; @@ -46,17 +48,34 @@ parse_option(int argc, char * const argv[]) case 'h': usage(progname_g); break; - case 'z': /* size of chunk=(z,z) */ - if ((UC_opts.chunksize = atoi(optarg)) <= 0){ - fprintf(stderr, "bad chunksize %s, must be a positive integer\n", optarg); + case 'f': /* usecase data file name */ + UC_opts.filename = optarg; + break; + case 'l': /* launch reader or writer only */ + switch (*optarg) { + case 'r': /* reader only */ + UC_opts.launch = UC_READER; + break; + case 'w': /* writer only */ + UC_opts.launch = UC_WRITER; + break; + default: + fprintf(stderr, "launch value(%c) should be w or r only.\n", *optarg); usage(progname_g); Hgoto_error(-1); - }; + break; + } break; case 's': /* use swmr file open mode */ - UC_opts.use_swmr=0; if ((UC_opts.use_swmr = atoi(optarg)) < 0){ - fprintf(stderr, "use swmr value should be 0(no) or 1(yes)\n"); + fprintf(stderr, "swmr value should be 0(no) or 1(yes)\n"); + usage(progname_g); + Hgoto_error(-1); + }; + break; + case 'z': /* size of chunk=(z,z) */ + if ((UC_opts.chunksize = atoi(optarg)) <= 0){ + fprintf(stderr, "bad chunksize %s, must be a positive integer\n", optarg); usage(progname_g); Hgoto_error(-1); }; @@ -75,6 +94,17 @@ parse_option(int argc, char * const argv[]) if (UC_opts.nplanes == 0) UC_opts.nplanes = UC_opts.chunksize; + /* set test file name if not given */ + if (!UC_opts.filename){ + /* default data file name is <progname>.h5 */ + if ((UC_opts.filename=(char*)HDmalloc(HDstrlen(progname_g)+4))==NULL) { + fprintf(stderr, "malloc: failed\n"); + Hgoto_error(-1); + }; + HDstrcpy(UC_opts.filename, progname_g); + HDstrcat(UC_opts.filename, ".h5"); + } + done: /* All done. */ return(ret_value); |