diff --git a/tests/check_hashmap.c b/tests/check_hashmap.c index e206b43..21c58d7 100644 --- a/tests/check_hashmap.c +++ b/tests/check_hashmap.c @@ -172,26 +172,24 @@ check_hashmap ( int n = -1; int r = -1; - getopt_foreach(argc, argv, ":s:n:r:") { - case 's': + OPT_START(argc, argv, "s:n:r:") + OPT_OPT('s') { if (0 != prng_seed_from_hex(seed_buf, optarg)) { return -1; } seed = seed_buf; break; - - case 'n': + } + OPT_OPT('n') { n = atoi(optarg); break; - - case 'r': + } + OPT_OPT('r') { r = atoi(optarg); break; - - default: - log_printf("bad option '-%c'", optopt); - return -1; } + OPT_END + if (n < 10 || n > 30) { log_printf("bad size %d", n); return -1; diff --git a/tests/check_lib.c b/tests/check_lib.c index c4e0536..cd571b1 100644 --- a/tests/check_lib.c +++ b/tests/check_lib.c @@ -87,15 +87,12 @@ subcmd_hash ( ) { unsigned long long seed = 0; - getopt_foreach(argc, argv, ":s:") { - case 's': + OPT_START(argc, argv, "s:") + OPT_OPT('s') { seed = strtoull(optarg, NULL, 16); break; - - default: - log_printf("bad option '-%c'", optopt); - return -1; } + OPT_END hash_seed(seed); printf("%016" PRIx64 "\n", hash_digestcb(hash_check_cb, NULL)); @@ -110,22 +107,19 @@ subcmd_prng ( uint64_t seed_buf[4], *seed = NULL; int n = 0; - getopt_foreach(argc, argv, ":s:n:") { - case 's': + OPT_START(argc, argv, "s:n:") + OPT_OPT('s') { if (0 != prng_seed_from_hex(seed_buf, optarg)) { return -1; } seed = seed_buf; break; - - case 'n': + } + OPT_OPT('n') { n = atoi(optarg); break; - - default: - log_printf("bad option '-%c'", optopt); - return -1; } + OPT_END if (0 != prng_seed(seed)) { return -1; diff --git a/tests/check_sandbox.c b/tests/check_sandbox.c index adf95f0..87326c5 100644 --- a/tests/check_sandbox.c +++ b/tests/check_sandbox.c @@ -158,19 +158,17 @@ check_sandbox ( #endif char const *path = NULL; - getopt_foreach(argc, argv, ":d:r") { - case 'd': + OPT_START(argc, argv, "d:r") + OPT_OPT('d') { path = optarg; break; - - case 'r': + } + OPT_OPT('r') { flags |= SANDBOX_READONLY; break; - - default: - log_printf("bad option '-%c'", optopt); - return -1; } + OPT_END + if (path == NULL) { log_puts("path not specified"); return -1; diff --git a/tests/check_watcher.c b/tests/check_watcher.c index 1be1c1e..e86c988 100644 --- a/tests/check_watcher.c +++ b/tests/check_watcher.c @@ -155,15 +155,13 @@ check_watcher ( ) { char const *path = NULL; - getopt_foreach(argc, argv, ":d:") { - case 'd': + OPT_START(argc, argv, "d:") + OPT_OPT('d') { path = optarg; break; - - default: - log_printf("bad option '-%c'", optopt); - return -1; } + OPT_END + if (path == NULL) { log_puts("path not specified"); return -1;