diff options
author | Håvard Pettersen <havardpe@oath.com> | 2022-03-31 11:44:10 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@oath.com> | 2022-04-01 10:24:32 +0000 |
commit | d71f76a73fe54558f613e75a3a8cfd70fc46a7e8 (patch) | |
tree | 7d170e5b792dbf5fed06ff7c7b2db398b6cb64c7 /searchlib/src/tests/transactionlogstress | |
parent | 1bb3dd192f4bcb91e710fe19ca54b2b8935ffb83 (diff) |
use getopt/getopt_long directly
Diffstat (limited to 'searchlib/src/tests/transactionlogstress')
-rw-r--r-- | searchlib/src/tests/transactionlogstress/translogstress.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/searchlib/src/tests/transactionlogstress/translogstress.cpp b/searchlib/src/tests/transactionlogstress/translogstress.cpp index de0e1b60ca0..cfd2138f2e8 100644 --- a/searchlib/src/tests/transactionlogstress/translogstress.cpp +++ b/searchlib/src/tests/transactionlogstress/translogstress.cpp @@ -12,6 +12,7 @@ #include <iostream> #include <sstream> #include <thread> +#include <unistd.h> #include <vespa/log/log.h> #include <vespa/vespalib/util/time.h> @@ -642,44 +643,42 @@ TransLogStress::Main() vespalib::duration sleepTime = 4s; - int idx = 1; int opt; - const char * arg; bool optError = false; - while ((opt = GetOpt("d:p:t:f:s:v:c:e:g:i:a:b:h", arg, idx)) != -1) { + while ((opt = getopt(_argc, _argv, "d:p:t:f:s:v:c:e:g:i:a:b:h")) != -1) { switch (opt) { case 'd': - _cfg.domainPartSize = atol(arg); + _cfg.domainPartSize = atol(optarg); break; case 'p': - _cfg.packetSize = atol(arg); + _cfg.packetSize = atol(optarg); break; case 't': - _cfg.stressTime = std::chrono::milliseconds(1000 * atol(arg)); + _cfg.stressTime = std::chrono::milliseconds(1000 * atol(optarg)); break; case 'f': - _cfg.feedRate = atoi(arg); + _cfg.feedRate = atoi(optarg); break; case 'v': - _cfg.numVisitors = atoi(arg); + _cfg.numVisitors = atoi(optarg); break; case 'c': - _cfg.visitorInterval = std::chrono::milliseconds(atol(arg)); + _cfg.visitorInterval = std::chrono::milliseconds(atol(optarg)); break; case 'e': - _cfg.pruneInterval = vespalib::from_s(atol(arg)); + _cfg.pruneInterval = vespalib::from_s(atol(optarg)); break; case 'g': - _cfg.numPreGeneratedBuffers = atoi(arg); + _cfg.numPreGeneratedBuffers = atoi(optarg); break; case 'i': - _cfg.minStrLen = atoi(arg); + _cfg.minStrLen = atoi(optarg); break; case 'a': - _cfg.maxStrLen = atoi(arg); + _cfg.maxStrLen = atoi(optarg); break; case 'b': - _cfg.baseSeed = atol(arg); + _cfg.baseSeed = atol(optarg); break; case 'h': usage(); @@ -693,7 +692,7 @@ TransLogStress::Main() printConfig(); std::this_thread::sleep_for(sleepTime); - if (_argc != idx || optError) { + if (_argc != optind || optError) { usage(); return -1; } |