From 9fbcf76d088740aacf535e6482f86c833cfae871 Mon Sep 17 00:00:00 2001 From: HÃ¥vard Pettersen Date: Wed, 6 Apr 2022 12:18:08 +0000 Subject: remove FastOS_Application fixup (per application): - maybe ignore SIGPIPE - wire argc/argv untangle Vespa Test Framework strip down deprecated TestApp --- config/src/apps/vespa-configproxy-cmd/main.cpp | 33 ++-- config/src/apps/vespa-get-config/getconfig.cpp | 28 +-- .../src/apps/vespa-ping-configproxy/pingproxy.cpp | 28 +-- configutil/src/apps/configstatus/main.cpp | 29 ++-- configutil/src/apps/modelinspect/main.cpp | 39 ++--- fastlib/src/vespa/fastlib/testsuite/suite.h | 6 +- fastlib/src/vespa/fastlib/testsuite/test.h | 5 +- .../fastlib/text/apps/unicode_propertydump.cpp | 12 +- .../fastlib/text/apps/unicode_tolowerdump.cpp | 12 +- .../fastlib/text/tests/latintokenizertest.cpp | 5 +- .../vespa/fastlib/text/tests/latintokenizertest.h | 12 -- .../vespa/fastlib/text/tests/unicodeutiltest.cpp | 5 +- .../src/vespa/fastlib/text/tests/unicodeutiltest.h | 7 - .../vespa/fastlib/text/tests/wordfolderstest.cpp | 5 +- .../src/vespa/fastlib/text/tests/wordfolderstest.h | 7 - fastos/src/tests/coretest.cpp | 68 -------- fastos/src/tests/tests.h | 17 +- fastos/src/tests/typetest.cpp | 1 - fastos/src/vespa/fastos/CMakeLists.txt | 2 - fastos/src/vespa/fastos/app.cpp | 59 ------- fastos/src/vespa/fastos/app.h | 193 --------------------- fastos/src/vespa/fastos/thread.h | 14 -- fastos/src/vespa/fastos/unix_app.cpp | 50 ------ fastos/src/vespa/fastos/unix_app.h | 29 ---- fnet/src/examples/frt/rpc/echo_client.cpp | 19 +- fnet/src/examples/frt/rpc/rpc_callback_client.cpp | 19 +- fnet/src/examples/frt/rpc/rpc_callback_server.cpp | 19 +- fnet/src/examples/frt/rpc/rpc_client.cpp | 19 +- fnet/src/examples/frt/rpc/rpc_info.cpp | 23 ++- fnet/src/examples/frt/rpc/rpc_invoke.cpp | 37 ++-- fnet/src/examples/frt/rpc/rpc_server.cpp | 32 +--- fnet/src/examples/ping/pingclient.cpp | 25 ++- fnet/src/examples/ping/pingserver.cpp | 22 ++- fnet/src/examples/timeout/timeout.cpp | 17 +- .../src/jrt-test/simpleserver/simpleserver.cpp | 28 +-- jrt_test/src/tests/echo/echo-client.cpp | 19 +- .../tests/mandatory-methods/extract-reflection.cpp | 25 ++- jrt_test/src/tests/mockup-invoke/mockup-server.cpp | 28 +-- juniper/src/test/SrcTestSuite.cpp | 17 +- juniper/src/test/auxTestApp.cpp | 17 +- juniper/src/test/matchobjectTestApp.cpp | 25 +-- juniper/src/test/mcandTestApp.cpp | 25 +-- juniper/src/test/queryparserTestApp.cpp | 24 +-- juniper/src/test/testenv.cpp | 10 +- juniper/src/test/testenv.h | 3 +- messagebus_test/src/tests/error/cpp-client.cpp | 11 +- messagebus_test/src/tests/error/cpp-server.cpp | 18 +- messagebus_test/src/tests/errorcodes/dumpcodes.cpp | 11 +- messagebus_test/src/tests/speed/cpp-client.cpp | 11 +- messagebus_test/src/tests/speed/cpp-server.cpp | 18 +- messagebus_test/src/tests/trace/cpp-server.cpp | 19 +- searchcore/src/apps/proton/proton.cpp | 25 ++- .../src/apps/verify_ranksetup/verify_ranksetup.cpp | 15 +- .../src/apps/vespa-dump-feed/vespa-dump-feed.cpp | 16 +- .../src/apps/vespa-feed-bm/vespa_feed_bm.cpp | 25 ++- .../apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp | 84 +++------ .../src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp | 50 +++--- .../vespa_redistribute_bm.cpp | 25 ++- .../vespa-transactionlog-inspect.cpp | 65 ++++--- .../proton/feed_and_search/feed_and_search.cpp | 2 +- .../src/tests/proton/matching/query_test.cpp | 22 +-- searchlib/src/apps/docstore/benchmarkdatastore.cpp | 43 +++-- .../src/apps/docstore/create-idx-from-dat.cpp | 29 ++-- .../src/apps/docstore/documentstoreinspect.cpp | 41 +++-- searchlib/src/apps/docstore/verifylogdatastore.cpp | 27 +-- searchlib/src/apps/uniform/uniform.cpp | 15 +- .../vespa-attribute-inspect.cpp | 20 +-- .../vespa-fileheader-inspect.cpp | 33 ++-- .../vespa-index-inspect/vespa-index-inspect.cpp | 79 ++++----- .../vespa-ranking-expression-analyzer.cpp | 25 +-- .../attribute/benchmark/attributebenchmark.cpp | 20 +-- .../src/tests/bitvector/bitvectorbenchmark.cpp | 18 +- .../diskindex/fieldwriter/fieldwriter_test.cpp | 20 +-- .../tests/diskindex/pagedict4/pagedict4test.cpp | 28 +-- .../src/tests/postinglistbm/postinglistbm.cpp | 17 +- .../tests/transactionlogstress/translogstress.cpp | 18 +- .../src/tests/docsumformat/docsum-pack.cpp | 15 +- .../src/tests/docsummary/positionsdfw_test.cpp | 14 +- .../tests/extractkeywords/extractkeywordstest.cpp | 19 +- .../tests/extractkeywords/extractkeywordstest.h | 6 +- slobrok/src/apps/check_slobrok/check_slobrok.cpp | 30 ++-- slobrok/src/apps/sbcmd/sbcmd.cpp | 70 ++++---- slobrok/src/apps/slobrok/slobrok.cpp | 17 +- slobrok/src/tests/startsome/rpc_info.cpp | 23 ++- slobrok/src/tests/startsome/tstdst.cpp | 15 +- storage/src/vespa/storage/tools/storage-cmd.cpp | 33 ++-- storageserver/src/apps/storaged/storage.cpp | 25 +-- vbench/src/apps/dumpurl/dumpurl.cpp | 22 +-- .../src/vespa/vespaclient/vdsstates/statesapp.cpp | 16 +- .../vespa/vespaclient/vesparoute/application.cpp | 76 ++++---- .../src/vespa/vespaclient/vesparoute/application.h | 7 +- .../src/vespa/vespaclient/vesparoute/main.cpp | 6 +- .../btree-scan-speed/btree_scan_speed_test.cpp | 14 +- vespalib/src/tests/btree/iteratespeed.cpp | 17 +- vespalib/src/vespa/vespalib/testkit/test_macros.h | 25 +-- .../src/vespa/vespalib/testkit/test_master.cpp | 2 + vespalib/src/vespa/vespalib/testkit/testapp.cpp | 23 +-- vespalib/src/vespa/vespalib/testkit/testapp.h | 166 +----------------- vespalib/src/vespa/vespalib/util/backtrace.cpp | 4 +- vespalog/src/test/threads/testthreads.cpp | 12 +- 100 files changed, 913 insertions(+), 1713 deletions(-) delete mode 100644 fastos/src/tests/coretest.cpp delete mode 100644 fastos/src/vespa/fastos/app.cpp delete mode 100644 fastos/src/vespa/fastos/app.h delete mode 100644 fastos/src/vespa/fastos/unix_app.cpp delete mode 100644 fastos/src/vespa/fastos/unix_app.h diff --git a/config/src/apps/vespa-configproxy-cmd/main.cpp b/config/src/apps/vespa-configproxy-cmd/main.cpp index 2af645b9351..28ebf454084 100644 --- a/config/src/apps/vespa-configproxy-cmd/main.cpp +++ b/config/src/apps/vespa-configproxy-cmd/main.cpp @@ -2,26 +2,26 @@ #include "proxycmd.h" #include "methods.h" -#include +#include #include #include -class Application : public FastOS_Application +class Application { Flags _flags; - bool parseOpts(); + bool parseOpts(int argc, char **argv); public: void usage(); - int Main() override; + int main(int argc, char **argv); Application() : _flags() {} }; bool -Application::parseOpts() +Application::parseOpts(int argc, char **argv) { int c = '?'; - while ((c = getopt(_argc, _argv, "m:s:p:h")) != -1) { + while ((c = getopt(argc, argv, "m:s:p:h")) != -1) { switch (c) { case 'm': _flags.method = optarg; @@ -38,18 +38,18 @@ Application::parseOpts() } } const Method method = methods::find(_flags.method); - if (optind + method.args <= _argc) { + if (optind + method.args <= argc) { for (int i = 0; i < method.args; ++i) { - vespalib::string arg = _argv[optind++]; + vespalib::string arg = argv[optind++]; _flags.args.push_back(arg); } } else { std::cerr << "ERROR: method "<< _flags.method << " requires " << method.args - << " arguments, only got " << (_argc - optind) << std::endl; + << " arguments, only got " << (argc - optind) << std::endl; return false; } - if (optind != _argc) { - std::cerr << "ERROR: "<<(_argc - optind)<<" extra arguments\n"; + if (optind != argc) { + std::cerr << "ERROR: "<<(argc - optind)<<" extra arguments\n"; return false; } _flags.method = method.rpcMethod; @@ -69,9 +69,9 @@ Application::usage(void) } int -Application::Main(void) +Application::main(int argc, char **argv) { - if (! parseOpts()) { + if (! parseOpts(argc, argv)) { usage(); return 1; } @@ -79,9 +79,8 @@ Application::Main(void) return client.action(); } -int -main(int argc, char** argv) -{ +int main(int argc, char** argv) { + vespalib::SignalHandler::PIPE.ignore(); Application app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/config/src/apps/vespa-get-config/getconfig.cpp b/config/src/apps/vespa-get-config/getconfig.cpp index e62521d8db1..74380390095 100644 --- a/config/src/apps/vespa-get-config/getconfig.cpp +++ b/config/src/apps/vespa-get-config/getconfig.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -22,7 +22,7 @@ LOG_SETUP("vespa-get-config"); using namespace config; -class GetConfig : public FastOS_Application +class GetConfig { private: std::unique_ptr _server; @@ -33,11 +33,11 @@ private: public: GetConfig() : _server(), _target(nullptr) {} - ~GetConfig() override; - int usage(); + ~GetConfig(); + int usage(const char *self); void initRPC(const char *spec); void finiRPC(); - int Main() override; + int main(int argc, char **argv); }; @@ -49,9 +49,9 @@ GetConfig::~GetConfig() int -GetConfig::usage() +GetConfig::usage(const char *self) { - fprintf(stderr, "usage: %s -n name -i configId\n", _argv[0]); + fprintf(stderr, "usage: %s -n name -i configId\n", self); fprintf(stderr, "-n name (config name, including namespace, on the form .)\n"); fprintf(stderr, "-i configId (config id, optional)\n"); fprintf(stderr, "-j (output config as json, optional)\n"); @@ -92,7 +92,7 @@ GetConfig::finiRPC() int -GetConfig::Main() +GetConfig::main(int argc, char **argv) { bool debugging = false; int c = -1; @@ -118,7 +118,7 @@ GetConfig::Main() int serverPort = 19090; - while ((c = getopt(_argc, _argv, "a:n:v:g:i:jlm:c:t:V:w:r:s:p:dh")) != -1) { + while ((c = getopt(argc, argv, "a:n:v:g:i:jlm:c:t:V:w:r:s:p:dh")) != -1) { int retval = 1; switch (c) { case 'a': @@ -170,13 +170,13 @@ GetConfig::Main() [[fallthrough]]; case '?': default: - usage(); + usage(argv[0]); return retval; } } if (defName == nullptr || serverPort == 0) { - usage(); + usage(argv[0]); return 1; } @@ -275,8 +275,8 @@ GetConfig::Main() return 0; } -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); GetConfig app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/config/src/apps/vespa-ping-configproxy/pingproxy.cpp b/config/src/apps/vespa-ping-configproxy/pingproxy.cpp index 92d07b743f5..e8423eba233 100644 --- a/config/src/apps/vespa-ping-configproxy/pingproxy.cpp +++ b/config/src/apps/vespa-ping-configproxy/pingproxy.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -12,7 +12,7 @@ LOG_SETUP("vespa-ping-configproxy"); -class PingProxy : public FastOS_Application +class PingProxy { private: std::unique_ptr _server; @@ -22,11 +22,11 @@ public: PingProxy(const PingProxy &) = delete; PingProxy &operator=(const PingProxy &) = delete; PingProxy() : _server(), _target(nullptr) {} - ~PingProxy() override ; - int usage(); + ~PingProxy(); + int usage(const char *self); void initRPC(const char *spec); void finiRPC(); - int Main() override; + int main(int argc, char **argv); }; @@ -38,9 +38,9 @@ PingProxy::~PingProxy() int -PingProxy::usage() +PingProxy::usage(const char *self) { - fprintf(stderr, "usage: %s\n", _argv[0]); + fprintf(stderr, "usage: %s\n", self); fprintf(stderr, "-s [server] (server hostname, default localhost)\n"); fprintf(stderr, "-p [port] (server port number, default 19090)\n"); return 1; @@ -67,7 +67,7 @@ PingProxy::finiRPC() int -PingProxy::Main() +PingProxy::main(int argc, char **argv) { int retval = 0; bool debugging = false; @@ -77,7 +77,7 @@ PingProxy::Main() int clientTimeout = 5; int serverPort = 19090; - while ((c = getopt(_argc, _argv, "w:s:p:dh")) != -1) { + while ((c = getopt(argc, argv, "w:s:p:dh")) != -1) { switch (c) { case 'w': clientTimeout = atoi(optarg); @@ -96,13 +96,13 @@ PingProxy::Main() retval = 1; [[fallthrough]]; case 'h': - usage(); + usage(argv[0]); return retval; } } if (serverPort == 0) { - usage(); + usage(argv[0]); return 1; } @@ -151,8 +151,8 @@ PingProxy::Main() return retval; } -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); PingProxy app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/configutil/src/apps/configstatus/main.cpp b/configutil/src/apps/configstatus/main.cpp index 6233a9d9bb5..43bce018564 100644 --- a/configutil/src/apps/configstatus/main.cpp +++ b/configutil/src/apps/configstatus/main.cpp @@ -4,23 +4,23 @@ #include #include "lib/configstatus.h" #include -#include +#include #include #include #include LOG_SETUP("vespa-config-status"); -class Application : public FastOS_Application { +class Application { ConfigStatus::Flags _flags; vespalib::string _cfgId; vespalib::string _specString; - int parseOpts(); + int parseOpts(int argc, char **argv); vespalib::string getSources(); HostFilter parse_host_set(vespalib::stringref raw_arg) const; public: - void usage(); - int Main() override; + void usage(const char *self); + int main(int argc, char **argv); Application(); ~Application(); @@ -33,9 +33,9 @@ Application::Application() {} Application::~Application() { } -int Application::parseOpts() { +int Application::parseOpts(int argc, char **argv) { int c = '?'; - while ((c = getopt(_argc, _argv, "c:s:vC:f:")) != -1) { + while ((c = getopt(argc, argv, "c:s:vC:f:")) != -1) { switch (c) { case 'v': _flags.verbose = true; @@ -47,13 +47,13 @@ int Application::parseOpts() { _specString = optarg; break; case 'h': - usage(); + usage(argv[0]); std::_Exit(0); case 'f': _flags.host_filter = parse_host_set(optarg); break; default: - usage(); + usage(argv[0]); std::_Exit(1); } } @@ -74,9 +74,9 @@ HostFilter Application::parse_host_set(vespalib::stringref raw_arg) const { return HostFilter(std::move(hosts)); } -void Application::usage() { +void Application::usage(const char *self) { std::cerr << "vespa-config-status version 1.0\n" - << "Usage: " << _argv[0] << " [options]\n" + << "Usage: " << self << " [options]\n" << "options: [-v] for verbose\n" << " [-c host] or [-c host:port] to specify config server\n" << " [-f host0,...,hostN] filter to only query config\n" @@ -84,8 +84,8 @@ void Application::usage() { << std::endl; } -int Application::Main() { - parseOpts(); +int Application::main(int argc, char **argv) { + parseOpts(argc, argv); fprintf(stderr, "Getting config from: %s\n", _specString.c_str()); config::ServerSpec spec(_specString); config::ConfigUri uri = config::ConfigUri::createFromSpec(_cfgId, spec); @@ -104,6 +104,7 @@ vespalib::string Application::getSources() { } int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); Application app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/configutil/src/apps/modelinspect/main.cpp b/configutil/src/apps/modelinspect/main.cpp index 84893ffdf07..7a15079f320 100644 --- a/configutil/src/apps/modelinspect/main.cpp +++ b/configutil/src/apps/modelinspect/main.cpp @@ -4,24 +4,24 @@ #include "lib/modelinspect.h" #include #include -#include +#include #include #include #include LOG_SETUP("vespa-model-inspect"); -class Application : public FastOS_Application +class Application { ModelInspect::Flags _flags; vespalib::string _cfgId; vespalib::string _specString; - int parseOpts(); + int parseOpts(int argc, char **argv); vespalib::string getSources(); config::ConfigUri getConfigUri(); public: - void usage(); - int Main() override; + void usage(const char *self); + int main(int argc, char **argv); Application(); ~Application(); @@ -31,10 +31,10 @@ Application::Application() : _flags(), _cfgId("admin/model"), _specString("") {} Application::~Application() { } int -Application::parseOpts() +Application::parseOpts(int argc, char **argv) { int c = '?'; - while ((c = getopt(_argc, _argv, "hvut:c:C:")) != -1) { + while ((c = getopt(argc, argv, "hvut:c:C:")) != -1) { switch (c) { case 'v': _flags.verbose = true; @@ -53,9 +53,9 @@ Application::parseOpts() _specString = optarg; break; case 'h': - return _argc; + return argc; default: - usage(); + usage(argv[0]); std::_Exit(1); } } @@ -89,11 +89,11 @@ Application::getConfigUri() } void -Application::usage() +Application::usage(const char *self) { std::cerr << "vespa-model-inspect version 2.0" << std::endl << - "Usage: " << _argv[0] << " [options] " << std::endl << + "Usage: " << self << " [options] " << std::endl << "options: [-u] for URLs, [-v] for verbose" << std::endl << " [-c host] or [-c host:port] to specify server" << std::endl << " [-t tag] to filter on a port tag" << std::endl << @@ -116,23 +116,22 @@ Application::usage() } int -Application::Main() +Application::main(int argc, char **argv) { - int cnt = parseOpts(); - if (_argc == cnt) { - usage(); + int cnt = parseOpts(argc, argv); + if (argc == cnt) { + usage(argv[0]); return 0; } config::ConfigUri uri = getConfigUri(); ModelInspect model(_flags, uri, std::cout); - return model.action(_argc - cnt, &_argv[cnt]); + return model.action(argc - cnt, &argv[cnt]); } -int -main(int argc, char** argv) -{ +int main(int argc, char** argv) { + vespalib::SignalHandler::PIPE.ignore(); vespa::Defaults::bootstrap(argv[0]); Application app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/fastlib/src/vespa/fastlib/testsuite/suite.h b/fastlib/src/vespa/fastlib/testsuite/suite.h index 43a655fab31..fea685731ae 100644 --- a/fastlib/src/vespa/fastlib/testsuite/suite.h +++ b/fastlib/src/vespa/fastlib/testsuite/suite.h @@ -28,10 +28,10 @@ * * * - * class MySuiteApp : public FastOS_Application + * class MySuiteApp * { * public: - * virtual int Main(); + * int Main(); * }; * * @@ -50,8 +50,6 @@ * mts.Free(); * } * - * FASTOS_MAIN(MyTestApp) - * * --- * **************************************************************************/ diff --git a/fastlib/src/vespa/fastlib/testsuite/test.h b/fastlib/src/vespa/fastlib/testsuite/test.h index ed771da04ec..1388c3ba812 100644 --- a/fastlib/src/vespa/fastlib/testsuite/test.h +++ b/fastlib/src/vespa/fastlib/testsuite/test.h @@ -22,10 +22,10 @@ * * }; * - * class MyTestApp : public FastOS_Application + * class MyTestApp * { * public: - * virtual int Main(); + * int Main(); * }; * * @@ -46,7 +46,6 @@ * return 0; * } * - * FASTOS_MAIN(MyTestApp) * * ---- * diff --git a/fastlib/src/vespa/fastlib/text/apps/unicode_propertydump.cpp b/fastlib/src/vespa/fastlib/text/apps/unicode_propertydump.cpp index 551c86cff2e..5f2b6089cdf 100644 --- a/fastlib/src/vespa/fastlib/text/apps/unicode_propertydump.cpp +++ b/fastlib/src/vespa/fastlib/text/apps/unicode_propertydump.cpp @@ -1,20 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include -#include -class UnicodePropertyDumpApp : public FastOS_Application -{ -public: - virtual int Main(); -}; - -int UnicodePropertyDumpApp::Main() -{ +int main(int argc, char **argv) { for (ucs4_t testchar = 0; testchar < 0x10000; testchar++) { printf("%08x %04x\n", testchar, Fast_UnicodeUtil::GetProperty(testchar)); } return 0; } - -FASTOS_MAIN(UnicodePropertyDumpApp) diff --git a/fastlib/src/vespa/fastlib/text/apps/unicode_tolowerdump.cpp b/fastlib/src/vespa/fastlib/text/apps/unicode_tolowerdump.cpp index f9a88e71008..7d84f6e931d 100644 --- a/fastlib/src/vespa/fastlib/text/apps/unicode_tolowerdump.cpp +++ b/fastlib/src/vespa/fastlib/text/apps/unicode_tolowerdump.cpp @@ -1,20 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include -#include -class UnicodeToLowerDumpApp : public FastOS_Application -{ -public: - virtual int Main(); -}; - -int UnicodeToLowerDumpApp::Main() -{ +int main(int argc, char **argv) { for (ucs4_t testchar = 0; testchar < 0x10000; testchar++) { printf("%08x %08x\n", testchar, Fast_UnicodeUtil::ToLower(testchar)); } return 0; } - -FASTOS_MAIN(UnicodeToLowerDumpApp) diff --git a/fastlib/src/vespa/fastlib/text/tests/latintokenizertest.cpp b/fastlib/src/vespa/fastlib/text/tests/latintokenizertest.cpp index cc6f62a0149..89273ab1ec0 100644 --- a/fastlib/src/vespa/fastlib/text/tests/latintokenizertest.cpp +++ b/fastlib/src/vespa/fastlib/text/tests/latintokenizertest.cpp @@ -1,12 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "latintokenizertest.h" -int LatinTokenizerTestApp::Main() -{ +int main(int, char **) { LatinTokenizerTest lta; lta.SetStream(&std::cout); lta.Run(); return lta.Report(); } - -FASTOS_MAIN(LatinTokenizerTestApp); diff --git a/fastlib/src/vespa/fastlib/text/tests/latintokenizertest.h b/fastlib/src/vespa/fastlib/text/tests/latintokenizertest.h index 8b8635db905..38dc08aa677 100644 --- a/fastlib/src/vespa/fastlib/text/tests/latintokenizertest.h +++ b/fastlib/src/vespa/fastlib/text/tests/latintokenizertest.h @@ -4,7 +4,6 @@ #include #include #include -#include class Mapel_Pucntuation { private: @@ -449,14 +448,3 @@ void LatinTokenizerTest::Run() TestTypeparamObservers(); TestMapelURL(); } - - -/** - The FastOS application class. -*/ - -class LatinTokenizerTestApp : public FastOS_Application -{ -public: - int Main() override; -}; diff --git a/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.cpp b/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.cpp index 5398d742042..9e7fa176a8c 100644 --- a/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.cpp +++ b/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.cpp @@ -1,12 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "unicodeutiltest.h" -int UnicodeUtilTestApp::Main() -{ +int main(int, char **) { UnicodeUtilTest t; t.SetStream(&std::cout); t.Run(); return t.Report(); } - -FASTOS_MAIN(UnicodeUtilTestApp) diff --git a/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.h b/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.h index 13bfc5b11f8..da7bae6d313 100644 --- a/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.h +++ b/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.h @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include #include -#include class UnicodeUtilTest : public Test { @@ -46,9 +45,3 @@ public: _test(IsTerminalPunctuationChar()); } }; - -class UnicodeUtilTestApp : public FastOS_Application -{ -public: - int Main() override; -}; diff --git a/fastlib/src/vespa/fastlib/text/tests/wordfolderstest.cpp b/fastlib/src/vespa/fastlib/text/tests/wordfolderstest.cpp index 21d1e0129ba..ea254b3d114 100644 --- a/fastlib/src/vespa/fastlib/text/tests/wordfolderstest.cpp +++ b/fastlib/src/vespa/fastlib/text/tests/wordfolderstest.cpp @@ -1,12 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "wordfolderstest.h" -int WordFoldersTestApp::Main() -{ +int main(int, char **) { WordFoldersTest t; t.SetStream(&std::cout); t.Run(); return t.Report(); } - -FASTOS_MAIN(WordFoldersTestApp) diff --git a/fastlib/src/vespa/fastlib/text/tests/wordfolderstest.h b/fastlib/src/vespa/fastlib/text/tests/wordfolderstest.h index 2ee97be1a00..b82415a9822 100644 --- a/fastlib/src/vespa/fastlib/text/tests/wordfolderstest.h +++ b/fastlib/src/vespa/fastlib/text/tests/wordfolderstest.h @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include #include -#include #include #include @@ -126,9 +125,3 @@ public: _test(AccentRemovalTest()); } }; - -class WordFoldersTestApp : public FastOS_Application -{ -public: - int Main() override; -}; diff --git a/fastos/src/tests/coretest.cpp b/fastos/src/tests/coretest.cpp deleted file mode 100644 index 01742791c58..00000000000 --- a/fastos/src/tests/coretest.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - - - - -static void -bomb(void) -{ - char *p; - - p = nullptr; - *p = 4; -} - -class FastS_Bomber : public FastOS_Runnable -{ - void Run(FastOS_ThreadInterface *thread, void *arg) - { - (void) thread; - (void) arg; - bomb(); - } -}; - -static int -bombMain(void) -{ - FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024); - FastS_Bomber bomber; - FastOS_ThreadInterface *thread; - - thread = pool->NewThread(&bomber, nullptr); - if (thread != nullptr) - thread->Join(); - - pool->Close(); - delete pool; - return (0); -} - - -class FastS_CoreTestApp : public FastOS_Application -{ -public: - FastS_CoreTestApp(void) { } - ~FastS_CoreTestApp(void) { } - int Main(void); -}; - - -int -FastS_CoreTestApp::Main(void) -{ - - return bombMain(); -} - - -int -main(int argc, char **argv) -{ - FastS_CoreTestApp app; - setvbuf(stdout, nullptr, _IOLBF, 8192); - if (argc == 1) - return app.Entry(argc, argv); - else - return bombMain(); -} diff --git a/fastos/src/tests/tests.h b/fastos/src/tests/tests.h index e93081eaa53..3a6f2ef9010 100644 --- a/fastos/src/tests/tests.h +++ b/fastos/src/tests/tests.h @@ -1,10 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include #include #include +#include -class BaseTest : public FastOS_Application +class BaseTest { private: BaseTest(const BaseTest&); @@ -13,17 +13,30 @@ private: int totallen; bool _allOkFlag; public: + int _argc; + char **_argv; + const char *okString; const char *failString; BaseTest () : totallen(70), _allOkFlag(true), + _argc(0), + _argv(nullptr), okString("SUCCESS"), failString("FAILURE") { } + virtual int Main() = 0; + + int Entry(int argc, char **argv) { + _argc = argc; + _argv = argv; + return Main(); + } + virtual ~BaseTest() {}; bool allWasOk() const { return _allOkFlag; } diff --git a/fastos/src/tests/typetest.cpp b/fastos/src/tests/typetest.cpp index ee7f88026bc..e5d7e9ceb74 100644 --- a/fastos/src/tests/typetest.cpp +++ b/fastos/src/tests/typetest.cpp @@ -11,7 +11,6 @@ private: { TestHeader("Object Sizes (bytes)"); - Progress(true, "FastOS_Application: %d", sizeof(FastOS_Application)); Progress(true, "FastOS_DirectoryScan %d", sizeof(FastOS_DirectoryScan)); Progress(true, "FastOS_File: %d", sizeof(FastOS_File)); Progress(true, "FastOS_Runnable %d", sizeof(FastOS_Runnable)); diff --git a/fastos/src/vespa/fastos/CMakeLists.txt b/fastos/src/vespa/fastos/CMakeLists.txt index 605b1e40a38..e4274261951 100644 --- a/fastos/src/vespa/fastos/CMakeLists.txt +++ b/fastos/src/vespa/fastos/CMakeLists.txt @@ -1,13 +1,11 @@ # Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_library(fastos_objects OBJECT SOURCES - app.cpp backtrace.c file.cpp file_rw_ops.cpp linux_file.cpp thread.cpp - unix_app.cpp unix_file.cpp unix_thread.cpp ) diff --git a/fastos/src/vespa/fastos/app.cpp b/fastos/src/vespa/fastos/app.cpp deleted file mode 100644 index 8477f79f00d..00000000000 --- a/fastos/src/vespa/fastos/app.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -//************************************************************************ -/** - * Implementation of FastOS_ApplicationInterface methods. - * - * @author Div, Oivind H. Danielsen - */ - -#include "app.h" -#include "file.h" -#include "thread.h" -#include -#include - -FastOS_ApplicationInterface::FastOS_ApplicationInterface() : - _argc(0), - _argv(nullptr) -{ -} - -FastOS_ApplicationInterface::~FastOS_ApplicationInterface () = default; - -bool FastOS_ApplicationInterface::Init () -{ - bool rc=false; - - if (PreThreadInit()) { - if (FastOS_Thread::InitializeClass()) { - rc = true; - } else { - fprintf(stderr, "FastOS_Thread class initialization failed.\n"); - } - } else - fprintf(stderr, "FastOS_PreThreadInit failed.\n"); - - return rc; -} - - -void FastOS_ApplicationInterface::Cleanup () -{ - FastOS_Thread::CleanupClass(); -} - -int FastOS_ApplicationInterface::Entry (int argc, char **argv) -{ - int rc=255; - - _argc = argc; - _argv = argv; - - if (Init()) { - rc = Main(); - } - - Cleanup(); - - return rc; -} diff --git a/fastos/src/vespa/fastos/app.h b/fastos/src/vespa/fastos/app.h deleted file mode 100644 index c03dbc5848c..00000000000 --- a/fastos/src/vespa/fastos/app.h +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -//************************************************************************ -/** - * @file - * Class definition for FastOS_ApplicationInterface. - * - * @author Div, Oivind H. Danielsen - */ - -#pragma once - - -#include "types.h" - -/** - * FastOS application wrapper class. - * This class manages initialization and cleanup of the services - * provided by FastOS. - * Your application should inherit from this class, and implement - * @ref Main(). - * It is possible, but not required to override the @ref Init() - * and @ref Cleanup() methods. If you do, make sure you invoke - * the superclass, in order to perform the neccessary initialization - * and cleanup. - * - * To startup the FastOS_Application, invoke @ref Entry() as shown - * in the example below. This will call @ref Init(), @ref Main() - * (if @ref Init() succeeds) and @ref Cleanup(), in that order. - * - * Example: - * @code - * #include - * - * class MyApplication : public FastOS_Application - * { - * int Main () - * { - * printf("Hello world\n"); - * - * return 0; - * } - * }; - * - * - * int main (int argc, char **argv) - * { - * MyApplication app; - * - * app.Entry(argc, argv); - * } - * @endcode - * - * Here is another example. This version overrides @ref Init() and - * @ref Cleanup(). Most applications do not need to do this, but - * an example of how to do it is included anyway: - * @code - * #include - * - * class MyApplication : public FastOS_Application - * { - * bool MyOwnInitializationStuff () - * { - * printf("My initialization stuff\n"); - * return true; - * } - * - * void MyOwnCleanupStuff() - * { - * printf("My cleanup stuff\n"); - * } - * - * // Most applications do not need to override this method. - * // If you do, make sure you invoke the superclass Init() - * // first. - * bool Init () - * { - * bool rc=false; - * - * if(FastOS_Application::Init()) - * { - * if(MyOwnInitializationStuff()) - * { - * rc = true; - * } - * } - * - * // The application will not start if false is returned. - * return rc; - * } - * - * // Most applications do not need to override this method. - * // If you do, make sure you invoke the superclass Cleanup() - * // at the end. - * // Note that Cleanup() is always invoked, even when Init() - * // fails. - * void Cleanup () - * { - * MyOwnCleanupStuff(); - * - * FastOS_Application::Cleanup(); - * } - * - * int Main () - * { - * printf("Hello world\n"); - * - * return 0; - * } - * }; - * - * - * int main (int argc, char **argv) - * { - * MyApplication app; - * - * app.Entry(argc, argv); - * } - * - * @endcode - */ -class FastOS_ApplicationInterface -{ - friend int main (int argc, char **argv); -protected: - virtual bool PreThreadInit () { return true; } - -public: - int _argc; - char **_argv; - - FastOS_ApplicationInterface(); - FastOS_ApplicationInterface(const FastOS_ApplicationInterface&) = delete; - FastOS_ApplicationInterface& operator=(const FastOS_ApplicationInterface&) = delete; - virtual ~FastOS_ApplicationInterface(); - - /** - * FastOS initialization. - * This method performs the neccessary initialization for FastOS. - * It is possible to override this method, see the class documentation - * for an example. - * @ref Main() will be called, if and only if @ref Init() returns true. - * @ref Cleanup will always be called, regardless of the @ref Init() - * return value. - */ - virtual bool Init(); - - /** - * FastOS Entry. - * This method is used to enter the application and provide command - * line arguments. See the class documentation for an example on - * how this is used. - * @param argc Number of arguments - * @param argv Array of arguments - * @return Errorlevel returned to the shell - */ - int Entry (int argc, char **argv); - - /** - * FastOS Main. - * This is where your application starts. See the class documentation - * for an example on how this is used. - * @return Errorlevel returned to the shell - */ - virtual int Main ()=0; - - /** - * FastOS Cleanup. - * This method performs the neccessary cleanup for FastOS. - * It is possible to override this method, see the class documentation - * for an example. - * @ref Cleanup() is always called, regardless of the return values - * of @ref Init() and @ref Main(). - */ - virtual void Cleanup (); -}; - - -#include -typedef FastOS_UNIX_Application FASTOS_PREFIX(Application); - - - -// Macro included for convenience. -#define FASTOS_MAIN(application_class) \ -int main (int argc, char **argv) \ -{ \ - application_class app; \ - \ - return app.Entry(argc, argv); \ -} - - - diff --git a/fastos/src/vespa/fastos/thread.h b/fastos/src/vespa/fastos/thread.h index f881095c29a..b3627d99d31 100644 --- a/fastos/src/vespa/fastos/thread.h +++ b/fastos/src/vespa/fastos/thread.h @@ -317,20 +317,6 @@ protected: bool _runningFlag; public: - /** - * Initialize the thread class. This is invoked by - * @ref FastOS_Application::Init(). - * @return Boolean success/failure - */ - static bool InitializeClass () {return true;}; - - /** - * Cleanup the thread class. This is invoked by - * @ref FastOS_Application::Cleanup(). - * @return Boolean success/failure - */ - static bool CleanupClass () {return true;}; - /** * Constructor. Resets internal attributes. */ diff --git a/fastos/src/vespa/fastos/unix_app.cpp b/fastos/src/vespa/fastos/unix_app.cpp deleted file mode 100644 index 733b8806fb5..00000000000 --- a/fastos/src/vespa/fastos/unix_app.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -/** -****************************************************************************** -* @author Oivind H. Danielsen -* @date Creation date: 2000-01-18 -* @file -* Implementation of FastOS_UNIX_Application methods. -*****************************************************************************/ - -#include "app.h" -#include "time.h" -#include -#include -#include - - -FastOS_UNIX_Application::FastOS_UNIX_Application() = default; -FastOS_UNIX_Application::~FastOS_UNIX_Application() = default; - -extern "C" -{ -extern char **environ; -}; - -bool FastOS_UNIX_Application::PreThreadInit () -{ - bool rc = true; - if (FastOS_ApplicationInterface::PreThreadInit()) { - // Ignore SIGPIPE - struct sigaction act; - act.sa_handler = SIG_IGN; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - sigaction(SIGPIPE, &act, nullptr); - } else { - rc = false; - fprintf(stderr, "FastOS_ApplicationInterface::PreThreadInit failed\n"); - } - return rc; -} - -bool FastOS_UNIX_Application::Init () -{ - return FastOS_ApplicationInterface::Init(); -} - -void FastOS_UNIX_Application::Cleanup () -{ - FastOS_ApplicationInterface::Cleanup(); -} diff --git a/fastos/src/vespa/fastos/unix_app.h b/fastos/src/vespa/fastos/unix_app.h deleted file mode 100644 index 0f11356614e..00000000000 --- a/fastos/src/vespa/fastos/unix_app.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -//************************************************************************ -/** - * Class definitions for FastOS_UNIX_Application. - * - * @author Div, Oivind H. Danielsen - */ - -#pragma once - -#include "app.h" -#include "types.h" -#include - -/** - * This is the generic UNIX implementation of @ref FastOS_ApplicationInterface - */ -class FastOS_UNIX_Application : public FastOS_ApplicationInterface -{ -protected: - bool PreThreadInit () override; -public: - FastOS_UNIX_Application (); - FastOS_UNIX_Application(const FastOS_UNIX_Application&) = delete; - FastOS_UNIX_Application& operator=(const FastOS_UNIX_Application&) = delete; - virtual ~FastOS_UNIX_Application(); - bool Init () override; - void Cleanup () override; -}; diff --git a/fnet/src/examples/frt/rpc/echo_client.cpp b/fnet/src/examples/frt/rpc/echo_client.cpp index 61416fb06bd..0176337c466 100644 --- a/fnet/src/examples/frt/rpc/echo_client.cpp +++ b/fnet/src/examples/frt/rpc/echo_client.cpp @@ -3,28 +3,28 @@ #include #include #include -#include +#include #include LOG_SETUP("echo_client"); -class EchoClient : public FastOS_Application +class EchoClient { public: - int Main() override; + int main(int argc, char **argv); }; int -EchoClient::Main() +EchoClient::main(int argc, char **argv) { - if (_argc < 2) { + if (argc < 2) { printf("usage : echo_client \n"); return 1; } fnet::frt::StandaloneFRT server; FRT_Supervisor & supervisor = server.supervisor(); - FRT_Target *target = supervisor.GetTarget(_argv[1]); + FRT_Target *target = supervisor.GetTarget(argv[1]); FRT_RPCRequest *req = supervisor.AllocRPCRequest(); FRT_Values *args = req->GetParams(); req->SetMethodName("frt.rpc.echo"); @@ -90,9 +90,8 @@ EchoClient::Main() return 0; } -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); EchoClient myapp; - return myapp.Entry(argc, argv); + return myapp.main(argc, argv); } diff --git a/fnet/src/examples/frt/rpc/rpc_callback_client.cpp b/fnet/src/examples/frt/rpc/rpc_callback_client.cpp index 9d56db3fe0a..b41c40ba29d 100644 --- a/fnet/src/examples/frt/rpc/rpc_callback_client.cpp +++ b/fnet/src/examples/frt/rpc/rpc_callback_client.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include LOG_SETUP("rpc_callback_client"); @@ -34,16 +34,16 @@ RPC::Init(FRT_Supervisor *s) } -class MyApp : public FastOS_Application +class MyApp { public: - int Main() override; + int main(int argc, char **argv); }; int -MyApp::Main() +MyApp::main(int argc, char **argv) { - if (_argc < 2) { + if (argc < 2) { printf("usage : rpc_server \n"); return 1; } @@ -53,7 +53,7 @@ MyApp::Main() FRT_Supervisor & orb = server.supervisor(); rpc.Init(&orb); - FRT_Target *target = orb.Get2WayTarget(_argv[1]); + FRT_Target *target = orb.Get2WayTarget(argv[1]); FRT_RPCRequest *req = orb.AllocRPCRequest(); printf("invokeCnt: %d\n", rpc.invokeCnt); @@ -108,9 +108,8 @@ MyApp::Main() } -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); MyApp myapp; - return myapp.Entry(argc, argv); + return myapp.main(argc, argv); } diff --git a/fnet/src/examples/frt/rpc/rpc_callback_server.cpp b/fnet/src/examples/frt/rpc/rpc_callback_server.cpp index 49792ddb893..37a819c6ee7 100644 --- a/fnet/src/examples/frt/rpc/rpc_callback_server.cpp +++ b/fnet/src/examples/frt/rpc/rpc_callback_server.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include @@ -49,17 +49,17 @@ RPC::Init(FRT_Supervisor *s) } -class MyApp : public FastOS_Application +class MyApp { public: - int Main() override; + int main(int argc, char **argv); }; int -MyApp::Main() +MyApp::main(int argc, char **argv) { FNET_SignalShutDown::hookSignals(); - if (_argc < 2) { + if (argc < 2) { printf("usage : rpc_server \n"); return 1; } @@ -67,16 +67,15 @@ MyApp::Main() fnet::frt::StandaloneFRT server; FRT_Supervisor & supervisor = server.supervisor(); rpc.Init(&supervisor); - supervisor.Listen(_argv[1]); + supervisor.Listen(argv[1]); FNET_SignalShutDown ssd(*supervisor.GetTransport()); server.supervisor().GetTransport()->WaitFinished(); return 0; } -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); MyApp myapp; - return myapp.Entry(argc, argv); + return myapp.main(argc, argv); } diff --git a/fnet/src/examples/frt/rpc/rpc_client.cpp b/fnet/src/examples/frt/rpc/rpc_client.cpp index 6eb8758157c..acb20a880c9 100644 --- a/fnet/src/examples/frt/rpc/rpc_client.cpp +++ b/fnet/src/examples/frt/rpc/rpc_client.cpp @@ -3,28 +3,28 @@ #include #include #include -#include +#include #include LOG_SETUP("rpc_client"); -class RPCClient : public FastOS_Application +class RPCClient { public: - int Main() override; + int main(int argc, char **argv); }; int -RPCClient::Main() +RPCClient::main(int argc, char **argv) { - if (_argc < 2) { + if (argc < 2) { printf("usage : rpc_client \n"); return 1; } fnet::frt::StandaloneFRT server; FRT_Supervisor & supervisor = server.supervisor(); - FRT_Target *target = supervisor.GetTarget(_argv[1]); + FRT_Target *target = supervisor.GetTarget(argv[1]); const char *str1 = "abc"; const char *str2 = "def"; @@ -86,9 +86,8 @@ RPCClient::Main() } -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); RPCClient myapp; - return myapp.Entry(argc, argv); + return myapp.main(argc, argv); } diff --git a/fnet/src/examples/frt/rpc/rpc_info.cpp b/fnet/src/examples/frt/rpc/rpc_info.cpp index 53adf262e35..9734342a24e 100644 --- a/fnet/src/examples/frt/rpc/rpc_info.cpp +++ b/fnet/src/examples/frt/rpc/rpc_info.cpp @@ -3,12 +3,12 @@ #include #include #include -#include +#include #include LOG_SETUP("vespa-rpc-info"); -class RPCInfo : public FastOS_Application +class RPCInfo { public: @@ -68,23 +68,23 @@ public: printf("\n"); } - int Main() override; + int main(int argc, char **argv); }; int -RPCInfo::Main() +RPCInfo::main(int argc, char **argv) { - if (_argc < 2) { + if (argc < 2) { printf("usage : vespa-rpc-info [verbose]\n"); return 1; } - bool verbose = (_argc > 2 && strcmp(_argv[2], "verbose") == 0); + bool verbose = (argc > 2 && strcmp(argv[2], "verbose") == 0); fnet::frt::StandaloneFRT server; FRT_Supervisor & supervisor = server.supervisor(); - FRT_Target *target = supervisor.GetTarget(_argv[1]); + FRT_Target *target = supervisor.GetTarget(argv[1]); FRT_RPCRequest *m_list = nullptr; FRT_RPCRequest *info = nullptr; @@ -92,7 +92,7 @@ RPCInfo::Main() info->SetMethodName("frt.rpc.ping"); target->InvokeSync(info, 5.0); if (info->IsError()) { - fprintf(stderr, "Error talking to %s\n", _argv[1]); + fprintf(stderr, "Error talking to %s\n", argv[1]); FreeReqs(m_list, info); return 1; } @@ -135,9 +135,8 @@ RPCInfo::Main() } -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); RPCInfo myapp; - return myapp.Entry(argc, argv); + return myapp.main(argc, argv); } diff --git a/fnet/src/examples/frt/rpc/rpc_invoke.cpp b/fnet/src/examples/frt/rpc/rpc_invoke.cpp index 987d987e672..a6177999d70 100644 --- a/fnet/src/examples/frt/rpc/rpc_invoke.cpp +++ b/fnet/src/examples/frt/rpc/rpc_invoke.cpp @@ -3,13 +3,13 @@ #include #include #include -#include +#include #include #include LOG_SETUP("vespa-rpc-invoke"); -class RPCClient : public FastOS_Application +class RPCClient { private: static bool addArg(FRT_RPCRequest *req, const char *param) { @@ -45,16 +45,16 @@ private: } return true; } - int run(); + int run(int argc, char **argv); public: - int Main() override; + int main(int argc, char **argv); }; int -RPCClient::Main() +RPCClient::main(int argc, char **argv) { - if (_argc < 3) { + if (argc < 3) { fprintf(stderr, "usage: vespa-rpc-invoke [-t timeout] [args]\n"); fprintf(stderr, " -t timeout in seconds\n"); fprintf(stderr, " Each arg must be on the form :\n"); @@ -62,7 +62,7 @@ RPCClient::Main() return 1; } try { - return run(); + return run(argc, argv); } catch (const std::exception & e) { fprintf(stderr, "Caught exception : '%s'", e.what()); return 2; @@ -70,7 +70,7 @@ RPCClient::Main() } int -RPCClient::run() +RPCClient::run(int argc, char **argv) { int retCode = 0; fnet::frt::StandaloneFRT server; @@ -79,18 +79,18 @@ RPCClient::run() int methNameArg = 2; int startOfArgs = 3; int timeOut = 10; - if (strcmp(_argv[1], "-t") == 0) { - timeOut = atoi(_argv[2]); + if (strcmp(argv[1], "-t") == 0) { + timeOut = atoi(argv[2]); targetArg = 3; methNameArg = 4; startOfArgs = 5; } - FRT_Target *target = supervisor.GetTarget(_argv[targetArg]); + FRT_Target *target = supervisor.GetTarget(argv[targetArg]); FRT_RPCRequest *req = supervisor.AllocRPCRequest(); - req->SetMethodName(_argv[methNameArg]); - for (int i = startOfArgs; i < _argc; ++i) { - if (!addArg(req, _argv[i])) { - fprintf(stderr, "could not parse parameter: '%s'\n", _argv[i]); + req->SetMethodName(argv[methNameArg]); + for (int i = startOfArgs; i < argc; ++i) { + if (!addArg(req, argv[i])) { + fprintf(stderr, "could not parse parameter: '%s'\n", argv[i]); retCode = 2; break; } @@ -115,9 +115,8 @@ RPCClient::run() } -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); RPCClient myapp; - return myapp.Entry(argc, argv); + return myapp.main(argc, argv); } diff --git a/fnet/src/examples/frt/rpc/rpc_server.cpp b/fnet/src/examples/frt/rpc/rpc_server.cpp index 83f86ed50bf..8cb3adf5387 100644 --- a/fnet/src/examples/frt/rpc/rpc_server.cpp +++ b/fnet/src/examples/frt/rpc/rpc_server.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include LOG_SETUP("rpc_server"); @@ -23,7 +23,7 @@ public: void RPC_concat(FRT_RPCRequest *req); void RPC_addFloat(FRT_RPCRequest *req); void RPC_addDouble(FRT_RPCRequest *req); - int Main(int argc, char **argv); + int main(int argc, char **argv); }; void @@ -86,7 +86,7 @@ RPCServer::RPC_addDouble(FRT_RPCRequest *req) } int -RPCServer::Main(int argc, char **argv) +RPCServer::main(int argc, char **argv) { FNET_SignalShutDown::hookSignals(); if (argc < 2) { @@ -104,26 +104,8 @@ RPCServer::Main(int argc, char **argv) } -class App : public FastOS_Application -{ -private: - RPCServer _server; - -public: - App() : _server() {} - int Main() override; -}; - -int -App::Main() -{ - return _server.Main(_argc, _argv); -} - - -int -main(int argc, char **argv) -{ - App myapp; - return myapp.Entry(argc, argv); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + RPCServer server; + return server.main(argc, argv); } diff --git a/fnet/src/examples/ping/pingclient.cpp b/fnet/src/examples/ping/pingclient.cpp index d57a17d2f5d..af3c9f68848 100644 --- a/fnet/src/examples/ping/pingclient.cpp +++ b/fnet/src/examples/ping/pingclient.cpp @@ -5,23 +5,23 @@ #include #include #include -#include +#include #include #include LOG_SETUP("pingclient"); -class PingClient : public FastOS_Application +class PingClient { public: - int Main() override; + int main(int argc, char **argv); }; int -PingClient::Main() +PingClient::main(int argc, char **argv) { - if (_argc < 2) { + if (argc < 2) { printf("usage : pingclient \n"); printf("example: pingclient 'tcp/localhost:8000'\n"); return 1; @@ -32,12 +32,12 @@ PingClient::Main() PingPacketFactory factory; FNET_SimplePacketStreamer streamer(&factory); FNET_Transport transport; - FNET_Connection *conn = transport.Connect(_argv[1], &streamer); + FNET_Connection *conn = transport.Connect(argv[1], &streamer); uint32_t timeout_ms=5000; FNET_Channel *channels[10]; - if (_argc == 3) { - timeout_ms = atof(_argv[2]) * 1000; + if (argc == 3) { + timeout_ms = atof(argv[2]) * 1000; } transport.Start(&pool); @@ -45,7 +45,7 @@ PingClient::Main() for (uint32_t i = 0; i < 10; i++) { channels[i] = (conn == nullptr) ? nullptr : conn->OpenChannel(&queue, FNET_Context(i)); if (channels[i] == 0) { - fprintf(stderr, "Could not make channel[%d] to %s\n", i, _argv[1]); + fprintf(stderr, "Could not make channel[%d] to %s\n", i, argv[1]); break; } channelCnt++; @@ -95,9 +95,8 @@ PingClient::Main() } -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); PingClient myapp; - return myapp.Entry(argc, argv); + return myapp.main(argc, argv); } diff --git a/fnet/src/examples/ping/pingserver.cpp b/fnet/src/examples/ping/pingserver.cpp index 83d99c9c7e8..fb5b12b66c0 100644 --- a/fnet/src/examples/ping/pingserver.cpp +++ b/fnet/src/examples/ping/pingserver.cpp @@ -7,14 +7,13 @@ #include #include #include -#include +#include #include LOG_SETUP("pingserver"); class PingServer : public FNET_IServerAdapter, - public FNET_IPacketHandler, - public FastOS_Application + public FNET_IPacketHandler { public: bool InitChannel(FNET_Channel *channel, uint32_t) override { @@ -31,16 +30,16 @@ public: packet->Free(); return FNET_FREE_CHANNEL; } - - int Main() override; + + int main(int argc, char **argv); }; int -PingServer::Main() +PingServer::main(int argc, char **argv) { FNET_SignalShutDown::hookSignals(); - if (_argc < 2) { + if (argc < 2) { printf("usage : pingserver \n"); printf("example: pingserver 'tcp/8000'\n"); return 1; @@ -50,7 +49,7 @@ PingServer::Main() PingPacketFactory factory; FNET_SimplePacketStreamer streamer(&factory); FNET_Connector *listener = - transport.Listen(_argv[1], &streamer, this); + transport.Listen(argv[1], &streamer, this); if (listener != nullptr) listener->SubRef(); @@ -60,9 +59,8 @@ PingServer::Main() } -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); PingServer myapp; - return myapp.Entry(argc, argv); + return myapp.main(argc, argv); } diff --git a/fnet/src/examples/timeout/timeout.cpp b/fnet/src/examples/timeout/timeout.cpp index 725ab8ce53d..70e9a1498c7 100644 --- a/fnet/src/examples/timeout/timeout.cpp +++ b/fnet/src/examples/timeout/timeout.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -38,15 +38,15 @@ Timeout::PerformTask() } -class MyApp : public FastOS_Application +class MyApp { public: - int Main() override; + int main(int argc, char **argv); }; int -MyApp::Main() +MyApp::main(int, char **) { using clock = std::chrono::steady_clock; using ms_double = std::chrono::duration; @@ -95,9 +95,8 @@ MyApp::Main() } -int -main(int argc, char **argv) -{ - MyApp myapp; - return myapp.Entry(argc, argv); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + MyApp myapp; + return myapp.main(argc, argv); } diff --git a/jrt_test/src/jrt-test/simpleserver/simpleserver.cpp b/jrt_test/src/jrt-test/simpleserver/simpleserver.cpp index b6269253c48..9feedb8d663 100644 --- a/jrt_test/src/jrt-test/simpleserver/simpleserver.cpp +++ b/jrt_test/src/jrt-test/simpleserver/simpleserver.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include class Server : public FRT_Invokable { @@ -66,31 +66,15 @@ public: }; -class App : public FastOS_Application -{ -public: - int Main() override; -}; - - -int -App::Main() -{ - if (_argc < 2) { - printf("usage: %s \n", _argv[0]); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + if (argc < 2) { + printf("usage: %s \n", argv[0]); return 1; } fnet::frt::StandaloneFRT frt; Server server(&frt.supervisor()); - frt.supervisor().Listen(_argv[1]); + frt.supervisor().Listen(argv[1]); frt.supervisor().GetTransport()->WaitFinished(); return 0; } - - -int -main(int argc, char **argv) -{ - App myapp; - return myapp.Entry(argc, argv); -} diff --git a/jrt_test/src/tests/echo/echo-client.cpp b/jrt_test/src/tests/echo/echo-client.cpp index 0661c8cfa2c..a7c8d309114 100644 --- a/jrt_test/src/tests/echo/echo-client.cpp +++ b/jrt_test/src/tests/echo/echo-client.cpp @@ -4,21 +4,21 @@ #include #include -#include +#include -class EchoClient : public FastOS_Application +class EchoClient { public: - int Main() override + int main(int argc, char **argv) { - if (_argc < 2) { + if (argc < 2) { printf("usage : echo_client \n"); return 1; } fnet::frt::StandaloneFRT server; FRT_Supervisor & supervisor = server.supervisor(); - FRT_Target *target = supervisor.GetTarget(_argv[1]); + FRT_Target *target = supervisor.GetTarget(argv[1]); FRT_RPCRequest *req = supervisor.AllocRPCRequest(); FRT_Values *args = req->GetParams(); req->SetMethodName("echo"); @@ -85,9 +85,8 @@ public: } }; -int -main(int argc, char **argv) -{ - EchoClient myapp; - return myapp.Entry(argc, argv); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + EchoClient myapp; + return myapp.main(argc, argv); } diff --git a/jrt_test/src/tests/mandatory-methods/extract-reflection.cpp b/jrt_test/src/tests/mandatory-methods/extract-reflection.cpp index 96f90c59645..cdcf02da465 100644 --- a/jrt_test/src/tests/mandatory-methods/extract-reflection.cpp +++ b/jrt_test/src/tests/mandatory-methods/extract-reflection.cpp @@ -1,13 +1,13 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include +#include #include #include #include #include #include -class RPCInfo : public FastOS_Application +class RPCInfo { public: @@ -68,17 +68,17 @@ public: } - int Main() override + int main(int argc, char **argv) { - if (_argc < 2) { + if (argc < 2) { printf("usage : rpc_info [verbose]\n"); return 1; } - bool verbose = (_argc > 2 && strcmp(_argv[2], "verbose") == 0); + bool verbose = (argc > 2 && strcmp(argv[2], "verbose") == 0); fnet::frt::StandaloneFRT server; FRT_Supervisor & supervisor = server.supervisor(); - FRT_Target *target = supervisor.GetTarget(_argv[1]); + FRT_Target *target = supervisor.GetTarget(argv[1]); FRT_RPCRequest *m_list = nullptr; FRT_RPCRequest *info = nullptr; @@ -91,10 +91,10 @@ public: } std::this_thread::sleep_for(1s); target->SubRef(); - target = supervisor.GetTarget(_argv[1]); + target = supervisor.GetTarget(argv[1]); } if (info->IsError()) { - fprintf(stderr, "Error talking to %s\n", _argv[1]); + fprintf(stderr, "Error talking to %s\n", argv[1]); info->Print(); FreeReqs(m_list, info); return 1; @@ -139,9 +139,8 @@ public: }; -int -main(int argc, char **argv) -{ - RPCInfo myapp; - return myapp.Entry(argc, argv); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + RPCInfo myapp; + return myapp.main(argc, argv); } diff --git a/jrt_test/src/tests/mockup-invoke/mockup-server.cpp b/jrt_test/src/tests/mockup-invoke/mockup-server.cpp index cfa40f3352d..a2ee4cb3440 100644 --- a/jrt_test/src/tests/mockup-invoke/mockup-server.cpp +++ b/jrt_test/src/tests/mockup-invoke/mockup-server.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include class MockupServer : public FRT_Invokable { @@ -37,31 +37,15 @@ public: }; -class App : public FastOS_Application -{ -public: - int Main() override; -}; - - -int -App::Main() -{ - if (_argc < 2) { - printf("usage: %s \n", _argv[0]); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + if (argc < 2) { + printf("usage: %s \n", argv[0]); return 1; } fnet::frt::StandaloneFRT frt; MockupServer server(&frt.supervisor()); - frt.supervisor().Listen(_argv[1]); + frt.supervisor().Listen(argv[1]); frt.supervisor().GetTransport()->WaitFinished(); return 0; } - - -int -main(int argc, char **argv) -{ - App myapp; - return myapp.Entry(argc, argv); -} diff --git a/juniper/src/test/SrcTestSuite.cpp b/juniper/src/test/SrcTestSuite.cpp index c26e73341d5..1fcaa6e29de 100644 --- a/juniper/src/test/SrcTestSuite.cpp +++ b/juniper/src/test/SrcTestSuite.cpp @@ -28,24 +28,11 @@ SrcTestSuite::SrcTestSuite() : AddTest(new AuxTest()); } -/** - * The SrcTestSuiteApp class holds the main body for running the - * SrcTestSuite class. - * - * @author Knut Omang - */ -class SrcTestSuiteApp : public vespalib::TestApp { -public: - int Main() override; -}; - -int SrcTestSuiteApp::Main() { - juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); +int main(int argc, char **argv) { + juniper::TestEnv te(argc, argv, TEST_PATH("../rpclient/testclient.rc").c_str()); SrcTestSuite suite; suite.Run(); long failures = suite.Report(); suite.Free(); return (int)failures; } - -FASTOS_MAIN(SrcTestSuiteApp); diff --git a/juniper/src/test/auxTestApp.cpp b/juniper/src/test/auxTestApp.cpp index ff942dc19f7..1c85796bb1f 100644 --- a/juniper/src/test/auxTestApp.cpp +++ b/juniper/src/test/auxTestApp.cpp @@ -2,27 +2,16 @@ #include "auxTest.h" #include -class AuxTestApp : public vespalib::TestApp -{ -public: - int Main() override; -}; - - - void Usage(char* s) { fprintf(stderr, "Usage: %s [-d debug_level]\n", s); } -int AuxTestApp::Main() -{ - juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); +int main(int argc, char **argv) { + juniper::TestEnv te(argc, argv, TEST_PATH("../rpclient/testclient.rc").c_str()); AuxTest pta; pta.SetStream(&std::cout); - pta.Run(_argc, _argv); + pta.Run(argc, argv); return pta.Report(); } - -FASTOS_MAIN(AuxTestApp); diff --git a/juniper/src/test/matchobjectTestApp.cpp b/juniper/src/test/matchobjectTestApp.cpp index 6a595e07983..7fae5b4c0de 100644 --- a/juniper/src/test/matchobjectTestApp.cpp +++ b/juniper/src/test/matchobjectTestApp.cpp @@ -4,21 +4,10 @@ #include "testenv.h" #include -/** - * The MatchObjectTestApp class is the main routine for running the unit - * tests for the MatchObject class in isolation. - * - * @sa MatchObject @author Knut Omang - */ -class MatchObjectTestApp : public vespalib::TestApp { -public: - int Main() override { - juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); - MatchObjectTest test; - test.SetStream(&std::cout); - test.Run(_argc, _argv); - return (int)test.Report(); - } -}; - -FASTOS_MAIN(MatchObjectTestApp); +int main(int argc, char **argv) { + juniper::TestEnv te(argc, argv, TEST_PATH("../rpclient/testclient.rc").c_str()); + MatchObjectTest test; + test.SetStream(&std::cout); + test.Run(argc, argv); + return (int)test.Report(); +} diff --git a/juniper/src/test/mcandTestApp.cpp b/juniper/src/test/mcandTestApp.cpp index 32d2a2e0b92..825dc61da06 100644 --- a/juniper/src/test/mcandTestApp.cpp +++ b/juniper/src/test/mcandTestApp.cpp @@ -3,21 +3,10 @@ #include "mcandTest.h" #include -/** - * The MatchCandidateTestApp class is the main routine for running the unit - * tests for the MatchCandidate class in isolation. - * - * @sa MatchCandidate @author Knut Omang - */ -class MatchCandidateTestApp : public vespalib::TestApp { -public: - int Main() override { - juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); - MatchCandidateTest test; - test.SetStream(&std::cout); - test.Run(_argc, _argv); - return (int)test.Report(); - } -}; - -FASTOS_MAIN(MatchCandidateTestApp); +int main(int argc, char **argv) { + juniper::TestEnv te(argc, argv, TEST_PATH("../rpclient/testclient.rc").c_str()); + MatchCandidateTest test; + test.SetStream(&std::cout); + test.Run(argc, argv); + return (int)test.Report(); +} diff --git a/juniper/src/test/queryparserTestApp.cpp b/juniper/src/test/queryparserTestApp.cpp index be0b505ac4f..a2c551a4730 100644 --- a/juniper/src/test/queryparserTestApp.cpp +++ b/juniper/src/test/queryparserTestApp.cpp @@ -4,21 +4,11 @@ #include "testenv.h" #include -/** - * The QueryParserTestApp class is the main routine for running the unit - * tests for the QueryParser class in isolation. - * - * @sa QueryParser @author Knut Omang - */ -class QueryParserTestApp : public vespalib::TestApp { -public: - int Main() override { - juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); - QueryParserTest test; - test.SetStream(&std::cout); - test.Run(_argc, _argv); - return (int)test.Report(); - } -}; -FASTOS_MAIN(QueryParserTestApp); +int main(int argc, char **argv) { + juniper::TestEnv te(argc, argv, TEST_PATH("../rpclient/testclient.rc").c_str()); + QueryParserTest test; + test.SetStream(&std::cout); + test.Run(argc, argv); + return (int)test.Report(); +} diff --git a/juniper/src/test/testenv.cpp b/juniper/src/test/testenv.cpp index 2dec01ffe3e..769c24b829c 100644 --- a/juniper/src/test/testenv.cpp +++ b/juniper/src/test/testenv.cpp @@ -16,12 +16,12 @@ Config* TestConfig; Juniper * _Juniper; -TestEnv::TestEnv(FastOS_Application* app, const char* propfile) : +TestEnv::TestEnv(int argc, char **argv, const char* propfile) : _props(), _config(), _juniper(), _wordFolder() { int c; - while ((c = getopt(app->_argc, app->_argv, "d:hcm:")) != EOF) + while ((c = getopt(argc, argv, "d:hcm:")) != EOF) { switch (c) { @@ -40,16 +40,16 @@ TestEnv::TestEnv(FastOS_Application* app, const char* propfile) : break; case 'h': default: - Usage(app->_argv[0]); + Usage(argv[0]); return; } } int expected_args = 0; - if (app->_argc - optind < expected_args) + if (argc - optind < expected_args) { - Usage(app->_argv[0]); + Usage(argv[0]); return; } diff --git a/juniper/src/test/testenv.h b/juniper/src/test/testenv.h index 4435b9157d1..a43f4a11bec 100644 --- a/juniper/src/test/testenv.h +++ b/juniper/src/test/testenv.h @@ -20,7 +20,6 @@ #include #include #include -#include namespace juniper { @@ -28,7 +27,7 @@ namespace juniper class TestEnv { public: - TestEnv(FastOS_Application* app, const char* propfile); + TestEnv(int argc, char **argv, const char* propfile); virtual ~TestEnv(); void Usage(char* s); private: diff --git a/messagebus_test/src/tests/error/cpp-client.cpp b/messagebus_test/src/tests/error/cpp-client.cpp index 365032536cc..f9ab29efc20 100644 --- a/messagebus_test/src/tests/error/cpp-client.cpp +++ b/messagebus_test/src/tests/error/cpp-client.cpp @@ -8,19 +8,19 @@ #include #include #include -#include +#include using namespace mbus; using namespace std::chrono_literals; -class App : public FastOS_Application +class App { public: - int Main() override; + int main(int argc, char **argv); }; int -App::Main() +App::main(int, char **) { RPCMessageBus mb(ProtocolSet().add(std::make_shared()), RPCNetworkParams(config::ConfigUri("file:slobrok.cfg")) @@ -65,6 +65,7 @@ App::Main() } int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); App app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/messagebus_test/src/tests/error/cpp-server.cpp b/messagebus_test/src/tests/error/cpp-server.cpp index e6be163a366..cbf07bd5f20 100644 --- a/messagebus_test/src/tests/error/cpp-server.cpp +++ b/messagebus_test/src/tests/error/cpp-server.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include using namespace mbus; @@ -42,15 +42,8 @@ Server::handleMessage(Message::UP msg) { _session->reply(std::move(reply)); } -class App : public FastOS_Application -{ -public: - int Main() override; -}; - -int -App::Main() -{ +int main(int, char **) { + vespalib::SignalHandler::PIPE.ignore(); RPCMessageBus mb(ProtocolSet().add(std::make_shared()), RPCNetworkParams(config::ConfigUri("file:slobrok.cfg")) .setIdentity(Identity("server/cpp")), @@ -61,8 +54,3 @@ App::Main() } return 0; } - -int main(int argc, char **argv) { - App app; - return app.Entry(argc, argv); -} diff --git a/messagebus_test/src/tests/errorcodes/dumpcodes.cpp b/messagebus_test/src/tests/errorcodes/dumpcodes.cpp index 3aef46dbb4c..102262d97bf 100644 --- a/messagebus_test/src/tests/errorcodes/dumpcodes.cpp +++ b/messagebus_test/src/tests/errorcodes/dumpcodes.cpp @@ -1,15 +1,15 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include -#include +#include using namespace mbus; -class App : public FastOS_Application +class App { public: void dump(const std::string &desc, uint32_t value); - int Main() override; + int main(int argc, char **argv); }; void @@ -20,7 +20,7 @@ App::dump(const std::string &desc, uint32_t value) } int -App::Main() +App::main(int, char **) { dump("NONE", ErrorCode::NONE); @@ -62,6 +62,7 @@ App::Main() } int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); App app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/messagebus_test/src/tests/speed/cpp-client.cpp b/messagebus_test/src/tests/speed/cpp-client.cpp index d8ba5d85169..bfd2faf735e 100644 --- a/messagebus_test/src/tests/speed/cpp-client.cpp +++ b/messagebus_test/src/tests/speed/cpp-client.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include using namespace mbus; using namespace std::chrono_literals; @@ -84,14 +84,14 @@ Client::handleReply(Reply::UP reply) { send(); } -class App : public FastOS_Application +class App { public: - int Main() override; + int main(int argc, char **argv); }; int -App::Main() +App::main(int, char **) { auto retryPolicy = std::make_shared(); retryPolicy->setBaseDelay(0.1); @@ -133,10 +133,11 @@ App::Main() } int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); fprintf(stderr, "started '%s'\n", argv[0]); fflush(stderr); App app; - int r = app.Entry(argc, argv); + int r = app.main(argc, argv); fprintf(stderr, "stopping '%s'\n", argv[0]); fflush(stderr); return r; diff --git a/messagebus_test/src/tests/speed/cpp-server.cpp b/messagebus_test/src/tests/speed/cpp-server.cpp index 20a72596182..aee6c5ed96d 100644 --- a/messagebus_test/src/tests/speed/cpp-server.cpp +++ b/messagebus_test/src/tests/speed/cpp-server.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include using namespace mbus; @@ -49,15 +49,8 @@ Server::handleMessage(Message::UP msg) { } } -class App : public FastOS_Application -{ -public: - int Main() override; -}; - -int -App::Main() -{ +int main(int, char **) { + vespalib::SignalHandler::PIPE.ignore(); RPCMessageBus mb(ProtocolSet().add(std::make_shared()), RPCNetworkParams(config::ConfigUri("file:slobrok.cfg")) .setIdentity(Identity("server/cpp")), @@ -68,8 +61,3 @@ App::Main() } return 0; } - -int main(int argc, char **argv) { - App app; - return app.Entry(argc, argv); -} diff --git a/messagebus_test/src/tests/trace/cpp-server.cpp b/messagebus_test/src/tests/trace/cpp-server.cpp index b8b20e8e621..f151286edf0 100644 --- a/messagebus_test/src/tests/trace/cpp-server.cpp +++ b/messagebus_test/src/tests/trace/cpp-server.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include using namespace mbus; @@ -56,24 +56,24 @@ Server::handleReply(Reply::UP reply) { _session->forward(std::move(reply)); } -class App : public FastOS_Application +class App { public: - int Main() override; + int main(int argc, char **argv); }; int -App::Main() +App::main(int argc, char **argv) { - if (_argc != 2) { - fprintf(stderr, "usage: %s \n", _argv[0]); + if (argc != 2) { + fprintf(stderr, "usage: %s \n", argv[0]); return 1; } RPCMessageBus mb(ProtocolSet().add(std::make_shared()), RPCNetworkParams(config::ConfigUri("file:slobrok.cfg")) - .setIdentity(Identity(_argv[1])), + .setIdentity(Identity(argv[1])), config::ConfigUri("file:routing.cfg")); - Server server(mb.getMessageBus(), _argv[1]); + Server server(mb.getMessageBus(), argv[1]); while (true) { std::this_thread::sleep_for(1s); } @@ -81,6 +81,7 @@ App::Main() } int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); App app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/searchcore/src/apps/proton/proton.cpp b/searchcore/src/apps/proton/proton.cpp index 27ecbd08917..c823ee8a09f 100644 --- a/searchcore/src/apps/proton/proton.cpp +++ b/searchcore/src/apps/proton/proton.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -40,15 +39,15 @@ Params::Params() {} Params::~Params() = default; -class App : public FastOS_Application +class App { private: static void setupSignals(); static void setup_fadvise(); - Params parseParams(); - void startAndRun(FastOS_ThreadPool & threadPool, FNET_Transport & transport); + Params parseParams(int argc, char **argv); + void startAndRun(FastOS_ThreadPool & threadPool, FNET_Transport & transport, int argc, char **argv); public: - int Main() override; + int main(int argc, char **argv); }; void @@ -77,10 +76,10 @@ App::setup_fadvise() } Params -App::parseParams() +App::parseParams(int argc, char **argv) { Params params; - vespalib::ProgramOptions parser(_argc, _argv); + vespalib::ProgramOptions parser(argc, argv); parser.setSyntaxMessage("proton -- the nextgen search core"); parser.addOption("identity", params.identity, "Node identity and config id"); std::string empty; @@ -207,8 +206,8 @@ buildTransportConfig() { } void -App::startAndRun(FastOS_ThreadPool & threadPool, FNET_Transport & transport) { - Params params = parseParams(); +App::startAndRun(FastOS_ThreadPool & threadPool, FNET_Transport & transport, int argc, char **argv) { + Params params = parseParams(argc, argv); LOG(debug, "identity: '%s'", params.identity.c_str()); LOG(debug, "serviceidentity: '%s'", params.serviceidentity.c_str()); LOG(debug, "subscribeTimeout: '%" PRIu64 "'", params.subscribeTimeout); @@ -217,7 +216,7 @@ App::startAndRun(FastOS_ThreadPool & threadPool, FNET_Transport & transport) { config::ConfigServerSpec configServerSpec(transport); config::ConfigUri identityUri(params.identity, std::make_shared(configServerSpec)); auto protonUP = std::make_unique(threadPool, transport, identityUri, - _argc > 0 ? _argv[0] : "proton", subscribeTimeout); + (argc > 0) ? argv[0] : "proton", subscribeTimeout); proton::Proton & proton = *protonUP; proton::BootstrapConfig::SP configSnapshot = proton.init(); if (proton.hasAbortedInit()) { @@ -263,7 +262,7 @@ App::startAndRun(FastOS_ThreadPool & threadPool, FNET_Transport & transport) { } int -App::Main() +App::main(int argc, char **argv) { try { setupSignals(); @@ -271,7 +270,7 @@ App::Main() FastOS_ThreadPool threadPool(128_Ki); FNET_Transport transport(buildTransportConfig()); transport.Start(&threadPool); - startAndRun(threadPool, transport); + startAndRun(threadPool, transport, argc, argv); transport.ShutDown(true); } catch (const vespalib::InvalidCommandLineArgumentsException &e) { LOG(warning, "Invalid commandline arguments: '%s'", e.what()); @@ -299,5 +298,5 @@ App::Main() int main(int argc, char **argv) { App app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp b/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp index 5ec1794c1b0..e72771f5aa6 100644 --- a/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp +++ b/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -88,7 +88,7 @@ OnnxModels make_models(const OnnxModelsConfig &modelsCfg, const VerifyRanksetupC return OnnxModels(model_list); } -class App : public FastOS_Application +class App { public: bool verify(const search::index::Schema &schema, @@ -106,7 +106,7 @@ public: const OnnxModelsConfig &modelsCfg); int usage(); - int Main() override; + int main(int argc, char **argv); }; struct DummyConstantValueRepo : IConstantValueRepo { @@ -201,13 +201,13 @@ App::usage() } int -App::Main() +App::main(int argc, char **argv) { - if (_argc != 2) { + if (argc != 2) { return usage(); } - const std::string configid = _argv[1]; + const std::string configid = argv[1]; LOG(debug, "verifying rank setup for config id '%s' ...", configid.c_str()); @@ -244,6 +244,7 @@ App::Main() } int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); App app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp b/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp index 85c39226998..98574752929 100644 --- a/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp +++ b/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include typedef vespalib::SignalHandler SIG; @@ -111,10 +111,10 @@ FeedHandler::~FeedHandler() //----------------------------------------------------------------------------- -class App : public FastOS_Application +class App { public: - virtual int Main() override; + int main(int argc, char **argv); }; template @@ -165,14 +165,14 @@ int usage() { } int -App::Main() +App::main(int argc, char **argv) { setupSignals(); - if (_argc != 3) { + if (argc != 3) { return usage(); } - std::string feedFile = _argv[1]; - std::string dirName = _argv[2]; + std::string feedFile = argv[1]; + std::string dirName = argv[2]; fprintf(stderr, "input feed: %s\n", feedFile.c_str()); fprintf(stderr, "output directory: %s\n", dirName.c_str()); vespalib::mkdir(dirName); @@ -214,5 +214,5 @@ App::Main() int main(int argc, char **argv) { App app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/searchcore/src/apps/vespa-feed-bm/vespa_feed_bm.cpp b/searchcore/src/apps/vespa-feed-bm/vespa_feed_bm.cpp index 9b5956d3910..9a4922c42fc 100644 --- a/searchcore/src/apps/vespa-feed-bm/vespa_feed_bm.cpp +++ b/searchcore/src/apps/vespa-feed-bm/vespa_feed_bm.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -185,15 +185,15 @@ Benchmark::run() _cluster->stop(); } -class App : public FastOS_Application +class App { BMParams _bm_params; public: App(); - ~App() override; + ~App(); void usage(); - bool get_options(); - int Main() override; + bool get_options(int argc, char **argv); + int main(int argc, char **argv); }; App::App() @@ -239,7 +239,7 @@ App::usage() } bool -App::get_options() +App::get_options(int argc, char **argv) { int c; int long_opt_index = 0; @@ -297,7 +297,7 @@ App::get_options() LONGOPT_USE_STORAGE_CHAIN }; optind = 1; - while ((c = getopt_long(_argc, _argv, "", long_opts, &long_opt_index)) != -1) { + while ((c = getopt_long(argc, argv, "", long_opts, &long_opt_index)) != -1) { switch (c) { case 0: switch(long_opt_index) { @@ -385,9 +385,9 @@ App::get_options() } int -App::Main() +App::main(int argc, char **argv) { - if (!get_options()) { + if (!get_options(argc, argv)) { usage(); return 1; } @@ -397,12 +397,11 @@ App::Main() return 0; } -int -main(int argc, char* argv[]) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); DummyFileHeaderContext::setCreator("vespa-feed-bm"); App app; - auto exit_value = app.Entry(argc, argv); + auto exit_value = app.main(argc, argv); vespalib::rmdir(base_dir, true); return exit_value; } diff --git a/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp b/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp index 669581a85ed..db89cbf6c2e 100644 --- a/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp +++ b/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -588,28 +588,11 @@ DocumentGenerator::generate(uint32_t docMin, uint32_t docIdLimit, class SubApp { -protected: - FastOS_Application &_app; - public: - SubApp(FastOS_Application &app) - : _app(app) - { - } - - virtual - ~SubApp() - { - } - - virtual void - usage(bool showHeader) = 0; - - virtual bool - getOptions() = 0; - - virtual int - run() = 0; + virtual void usage(bool showHeader) = 0; + virtual bool getOptions(int argc, char **argv) = 0; + virtual int run() = 0; + virtual ~SubApp() = default; }; class GenTestDocsApp : public SubApp @@ -629,9 +612,8 @@ class GenTestDocsApp : public SubApp bool _json; public: - GenTestDocsApp(FastOS_Application &app) - : SubApp(app), - _baseDir(""), + GenTestDocsApp() + : _baseDir(""), _docType("testdoc"), _minDocId(0u), _docIdLimit(5u), @@ -653,19 +635,13 @@ public: _rnd.srand48(42); } - virtual - ~GenTestDocsApp() + ~GenTestDocsApp() override { } - virtual void - usage(bool showHeader) override; - - virtual bool - getOptions() override; - - virtual int - run() override; + virtual void usage(bool showHeader) override; + virtual bool getOptions(int argc, char **argv) override; + virtual int run() override; }; @@ -694,7 +670,7 @@ GenTestDocsApp::usage(bool showHeader) } bool -GenTestDocsApp::getOptions() +GenTestDocsApp::getOptions(int argc, char **argv) { int c; int longopt_index = 0; @@ -730,7 +706,7 @@ GenTestDocsApp::getOptions() LONGOPT_JSON }; optind = 2; - while ((c = getopt_long(_app._argc, _app._argv, "v", + while ((c = getopt_long(argc, argv, "v", longopts, &longopt_index)) != -1) { FieldGenerator::SP g; @@ -809,10 +785,10 @@ GenTestDocsApp::getOptions() } } _optIndex = optind; - if (_optIndex >= _app._argc) { + if (_optIndex >= argc) { return false; } - _outFile = _app._argv[optind]; + _outFile = argv[optind]; return true; } @@ -834,35 +810,32 @@ GenTestDocsApp::run() } -class App : public FastOS_Application +class App { public: - void - usage(); - - int - Main() override; + void usage(); + int main(int argc, char **argv); }; void App::usage() { - GenTestDocsApp(*this).usage(true); + GenTestDocsApp().usage(true); } int -App::Main() +App::main(int argc, char **argv) { - if (_argc < 2) { + if (argc < 2) { usage(); return 1; } std::unique_ptr subApp; - if (strcmp(_argv[1], "gentestdocs") == 0) - subApp.reset(new GenTestDocsApp(*this)); - if (subApp.get() != NULL) { - if (!subApp->getOptions()) { + if (strcmp(argv[1], "gentestdocs") == 0) + subApp = std::make_unique(); + if (subApp.get() != nullptr) { + if (!subApp->getOptions(argc, argv)) { subApp->usage(true); return 1; } @@ -873,9 +846,8 @@ App::Main() } -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); App app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp b/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp index ac2d3b44ffe..8eb56d218fb 100644 --- a/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp +++ b/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -19,7 +19,7 @@ LOG_SETUP("vespa-proton-cmd"); namespace pandora::rtc_cmd { -class App : public FastOS_Application +class App { private: App(const App &); @@ -35,16 +35,16 @@ public: _target(nullptr), _req(nullptr) {} - ~App() override + ~App() { assert(!_frt); assert(_target == nullptr); assert(_req == nullptr); } - int usage() + int usage(const char *self) { - fprintf(stderr, "usage: %s [args]\n", _argv[0]); + fprintf(stderr, "usage: %s [args]\n", self); fprintf(stderr, "die\n"); fprintf(stderr, "getProtonStatus\n"); fprintf(stderr, "getState\n"); @@ -208,10 +208,10 @@ public: } - int Main() override + int main(int argc, char **argv) { - if (_argc < 3) { - return usage(); + if (argc < 3) { + return usage(argv[0]); } config::ConfigSystem configSystem; @@ -226,7 +226,7 @@ public: return 2; } int port = 0; - std::string spec = _argv[1]; + std::string spec = argv[1]; try { if (spec == "--local") { @@ -234,7 +234,7 @@ public: } else if (spec.compare(0, 5, "--id=") == 0) { spec = findRTC(spec.substr(5)); } else { - port = atoi(_argv[1]); + port = atoi(argv[1]); } } catch (const std::runtime_error & e) { fprintf(stderr, "%s", e.what()); @@ -248,7 +248,7 @@ public: if (port == 0 && spec.compare(0, 4, "tcp/") != 0) { finiRPC(); - return usage(); + return usage(argv[0]); } if (port != 0) { @@ -259,14 +259,14 @@ public: bool invoked = false; - if (strcmp(_argv[2], "getState") == 0 && - _argc >= 3) { + if (strcmp(argv[2], "getState") == 0 && + argc >= 3) { _req->SetMethodName("pandora.rtc.getState"); FRT_Values ¶ms = *_req->GetParams(); - params.AddInt32(_argc > 3 ? atoi(_argv[3]) : 0); - params.AddInt32(_argc > 4 ? atoi(_argv[4]) : 0); + params.AddInt32(argc > 3 ? atoi(argv[3]) : 0); + params.AddInt32(argc > 4 ? atoi(argv[4]) : 0); invokeRPC(false); invoked = true; @@ -289,12 +289,12 @@ public: printf("gencnt=%u\n", static_cast(gencnt._intval32)); } - } else if (strcmp(_argv[2], "getProtonStatus") == 0 && - _argc >= 3) { + } else if (strcmp(argv[2], "getProtonStatus") == 0 && + argc >= 3) { _req->SetMethodName("proton.getStatus"); FRT_Values ¶ms = *_req->GetParams(); - params.AddString(_argc > 3 ? _argv[3] : ""); + params.AddString(argc > 3 ? argv[3] : ""); invokeRPC(false); invoked = true; FRT_Values &rvals = *_req->GetReturn(); @@ -317,25 +317,25 @@ public: } } - } else if (strcmp(_argv[2], "triggerFlush") == 0) { + } else if (strcmp(argv[2], "triggerFlush") == 0) { _req->SetMethodName("proton.triggerFlush"); invokeRPC(false, 86400.0); invoked = true; if (! _req->IsError()) { printf("OK: flush trigger enabled\n"); } - } else if (strcmp(_argv[2], "prepareRestart") == 0) { + } else if (strcmp(argv[2], "prepareRestart") == 0) { _req->SetMethodName("proton.prepareRestart"); invokeRPC(false, 600.0); invoked = true; if (! _req->IsError()) { printf("OK: prepareRestart enabled\n"); } - } else if (strcmp(_argv[2], "die") == 0) { + } else if (strcmp(argv[2], "die") == 0) { _req->SetMethodName("pandora.rtc.die"); } else { finiRPC(); - return usage(); + return usage(argv[0]); } if (!invoked) invokeRPC(true); @@ -347,8 +347,8 @@ public: } // namespace pandora::rtc_cmd -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); pandora::rtc_cmd::App app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/searchcore/src/apps/vespa-redistribute-bm/vespa_redistribute_bm.cpp b/searchcore/src/apps/vespa-redistribute-bm/vespa_redistribute_bm.cpp index f331c3f2511..40847baa719 100644 --- a/searchcore/src/apps/vespa-redistribute-bm/vespa_redistribute_bm.cpp +++ b/searchcore/src/apps/vespa-redistribute-bm/vespa_redistribute_bm.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -440,15 +440,15 @@ Benchmark::run() _cluster->stop(); } -class App : public FastOS_Application +class App { BMParams _bm_params; public: App(); - ~App() override; + ~App(); void usage(); - bool get_options(); - int Main() override; + bool get_options(int argc, char **argv); + int main(int argc, char **argv); }; App::App() @@ -497,7 +497,7 @@ App::usage() } bool -App::get_options() +App::get_options(int argc, char **argv) { int c; int long_opt_index = 0; @@ -561,7 +561,7 @@ App::get_options() LONGOPT_USE_FEED_SETTLE }; optind = 1; - while ((c = getopt_long(_argc, _argv, "", long_opts, &long_opt_index)) != -1) { + while ((c = getopt_long(argc, argv, "", long_opts, &long_opt_index)) != -1) { switch (c) { case 0: switch(long_opt_index) { @@ -664,9 +664,9 @@ App::get_options() } int -App::Main() +App::main(int argc, char **argv) { - if (!get_options()) { + if (!get_options(argc, argv)) { usage(); return 1; } @@ -676,12 +676,11 @@ App::Main() return 0; } -int -main(int argc, char* argv[]) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); DummyFileHeaderContext::setCreator("vespa-redistribute-bm"); App app; - auto exit_value = app.Entry(argc, argv); + auto exit_value = app.main(argc, argv); vespalib::rmdir(base_dir, true); return exit_value; } diff --git a/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp b/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp index 4d7f32241f9..711191125da 100644 --- a/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp +++ b/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include @@ -599,59 +599,59 @@ DumpDocumentsOptions::createUtility() const /** * Main application. */ -class App : public FastOS_Application +class App { private: std::string _programName; std::string _tmpArg; - void combineFirstArgs() { - _tmpArg = vespalib::make_string("%s %s", _argv[0], _argv[1]).c_str(); - _argv[1] = &_tmpArg[0]; + void combineFirstArgs(char **argv) { + _tmpArg = vespalib::make_string("%s %s", argv[0], argv[1]).c_str(); + argv[1] = &_tmpArg[0]; } - void replaceFirstArg(const std::string &replace) { + void replaceFirstArg(char **argv, const std::string &replace) { _tmpArg = vespalib::make_string("%s %s", _programName.c_str(), replace.c_str()).c_str(); - _argv[0] = &_tmpArg[0]; + argv[0] = &_tmpArg[0]; } void usageHeader() { std::cout << _programName << " version 0.0\n"; } - void usage() { + void usage(int argc, char **argv) { usageHeader(); - replaceFirstArg(ListDomainsOptions::command()); - ListDomainsOptions(_argc, _argv).usage(); - replaceFirstArg(DumpOperationsOptions::command()); - DumpOperationsOptions(_argc, _argv).usage(); - replaceFirstArg(DumpDocumentsOptions::command()); - DumpDocumentsOptions(_argc, _argv).usage(); + replaceFirstArg(argv, ListDomainsOptions::command()); + ListDomainsOptions(argc, argv).usage(); + replaceFirstArg(argv, DumpOperationsOptions::command()); + DumpOperationsOptions(argc, argv).usage(); + replaceFirstArg(argv, DumpDocumentsOptions::command()); + DumpDocumentsOptions(argc, argv).usage(); } public: App(); ~App(); - int Main() override; + int main(int argc, char **argv); }; App::App() {} App::~App() {} int -App::Main() { - _programName = _argv[0]; - if (_argc < 2) { - usage(); +App::main(int argc, char **argv) { + _programName = argv[0]; + if (argc < 2) { + usage(argc, argv); return 1; } BaseOptions::UP opts; - if (strcmp(_argv[1], ListDomainsOptions::command().c_str()) == 0) { - combineFirstArgs(); - opts.reset(new ListDomainsOptions(_argc-1, _argv+1)); - } else if (strcmp(_argv[1], DumpOperationsOptions::command().c_str()) == 0) { - combineFirstArgs(); - opts.reset(new DumpOperationsOptions(_argc-1, _argv+1)); - } else if (strcmp(_argv[1], DumpDocumentsOptions::command().c_str()) == 0) { - combineFirstArgs(); - opts.reset(new DumpDocumentsOptions(_argc-1, _argv+1)); + if (strcmp(argv[1], ListDomainsOptions::command().c_str()) == 0) { + combineFirstArgs(argv); + opts.reset(new ListDomainsOptions(argc-1, argv+1)); + } else if (strcmp(argv[1], DumpOperationsOptions::command().c_str()) == 0) { + combineFirstArgs(argv); + opts.reset(new DumpOperationsOptions(argc-1, argv+1)); + } else if (strcmp(argv[1], DumpDocumentsOptions::command().c_str()) == 0) { + combineFirstArgs(argv); + opts.reset(new DumpDocumentsOptions(argc-1, argv+1)); } if (opts.get() != NULL) { try { @@ -664,13 +664,12 @@ App::Main() { } return opts->createUtility()->run(); } - usage(); + usage(argc, argv); return 1; } -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); App app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp b/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp index aff368ceced..ac540ad2e2d 100644 --- a/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp +++ b/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp @@ -71,7 +71,7 @@ void commit_memory_index_and_wait(MemoryIndex &memory_index) class Test : public vespalib::TestApp { const char *current_state; void DumpState(bool) { - fprintf(stderr, "%s: ERROR: in %s\n", GetName(), current_state); + fprintf(stderr, "%s: ERROR: in %s\n", __FILE__, current_state); } void requireThatMemoryIndexCanBeDumpedAndSearched(); diff --git a/searchcore/src/tests/proton/matching/query_test.cpp b/searchcore/src/tests/proton/matching/query_test.cpp index fd3dd0da518..11d4b1a1687 100644 --- a/searchcore/src/tests/proton/matching/query_test.cpp +++ b/searchcore/src/tests/proton/matching/query_test.cpp @@ -712,7 +712,7 @@ void Test::requireThatQueryGluesEverythingTogether() { ASSERT_TRUE(search.get()); } -void checkQueryAddsLocation(Test &test, const string &loc_in, const string &loc_out) { +void checkQueryAddsLocation(const string &loc_in, const string &loc_out) { fef_test::IndexEnvironment index_environment; FieldInfo field_info(FieldType::INDEX, CollectionType::SINGLE, field, 0); index_environment.getFields().push_back(field_info); @@ -730,7 +730,7 @@ void checkQueryAddsLocation(Test &test, const string &loc_in, const string &loc_ ViewResolver(), index_environment); vector term_data; query.extractTerms(term_data); - test.EXPECT_EQUAL(2u, term_data.size()); + EXPECT_EQUAL(2u, term_data.size()); FakeRequestContext requestContext; FakeSearchContext context; @@ -738,12 +738,12 @@ void checkQueryAddsLocation(Test &test, const string &loc_in, const string &loc_ MatchDataLayout mdl; query.reserveHandles(requestContext, context, mdl); MatchData::UP md = mdl.createMatchData(); - test.EXPECT_EQUAL(2u, md->getNumTermFields()); + EXPECT_EQUAL(2u, md->getNumTermFields()); query.fetchPostings(); SearchIterator::UP search = query.createSearch(*md); - test.ASSERT_TRUE(search.get()); - if (!test.EXPECT_NOT_EQUAL(string::npos, search->asString().find(loc_out))) { + ASSERT_TRUE(search.get()); + if (!EXPECT_NOT_EQUAL(string::npos, search->asString().find(loc_out))) { fprintf(stderr, "search (missing loc_out '%s'): %s", loc_out.c_str(), search->asString().c_str()); } @@ -804,15 +804,15 @@ void Test::requireThatLocationIsAddedTheCorrectPlace() { } void Test::requireThatQueryAddsLocation() { - checkQueryAddsLocation(*this, "(2,10,10,3,0,1,0,0)", "{p:{x:10,y:10},r:3,b:{x:[7,13],y:[7,13]}}"); - checkQueryAddsLocation(*this, "{p:{x:10,y:10},r:3}", "{p:{x:10,y:10},r:3,b:{x:[7,13],y:[7,13]}}"); - checkQueryAddsLocation(*this, "{b:{x:[6,11],y:[8,15]},p:{x:10,y:10},r:3}", "{p:{x:10,y:10},r:3,b:{x:[7,11],y:[8,13]}}"); - checkQueryAddsLocation(*this, "{a:12345,b:{x:[8,10],y:[8,10]},p:{x:10,y:10},r:3}", "{p:{x:10,y:10},r:3,a:12345,b:{x:[8,10],y:[8,10]}}"); + checkQueryAddsLocation("(2,10,10,3,0,1,0,0)", "{p:{x:10,y:10},r:3,b:{x:[7,13],y:[7,13]}}"); + checkQueryAddsLocation("{p:{x:10,y:10},r:3}", "{p:{x:10,y:10},r:3,b:{x:[7,13],y:[7,13]}}"); + checkQueryAddsLocation("{b:{x:[6,11],y:[8,15]},p:{x:10,y:10},r:3}", "{p:{x:10,y:10},r:3,b:{x:[7,11],y:[8,13]}}"); + checkQueryAddsLocation("{a:12345,b:{x:[8,10],y:[8,10]},p:{x:10,y:10},r:3}", "{p:{x:10,y:10},r:3,a:12345,b:{x:[8,10],y:[8,10]}}"); } void Test::requireThatQueryAddsLocationCutoff() { - checkQueryAddsLocation(*this, "[2,10,11,23,24]", "{b:{x:[10,23],y:[11,24]}}"); - checkQueryAddsLocation(*this, "{b:{y:[11,24],x:[10,23]}}", "{b:{x:[10,23],y:[11,24]}}"); + checkQueryAddsLocation("[2,10,11,23,24]", "{b:{x:[10,23],y:[11,24]}}"); + checkQueryAddsLocation("{b:{y:[11,24],x:[10,23]}}", "{b:{x:[10,23],y:[11,24]}}"); } void diff --git a/searchlib/src/apps/docstore/benchmarkdatastore.cpp b/searchlib/src/apps/docstore/benchmarkdatastore.cpp index 4a0be335b11..9c2a40d6e98 100644 --- a/searchlib/src/apps/docstore/benchmarkdatastore.cpp +++ b/searchlib/src/apps/docstore/benchmarkdatastore.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -16,40 +16,41 @@ LOG_SETUP("documentstore.benchmark"); using namespace search; -class BenchmarkDataStoreApp : public FastOS_Application +class BenchmarkDataStoreApp { - void usage(); + void usage(const char *self); int benchmark(const vespalib::string & directory, size_t numReads, size_t numThreads, size_t perChunk, const vespalib::string & readType); - int Main() override; void read(size_t numReads, size_t perChunk, const IDataStore * dataStore); +public: + int main(int argc, char **argv); }; void -BenchmarkDataStoreApp::usage() +BenchmarkDataStoreApp::usage(const char *self) { - printf("Usage: %s \n", _argv[0]); + printf("Usage: %s \n", self); fflush(stdout); } int -BenchmarkDataStoreApp::Main() +BenchmarkDataStoreApp::main(int argc, char **argv) { - if (_argc >= 2) { + if (argc >= 2) { size_t numThreads(16); size_t numReads(1000000); size_t perChunk(1); vespalib::string readType("directio"); - vespalib::string directory(_argv[1]); - if (_argc >= 3) { - numReads = strtoul(_argv[2], NULL, 0); - if (_argc >= 4) { - numThreads = strtoul(_argv[3], NULL, 0); - if (_argc >= 5) { - perChunk = strtoul(_argv[4], NULL, 0); - if (_argc >= 5) { - readType = _argv[5]; + vespalib::string directory(argv[1]); + if (argc >= 3) { + numReads = strtoul(argv[2], NULL, 0); + if (argc >= 4) { + numThreads = strtoul(argv[3], NULL, 0); + if (argc >= 5) { + perChunk = strtoul(argv[4], NULL, 0); + if (argc >= 5) { + readType = argv[5]; } } } @@ -57,7 +58,7 @@ BenchmarkDataStoreApp::Main() return benchmark(directory, numReads, numThreads, perChunk, readType); } else { fprintf(stderr, "Too few arguments\n"); - usage(); + usage(argv[0]); return 1; } return 0; @@ -111,4 +112,8 @@ BenchmarkDataStoreApp::benchmark(const vespalib::string & dir, size_t numReads, return retval; } -FASTOS_MAIN(BenchmarkDataStoreApp); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + BenchmarkDataStoreApp app; + return app.main(argc, argv); +} diff --git a/searchlib/src/apps/docstore/create-idx-from-dat.cpp b/searchlib/src/apps/docstore/create-idx-from-dat.cpp index 30af02ddb92..7ac6b37473c 100644 --- a/searchlib/src/apps/docstore/create-idx-from-dat.cpp +++ b/searchlib/src/apps/docstore/create-idx-from-dat.cpp @@ -4,24 +4,25 @@ #include #include #include -#include +#include #include #include #include using namespace search; -class CreateIdxFileFromDatApp : public FastOS_Application +class CreateIdxFileFromDatApp { - void usage(); + void usage(const char *self); int createIdxFile(const vespalib::string & datFileName, const vespalib::string & idxFileName); - int Main() override; +public: + int main(int argc, char **argv); }; void -CreateIdxFileFromDatApp::usage() +CreateIdxFileFromDatApp::usage(const char *self) { - printf("Usage: %s \n", _argv[0]); + printf("Usage: %s \n", self); fflush(stdout); } @@ -152,19 +153,23 @@ int CreateIdxFileFromDatApp::createIdxFile(const vespalib::string & datFileName, } int -CreateIdxFileFromDatApp::Main() +CreateIdxFileFromDatApp::main(int argc, char **argv) { vespalib::string cmd; - if (_argc == 3) { - vespalib::string datFile(_argv[1]); - vespalib::string idxfile(_argv[2]); + if (argc == 3) { + vespalib::string datFile(argv[1]); + vespalib::string idxfile(argv[2]); createIdxFile(datFile, idxfile); } else { fprintf(stderr, "Too few arguments\n"); - usage(); + usage(argv[0]); return 1; } return 0; } -FASTOS_MAIN(CreateIdxFileFromDatApp); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + CreateIdxFileFromDatApp app; + return app.main(argc, argv); +} diff --git a/searchlib/src/apps/docstore/documentstoreinspect.cpp b/searchlib/src/apps/docstore/documentstoreinspect.cpp index 0fc0c26f9c7..34afa0216ed 100644 --- a/searchlib/src/apps/docstore/documentstoreinspect.cpp +++ b/searchlib/src/apps/docstore/documentstoreinspect.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -11,20 +11,21 @@ using namespace search; -class DocumentStoreInspectApp : public FastOS_Application +class DocumentStoreInspectApp { - void usage(); + void usage(const char *self); int verify(const vespalib::string & directory); int dumpIdxFile(const vespalib::string & file); - int Main() override; +public: + int main(int argc, char **argv); }; void -DocumentStoreInspectApp::usage() +DocumentStoreInspectApp::usage(const char *self) { - printf("Usage: %s dumpidxfile [--idxfile idxFile]\n", _argv[0]); + printf("Usage: %s dumpidxfile [--idxfile idxFile]\n", self); fflush(stdout); } @@ -64,35 +65,35 @@ int DocumentStoreInspectApp::dumpIdxFile(const vespalib::string & file) } int -DocumentStoreInspectApp::Main() +DocumentStoreInspectApp::main(int argc, char **argv) { vespalib::string cmd; - if (_argc >= 2) { - cmd = _argv[1]; + if (argc >= 2) { + cmd = argv[1]; if (cmd == "dumpidxfile") { vespalib::string idxfile; - if (_argc >= 4) { - if (vespalib::string(_argv[2]) == vespalib::string("--idxfile")) { - idxfile = _argv[3]; + if (argc >= 4) { + if (vespalib::string(argv[2]) == vespalib::string("--idxfile")) { + idxfile = argv[3]; dumpIdxFile(idxfile); } else { - fprintf(stderr, "Unknown option '%s'.\n", _argv[2]); - usage(); + fprintf(stderr, "Unknown option '%s'.\n", argv[2]); + usage(argv[0]); return 1; } } else { fprintf(stderr, "Too few arguments\n"); - usage(); + usage(argv[0]); return 1; } } else { fprintf(stderr, "Unknown command '%s'.\n", cmd.c_str()); - usage(); + usage(argv[0]); return 1; } } else { fprintf(stderr, "Too few arguments\n"); - usage(); + usage(argv[0]); return 1; } return 0; @@ -116,4 +117,8 @@ DocumentStoreInspectApp::verify(const vespalib::string & dir) return retval; } -FASTOS_MAIN(DocumentStoreInspectApp); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + DocumentStoreInspectApp app; + return app.main(argc, argv); +} diff --git a/searchlib/src/apps/docstore/verifylogdatastore.cpp b/searchlib/src/apps/docstore/verifylogdatastore.cpp index c868707e545..3b673c172c9 100644 --- a/searchlib/src/apps/docstore/verifylogdatastore.cpp +++ b/searchlib/src/apps/docstore/verifylogdatastore.cpp @@ -4,38 +4,39 @@ #include #include #include -#include +#include #include #include #include using namespace search; -class VerifyLogDataStoreApp : public FastOS_Application +class VerifyLogDataStoreApp { - void usage(); + void usage(const char *self); int verify(const vespalib::string & directory); - int Main() override; +public: + int main(int argc, char **argv); }; void -VerifyLogDataStoreApp::usage() +VerifyLogDataStoreApp::usage(const char *self) { - printf("Usage: %s \n", _argv[0]); + printf("Usage: %s \n", self); fflush(stdout); } int -VerifyLogDataStoreApp::Main() +VerifyLogDataStoreApp::main(int argc, char **argv) { - if (_argc >= 2) { - vespalib::string directory(_argv[1]); + if (argc >= 2) { + vespalib::string directory(argv[1]); return verify(directory); } else { fprintf(stderr, "Too few arguments\n"); - usage(); + usage(argv[0]); return 1; } return 0; @@ -65,4 +66,8 @@ VerifyLogDataStoreApp::verify(const vespalib::string & dir) return retval; } -FASTOS_MAIN(VerifyLogDataStoreApp); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + VerifyLogDataStoreApp app; + return app.main(argc, argv); +} diff --git a/searchlib/src/apps/uniform/uniform.cpp b/searchlib/src/apps/uniform/uniform.cpp index baec62370ed..a72a13464fd 100644 --- a/searchlib/src/apps/uniform/uniform.cpp +++ b/searchlib/src/apps/uniform/uniform.cpp @@ -1,6 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include +#include #include #include @@ -13,7 +13,7 @@ maxExpGolombVal(uint64_t kValue, uint64_t maxBits) (UINT64_C(1) << kValue)); } -class UniformApp : public FastOS_Application +class UniformApp { typedef search::bitcompression::EncodeContext64BE EC64; @@ -27,7 +27,8 @@ class UniformApp : public FastOS_Application static uint32_t encodeSpace(uint64_t x, uint32_t k) { return EC64::encodeExpGolombSpace(x, k); } void clearBits(); void reportBits(); - int Main() override; +public: + int main(int argc, char **argv); }; @@ -55,7 +56,7 @@ UniformApp::reportBits() int -UniformApp::Main() +UniformApp::main(int, char **) { int k, l, m, bestmask, oldbestmask; printf("Hello world\n"); @@ -139,6 +140,10 @@ UniformApp::Main() return 0; } -FASTOS_MAIN(UniformApp); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + UniformApp app; + return app.main(argc, argv); +} diff --git a/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp b/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp index 5cf7528ff1c..ffcb4ca4019 100644 --- a/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp +++ b/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp @@ -8,14 +8,14 @@ #include #include -#include +#include #include namespace search { typedef AttributeVector::SP AttributePtr; -class LoadAttribute : public FastOS_Application +class LoadAttribute { private: void load(const AttributePtr & ptr); @@ -24,7 +24,7 @@ private: void usage(); public: - int Main() override; + int main(int argc, char **argv); }; void @@ -105,7 +105,7 @@ LoadAttribute::usage() } int -LoadAttribute::Main() +LoadAttribute::main(int argc, char **argv) { bool doPrintContent = false; bool doApplyUpdate = false; @@ -115,7 +115,7 @@ LoadAttribute::Main() int opt; bool optError = false; - while ((opt = getopt(_argc, _argv, "pasf:h")) != -1) { + while ((opt = getopt(argc, argv, "pasf:h")) != -1) { switch (opt) { case 'p': doPrintContent = true; @@ -144,12 +144,12 @@ LoadAttribute::Main() } } - if (_argc != (optind + 1) || optError) { + if (argc != (optind + 1) || optError) { usage(); return -1; } - vespalib::string fileName(_argv[optind]); + vespalib::string fileName(argv[optind]); vespalib::FileHeader fh; { vespalib::string datFileName(fileName + ".dat"); @@ -199,8 +199,8 @@ LoadAttribute::Main() } -int main(int argc, char ** argv) -{ +int main(int argc, char ** argv) { + vespalib::SignalHandler::PIPE.ignore(); search::LoadAttribute myApp; - return myApp.Entry(argc, argv); + return myApp.main(argc, argv); } diff --git a/searchlib/src/apps/vespa-fileheader-inspect/vespa-fileheader-inspect.cpp b/searchlib/src/apps/vespa-fileheader-inspect/vespa-fileheader-inspect.cpp index 349064eb2a8..eb5b4cba342 100644 --- a/searchlib/src/apps/vespa-fileheader-inspect/vespa-fileheader-inspect.cpp +++ b/searchlib/src/apps/vespa-fileheader-inspect/vespa-fileheader-inspect.cpp @@ -1,6 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include +#include #include #include #include @@ -12,14 +12,14 @@ LOG_SETUP("vespa-fileheader-inspect"); using namespace vespalib; -class Application : public FastOS_Application { +class Application { private: vespalib::string _fileName; char _delimiter; bool _quiet; - int parseOpts(); - void usage(); + int parseOpts(int argc, char **argv); + void usage(const char *self); void printQuiet(FileHeader &header); void printVerbose(FileHeader &header); vespalib::string escape(const vespalib::string &str, char quote = '\0'); @@ -29,7 +29,7 @@ private: public: Application(); ~Application(); - int Main() override; + int main(int argc, char **argv); }; Application::Application() : @@ -42,10 +42,10 @@ Application::~Application() {} void -Application::usage() +Application::usage(const char *self) { printf("Tool for inspecting the headers of files used by Vespa.\n"); - printf("Usage: %s [options] filename\n", _argv[0]); + printf("Usage: %s [options] filename\n", self); printf("\n"); printf("The options are:\n"); printf("-d delimiter The delimiter to use to separate values in quiet output.\n"); @@ -56,10 +56,10 @@ Application::usage() int -Application::parseOpts() +Application::parseOpts(int argc, char **argv) { int c = '?'; - while ((c = getopt(_argc, _argv, "d:f:qh")) != -1) { + while ((c = getopt(argc, argv, "d:f:qh")) != -1) { switch (c) { case 'd': _delimiter = optarg[0]; @@ -71,15 +71,15 @@ Application::parseOpts() _quiet = true; break; case 'h': - usage(); + usage(argv[0]); return EXIT_SUCCESS; default: - usage(); + usage(argv[0]); return EXIT_FAILURE; } } - if (_argc == optind + 1) { - _fileName = _argv[optind]; + if (argc == optind + 1) { + _fileName = argv[optind]; } if (_fileName.empty()) { std::cerr << "No filename given." << std::endl; @@ -89,9 +89,9 @@ Application::parseOpts() } int -Application::Main() +Application::main(int argc, char **argv) { - int ret = parseOpts(); + int ret = parseOpts(argc, argv); if (ret == EXIT_FAILURE || ret == EXIT_SUCCESS) { return ret; } @@ -218,6 +218,7 @@ Application::getValueString(const FileHeader::Tag &tag) int main(int argc, char** argv) { + vespalib::SignalHandler::PIPE.ignore(); Application app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp index 79d205d7ad6..073a5d2884d 100644 --- a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp +++ b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -167,18 +167,10 @@ FieldOptions::validateFields(const Schema &schema) class SubApp { -protected: - FastOS_Application &_app; - public: - SubApp(FastOS_Application &app) - : _app(app) - { - } - virtual ~SubApp() { } virtual void usage(bool showHeader) = 0; - virtual bool getOptions() = 0; + virtual bool getOptions(int argc, char **argv) = 0; virtual int run() = 0; }; @@ -202,10 +194,10 @@ class ShowPostingListSubApp : public SubApp static uint64_t noWordNumHigh() { return std::numeric_limits::max(); } static uint64_t noWordNum() { return 0u; } public: - ShowPostingListSubApp(FastOS_Application &app); + ShowPostingListSubApp(); virtual ~ShowPostingListSubApp(); virtual void usage(bool showHeader) override; - virtual bool getOptions() override; + virtual bool getOptions(int argc, char **argv) override; virtual int run() override; void showPostingList(); bool readDocIdLimit(const Schema &schema); @@ -216,9 +208,8 @@ public: }; -ShowPostingListSubApp::ShowPostingListSubApp(FastOS_Application &app) - : SubApp(app), - _indexDir("."), +ShowPostingListSubApp::ShowPostingListSubApp() + : _indexDir("."), _fieldOptions(), _word(), _verbose(false), @@ -260,7 +251,7 @@ ShowPostingListSubApp::usage(bool showHeader) bool -ShowPostingListSubApp::getOptions() +ShowPostingListSubApp::getOptions(int argc, char **argv) { int c; int longopt_index = 0; @@ -280,7 +271,7 @@ ShowPostingListSubApp::getOptions() LONGOPT_MINDOCID }; optind = 2; - while ((c = getopt_long(_app._argc, _app._argv, "di:mv", + while ((c = getopt_long(argc, argv, "di:mv", longopts, &longopt_index)) != -1) { switch (c) { @@ -339,10 +330,10 @@ ShowPostingListSubApp::getOptions() _optIndex = optind; if (_transpose) { } else { - if (_optIndex >= _app._argc) { + if (_optIndex >= argc) { return false; } - _word = _app._argv[optind]; + _word = argv[optind]; } return true; } @@ -673,18 +664,17 @@ class DumpWordsSubApp : public SubApp bool _showWordNum; public: - DumpWordsSubApp(FastOS_Application &app); + DumpWordsSubApp(); virtual ~DumpWordsSubApp(); virtual void usage(bool showHeader) override; - virtual bool getOptions() override; + virtual bool getOptions(int argc, char **argv) override; virtual int run() override; void dumpWords(); }; -DumpWordsSubApp::DumpWordsSubApp(FastOS_Application &app) - : SubApp(app), - _indexDir("."), +DumpWordsSubApp::DumpWordsSubApp() + : _indexDir("."), _fieldOptions(), _minNumDocs(0u), _verbose(false), @@ -713,7 +703,7 @@ DumpWordsSubApp::usage(bool showHeader) bool -DumpWordsSubApp::getOptions() +DumpWordsSubApp::getOptions(int argc, char **argv) { int c; int longopt_index = 0; @@ -733,7 +723,7 @@ DumpWordsSubApp::getOptions() LONGOPT_WORDNUM }; optind = 2; - while ((c = getopt_long(_app._argc, _app._argv, "i:", + while ((c = getopt_long(argc, argv, "i:", longopts, &longopt_index)) != -1) { switch (c) { @@ -835,43 +825,36 @@ DumpWordsSubApp::run() } -class VespaIndexInspectApp : public FastOS_Application +class VespaIndexInspectApp { public: - VespaIndexInspectApp(); void usage(); - int Main() override; + int main(int argc, char **argv); }; -VespaIndexInspectApp::VespaIndexInspectApp() - : FastOS_Application() -{ -} - - void VespaIndexInspectApp::usage() { - ShowPostingListSubApp(*this).usage(true); - DumpWordsSubApp(*this).usage(false); + ShowPostingListSubApp().usage(true); + DumpWordsSubApp().usage(false); } int -VespaIndexInspectApp::Main() +VespaIndexInspectApp::main(int argc, char **argv) { - if (_argc < 2) { + if (argc < 2) { usage(); return 1; } std::unique_ptr subApp; - if (strcmp(_argv[1], "showpostings") == 0) - subApp.reset(new ShowPostingListSubApp(*this)); - else if (strcmp(_argv[1], "dumpwords") == 0) - subApp.reset(new DumpWordsSubApp(*this)); - if (subApp.get() != NULL) { - if (!subApp->getOptions()) { + if (strcmp(argv[1], "showpostings") == 0) + subApp = std::make_unique(); + else if (strcmp(argv[1], "dumpwords") == 0) + subApp = std::make_unique(); + if (subApp.get() != nullptr) { + if (!subApp->getOptions(argc, argv)) { subApp->usage(true); return 1; } @@ -881,4 +864,8 @@ VespaIndexInspectApp::Main() return 1; } -FASTOS_MAIN(VespaIndexInspectApp); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + VespaIndexInspectApp app; + return app.main(argc, argv); +} diff --git a/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp b/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp index d4c11d5ac2f..dee7d6f650d 100644 --- a/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp +++ b/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include //----------------------------------------------------------------------------- @@ -328,27 +328,27 @@ State::~State() {} //----------------------------------------------------------------------------- -struct MyApp : public FastOS_Application { - int Main() override; - int usage(); +struct MyApp { + int main(int argc, char **argv); + int usage(const char *self); }; int -MyApp::usage() { - fprintf(stderr, "usage: %s [-v] \n", _argv[0]); +MyApp::usage(const char *self) { + fprintf(stderr, "usage: %s [-v] \n", self); fprintf(stderr, " analyze/benchmark vespa ranking expression\n"); fprintf(stderr, " -v: more verbose output\n"); return 1; } int -MyApp::Main() +MyApp::main(int argc, char **argv) { - bool verbose = (_argc == 3) && (strcmp(_argv[1], "-v") == 0); - if (!(verbose || (_argc == 2))) { - return usage(); + bool verbose = (argc == 3) && (strcmp(argv[1], "-v") == 0); + if (!(verbose || (argc == 2))) { + return usage(argv[0]); } - vespalib::string file_name(verbose ? _argv[2] : _argv[1]); + vespalib::string file_name(verbose ? argv[2] : argv[1]); vespalib::MappedFileInput file(file_name); if (!file.valid()) { fprintf(stderr, "could not read input file: '%s'\n", @@ -369,8 +369,9 @@ MyApp::Main() } int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); MyApp my_app; - return my_app.Entry(argc, argv); + return my_app.main(argc, argv); } //----------------------------------------------------------------------------- diff --git a/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp b/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp index 4a690a28cc8..abdcd27b09a 100644 --- a/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp +++ b/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include "attributesearcher.h" @@ -29,7 +29,7 @@ namespace search { using AttributePtr = AttributeVector::SP; using DocId = AttributeVector::DocId; -class AttributeBenchmark : public FastOS_Application +class AttributeBenchmark { private: class Config { @@ -135,7 +135,7 @@ public: delete _threadPool; } } - int Main() override; + int main(int argc, char **argv); }; @@ -460,7 +460,7 @@ AttributeBenchmark::usage() } int -AttributeBenchmark::Main() +AttributeBenchmark::main(int argc, char **argv) { Config dc; dc._numDocs = 50000; @@ -488,7 +488,7 @@ AttributeBenchmark::Main() int opt; bool optError = false; - while ((opt = getopt(_argc, _argv, "n:u:v:s:q:p:r:c:l:h:i:a:e:S:E:D:L:bRPtw")) != -1) { + while ((opt = getopt(argc, argv, "n:u:v:s:q:p:r:c:l:h:i:a:e:S:E:D:L:bRPtw")) != -1) { switch (opt) { case 'n': dc._numDocs = atoi(optarg); @@ -562,12 +562,12 @@ AttributeBenchmark::Main() } } - if (_argc != (optind + 1) || optError) { + if (argc != (optind + 1) || optError) { usage(); return -1; } - dc._attribute = vespalib::string(_argv[optind]); + dc._attribute = vespalib::string(argv[optind]); _threadPool = new FastOS_ThreadPool(256000); @@ -662,9 +662,9 @@ AttributeBenchmark::Main() } } -int main(int argc, char ** argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); search::AttributeBenchmark myapp; - return myapp.Entry(argc, argv); + return myapp.main(argc, argv); } diff --git a/searchlib/src/tests/bitvector/bitvectorbenchmark.cpp b/searchlib/src/tests/bitvector/bitvectorbenchmark.cpp index e140814a5ad..26b0ccff656 100644 --- a/searchlib/src/tests/bitvector/bitvectorbenchmark.cpp +++ b/searchlib/src/tests/bitvector/bitvectorbenchmark.cpp @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include #include -#include +#include #include #include #include @@ -12,7 +12,7 @@ LOG_SETUP("bitvectorbenchmark"); namespace search { -class BitVectorBenchmark : public FastOS_Application +class BitVectorBenchmark { private: std::vector _bv; @@ -27,7 +27,7 @@ private: public: BitVectorBenchmark(); ~BitVectorBenchmark(); - int Main() override; + int main(int argc, char **argv); }; BitVectorBenchmark::BitVectorBenchmark() : @@ -164,13 +164,13 @@ void BitVectorBenchmark::testOrSpeed2() } } -int BitVectorBenchmark::Main() +int BitVectorBenchmark::main(int argc, char **argv) { std::string operation; size_t numBits(8*1000000); int opt; bool optError = false; - while ((opt = getopt(_argc, _argv, "n:t:")) != -1) { + while ((opt = getopt(argc, argv, "n:t:")) != -1) { switch (opt) { case 'n': numBits = strtoll(optarg, NULL, 10); @@ -184,7 +184,7 @@ int BitVectorBenchmark::Main() } } - if ((_argc != optind ) || optError) { + if ((argc != optind ) || optError) { usage(); return -1; } @@ -217,9 +217,9 @@ int BitVectorBenchmark::Main() } } -int main(int argc, char ** argv) -{ +int main(int argc, char ** argv) { + vespalib::SignalHandler::PIPE.ignore(); search::BitVectorBenchmark myapp; - return myapp.Entry(argc, argv); + return myapp.main(argc, argv); } diff --git a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp index aa5f9a13e7d..47725d7306d 100644 --- a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp +++ b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include LOG_SETUP("fieldwriter_test"); @@ -104,7 +104,7 @@ makeWordString(uint64_t wordNum) } -class FieldWriterTest : public FastOS_Application +class FieldWriterTest { private: bool _verbose; @@ -122,7 +122,7 @@ private: public: FieldWriterTest(); ~FieldWriterTest(); - int Main() override; + int main(int argc, char **argv); }; @@ -664,15 +664,15 @@ testFieldWriterVariantsWithHighLids(FakeWordSet &wordSet, uint32_t docIdLimit, } int -FieldWriterTest::Main() +FieldWriterTest::main(int argc, char **argv) { int c; - if (_argc > 0) { - DummyFileHeaderContext::setCreator(_argv[0]); + if (argc > 0) { + DummyFileHeaderContext::setCreator(argv[0]); } - while ((c = getopt(_argc, _argv, "c:d:vw:")) != -1) { + while ((c = getopt(argc, argv, "c:d:vw:")) != -1) { switch(c) { case 'c': _commonDocFreq = atoi(optarg); @@ -718,11 +718,11 @@ FieldWriterTest::Main() } // namespace fieldwriter int -main(int argc, char **argv) -{ +main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); fieldwriter::FieldWriterTest app; setvbuf(stdout, nullptr, _IOLBF, 32_Ki); app._rnd.srand48(32); - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp b/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp index 05fdf4b70f9..f1729f21f39 100644 --- a/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp +++ b/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include @@ -51,7 +51,7 @@ using Writer = search::diskindex::test::PageDict4MemWriter; using SeqReader = search::diskindex::test::PageDict4MemSeqReader; using RandReader = search::diskindex::test::PageDict4MemRandReader; -class PageDict4TestApp : public FastOS_Application +class PageDict4TestApp { public: vespalib::Rand48 _rnd; @@ -61,7 +61,7 @@ public: bool _lastWordForcedCommon; void usage(); - int Main() override; + int main(int argc, char **argv); void testWords(); PageDict4TestApp() : _rnd(), @@ -83,20 +83,20 @@ PageDict4TestApp::usage() int -PageDict4TestApp::Main() +PageDict4TestApp::main(int argc, char **argv) { - if (_argc > 0) { - DummyFileHeaderContext::setCreator(_argv[0]); + if (argc > 0) { + DummyFileHeaderContext::setCreator(argv[0]); } _rnd.srand48(32); - for (int32_t i = 1; i < _argc; ++i) { - if (strcmp(_argv[i], "stress") == 0) + for (int32_t i = 1; i < argc; ++i) { + if (strcmp(argv[i], "stress") == 0) _stress = true; - if (strcmp(_argv[i], "emptyword") == 0) + if (strcmp(argv[i], "emptyword") == 0) _emptyWord = true; - if (strcmp(_argv[i], "firstwordforcedcommon") == 0) + if (strcmp(argv[i], "firstwordforcedcommon") == 0) _firstWordForcedCommon = true; - if (strcmp(_argv[i], "lastwordforcedcommon") == 0) + if (strcmp(argv[i], "lastwordforcedcommon") == 0) _lastWordForcedCommon = true; } testWords(); @@ -690,4 +690,8 @@ PageDict4TestApp::testWords() #endif } -FASTOS_MAIN(PageDict4TestApp); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + PageDict4TestApp app; + return app.main(argc, argv); +} diff --git a/searchlib/src/tests/postinglistbm/postinglistbm.cpp b/searchlib/src/tests/postinglistbm/postinglistbm.cpp index d0552958611..6155ef88ef3 100644 --- a/searchlib/src/tests/postinglistbm/postinglistbm.cpp +++ b/searchlib/src/tests/postinglistbm/postinglistbm.cpp @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "stress_runner.h" -#include +#include #include #include #include @@ -28,7 +28,7 @@ using namespace search::fakedata; namespace postinglistbm { -class PostingListBM : public FastOS_Application { +class PostingListBM { private: uint32_t _numDocs; uint32_t _commonDocFreq; @@ -49,7 +49,7 @@ public: public: PostingListBM(); ~PostingListBM(); - int Main() override; + int main(int argc, char **argv); }; void @@ -108,14 +108,14 @@ PostingListBM::PostingListBM() PostingListBM::~PostingListBM() = default; int -PostingListBM::Main() +PostingListBM::main(int argc, char **argv) { int c; bool hasElements = false; bool hasElementWeights = false; - while ((c = getopt(_argc, _argv, "C:c:m:r:d:l:s:t:o:uw:T:q")) != -1) { + while ((c = getopt(argc, argv, "C:c:m:r:d:l:s:t:o:uw:T:q")) != -1) { switch(c) { case 'C': _skipCommonPairsRate = atoi(optarg); @@ -226,12 +226,11 @@ PostingListBM::Main() } -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); postinglistbm::PostingListBM app; setvbuf(stdout, nullptr, _IOLBF, 32_Ki); app._rnd.srand48(32); - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/searchlib/src/tests/transactionlogstress/translogstress.cpp b/searchlib/src/tests/transactionlogstress/translogstress.cpp index cfd2138f2e8..9988f3e171a 100644 --- a/searchlib/src/tests/transactionlogstress/translogstress.cpp +++ b/searchlib/src/tests/transactionlogstress/translogstress.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -563,7 +563,7 @@ ControllerThread::doRun() //----------------------------------------------------------------------------- // TransLogStress //----------------------------------------------------------------------------- -class TransLogStress : public FastOS_Application +class TransLogStress { private: class Config { @@ -593,7 +593,7 @@ private: void usage(); public: - int Main() override; + int main(int argc, char **argv); }; void @@ -623,7 +623,7 @@ TransLogStress::usage() } int -TransLogStress::Main() +TransLogStress::main(int argc, char **argv) { std::string tlsSpec("tcp/localhost:17897"); std::string domain("translogstress"); @@ -645,7 +645,7 @@ TransLogStress::Main() int opt; bool optError = false; - while ((opt = getopt(_argc, _argv, "d:p:t:f:s:v:c:e:g:i:a:b:h")) != -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(optarg); @@ -692,7 +692,7 @@ TransLogStress::Main() printConfig(); std::this_thread::sleep_for(sleepTime); - if (_argc != optind || optError) { + if (argc != optind || optError) { usage(); return -1; } @@ -758,8 +758,8 @@ TransLogStress::Main() } -int main(int argc, char ** argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); search::transactionlog::TransLogStress myApp; - return myApp.Entry(argc, argv); + return myApp.main(argc, argv); } diff --git a/searchsummary/src/tests/docsumformat/docsum-pack.cpp b/searchsummary/src/tests/docsumformat/docsum-pack.cpp index a80c030ef6e..ed1ba23017c 100644 --- a/searchsummary/src/tests/docsumformat/docsum-pack.cpp +++ b/searchsummary/src/tests/docsumformat/docsum-pack.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include LOG_SETUP("docsum-pack"); @@ -15,7 +15,7 @@ using namespace search::docsummary; void FastS_block_usr2() {} -class MyApp : public FastOS_Application +class MyApp { private: bool _rc; @@ -47,7 +47,7 @@ public: void TestFailOrder(); void TestBasicInplace(); - int Main() override; + int main(int argc, char **argv); }; MyApp::MyApp() @@ -337,7 +337,7 @@ MyApp::TestBasicInplace() } int -MyApp::Main() +MyApp::main(int, char **) { _rc = true; _cnt = 0; @@ -373,9 +373,8 @@ MyApp::Main() return (_rc ? 0 : 1); } -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); MyApp myapp; - return myapp.Entry(argc, argv); + return myapp.main(argc, argv); } diff --git a/searchsummary/src/tests/docsummary/positionsdfw_test.cpp b/searchsummary/src/tests/docsummary/positionsdfw_test.cpp index b9469ca2102..11f0d0eb6d6 100644 --- a/searchsummary/src/tests/docsummary/positionsdfw_test.cpp +++ b/searchsummary/src/tests/docsummary/positionsdfw_test.cpp @@ -113,7 +113,7 @@ struct MyGetDocsumsStateCallback : GetDocsumsStateCallback { }; template -void checkWritePositionField(Test &test, AttrType &attr, +void checkWritePositionField(AttrType &attr, uint32_t doc_id, const vespalib::string &expect_json) { for (AttributeVector::DocId i = 0; i < doc_id + 1; ) { attr.addDoc(i); @@ -143,16 +143,16 @@ void checkWritePositionField(Test &test, AttrType &attr, writer->insertField(doc_id, &state, res_type, inserter); test::SlimeValue expected(expect_json); - test.EXPECT_EQUAL(expected.slime, target); + EXPECT_EQUAL(expected.slime, target); } void Test::requireThat2DPositionFieldIsWritten() { SingleInt64ExtAttribute attr("foo"); - checkWritePositionField(*this, attr, 0x3e, "{x:6,y:7,latlong:'N0.000007;E0.000006'}"); - checkWritePositionField(*this, attr, 007, "{x:-1,y:-1,latlong:'S0.000001;W0.000001'}"); - checkWritePositionField(*this, attr, 0x42, "{x:0,y:-1,latlong:'S0.000001;E0.000000'}"); - checkWritePositionField(*this, attr, 0x17, "{x:-16711935,y:16711935,latlong:'N16.711935;W16.711935'}"); - checkWritePositionField(*this, attr, 42, "null"); + checkWritePositionField(attr, 0x3e, "{x:6,y:7,latlong:'N0.000007;E0.000006'}"); + checkWritePositionField(attr, 007, "{x:-1,y:-1,latlong:'S0.000001;W0.000001'}"); + checkWritePositionField(attr, 0x42, "{x:0,y:-1,latlong:'S0.000001;E0.000000'}"); + checkWritePositionField(attr, 0x17, "{x:-16711935,y:16711935,latlong:'N16.711935;W16.711935'}"); + checkWritePositionField(attr, 42, "null"); } } // namespace diff --git a/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp b/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp index 42000b3e235..724cf338497 100644 --- a/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp +++ b/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "extractkeywordstest.h" +#include #include #include "simplequerystack.h" #include @@ -9,7 +10,7 @@ #define NUMTESTS 5 int -ExtractKeywordsTest::Main() +ExtractKeywordsTest::main(int argc, char **argv) { int doTest[NUMTESTS]; int low, high, accnum, num; @@ -18,18 +19,18 @@ ExtractKeywordsTest::Main() int multiplier = 1; bool failed = false; - if (_argc == 1) - return Usage(_argv[0]); + if (argc == 1) + return Usage(argv[0]); // default initialize to not run any tests. for (int n = 0; n < NUMTESTS; n++) doTest[n] = 0; // parse the command line arguments - for (int i = 1; i < _argc; i++) { + for (int i = 1; i < argc; i++) { low = 0; high = NUMTESTS - 1; - char *p = _argv[i]; + char *p = argv[i]; // Check if a multiplier is specified if (*p == '*') { @@ -287,10 +288,8 @@ ExtractKeywordsTest::Usage(char *progname) return EXIT_FAILURE; } -int -main(int argc, char** argv) -{ +int main(int argc, char** argv) { + vespalib::SignalHandler::PIPE.ignore(); ExtractKeywordsTest tester; - return tester.Entry(argc, argv); + return tester.main(argc, argv); } - diff --git a/searchsummary/src/tests/extractkeywords/extractkeywordstest.h b/searchsummary/src/tests/extractkeywords/extractkeywordstest.h index 2e07717821a..6bd07d8a111 100644 --- a/searchsummary/src/tests/extractkeywords/extractkeywordstest.h +++ b/searchsummary/src/tests/extractkeywords/extractkeywordstest.h @@ -2,11 +2,9 @@ #pragma once -#include - namespace search::docsummary { class KeywordExtractor; } -class ExtractKeywordsTest : public FastOS_Application +class ExtractKeywordsTest { private: ExtractKeywordsTest(const ExtractKeywordsTest &); @@ -14,7 +12,6 @@ private: search::docsummary::KeywordExtractor *_extractor; - int Main() override; int Usage(char *progname); bool ShowResult(int testNo, const char *actual, const char *correct); bool RunTest(int i, bool verify); @@ -23,5 +20,6 @@ public: ExtractKeywordsTest() : _extractor(nullptr) {} + int main(int argc, char **argv); }; diff --git a/slobrok/src/apps/check_slobrok/check_slobrok.cpp b/slobrok/src/apps/check_slobrok/check_slobrok.cpp index d533292113a..1b69588a9fc 100644 --- a/slobrok/src/apps/check_slobrok/check_slobrok.cpp +++ b/slobrok/src/apps/check_slobrok/check_slobrok.cpp @@ -1,6 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include +#include #include #include #include @@ -10,7 +10,7 @@ #include LOG_SETUP("check_slobrok"); -class Slobrok_Checker : public FastOS_Application +class Slobrok_Checker { private: std::unique_ptr _server; @@ -21,11 +21,11 @@ private: public: Slobrok_Checker() : _server(), _target(nullptr) {} - virtual ~Slobrok_Checker(); - int usage(); + ~Slobrok_Checker(); + int usage(const char *self); void initRPC(const char *spec); void finiRPC(); - int Main() override; + int main(int argc, char **argv); }; Slobrok_Checker::~Slobrok_Checker() @@ -36,9 +36,9 @@ Slobrok_Checker::~Slobrok_Checker() int -Slobrok_Checker::usage() +Slobrok_Checker::usage(const char *self) { - fprintf(stderr, "usage: %s \n", _argv[0]); + fprintf(stderr, "usage: %s \n", self); return 1; } @@ -65,14 +65,14 @@ Slobrok_Checker::finiRPC() int -Slobrok_Checker::Main() +Slobrok_Checker::main(int argc, char **argv) { - if (_argc != 2) { - return usage(); + if (argc != 2) { + return usage(argv[0]); } - int port = atoi(_argv[1]); + int port = atoi(argv[1]); if (port == 0) { - initRPC(_argv[1]); + initRPC(argv[1]); } else { std::ostringstream tmp; tmp << "tcp/localhost:"; @@ -104,8 +104,8 @@ Slobrok_Checker::Main() return failed; } -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); Slobrok_Checker sb_checker; - return sb_checker.Entry(argc, argv); + return sb_checker.main(argc, argv); } diff --git a/slobrok/src/apps/sbcmd/sbcmd.cpp b/slobrok/src/apps/sbcmd/sbcmd.cpp index 56d1b6f5a41..64c29cd92a9 100644 --- a/slobrok/src/apps/sbcmd/sbcmd.cpp +++ b/slobrok/src/apps/sbcmd/sbcmd.cpp @@ -1,6 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include +#include #include #include #include @@ -9,7 +9,7 @@ #include LOG_SETUP("vespa-slobrok-cmd"); -class Slobrok_CMD : public FastOS_Application +class Slobrok_CMD { private: std::unique_ptr _server; @@ -20,11 +20,11 @@ private: public: Slobrok_CMD() : _server(), _target(nullptr) {} - virtual ~Slobrok_CMD(); - int usage(); + ~Slobrok_CMD(); + int usage(const char *self); void initRPC(const char *spec); void finiRPC(); - int Main() override; + int main(int argc, char **argv); }; Slobrok_CMD::~Slobrok_CMD() @@ -34,9 +34,9 @@ Slobrok_CMD::~Slobrok_CMD() } int -Slobrok_CMD::usage() +Slobrok_CMD::usage(const char *self) { - fprintf(stderr, "usage: %s [args]\n", _argv[0]); + fprintf(stderr, "usage: %s [args]\n", self); fprintf(stderr, "with cmd one of:\n"); fprintf(stderr, " slobrok.callback.listNamesServed\n"); fprintf(stderr, " slobrok.internal.listManagedRpcServers\n"); @@ -75,14 +75,14 @@ Slobrok_CMD::finiRPC() int -Slobrok_CMD::Main() +Slobrok_CMD::main(int argc, char **argv) { - if (_argc < 3) { - return usage(); + if (argc < 3) { + return usage(argv[0]); } - int port = atoi(_argv[1]); + int port = atoi(argv[1]); if (port == 0) { - initRPC(_argv[1]); + initRPC(argv[1]); } else { std::ostringstream tmp; tmp << "tcp/localhost:"; @@ -95,39 +95,39 @@ Slobrok_CMD::Main() FRT_RPCRequest *req = _server->supervisor().AllocRPCRequest(); - req->SetMethodName(_argv[2]); - if (strcmp(_argv[2], "slobrok.admin.listAllRpcServers") == 0) { + req->SetMethodName(argv[2]); + if (strcmp(argv[2], "slobrok.admin.listAllRpcServers") == 0) { threeTables = true; // no params - } else if (strcmp(_argv[2], "slobrok.internal.listManagedRpcServers") == 0) { + } else if (strcmp(argv[2], "slobrok.internal.listManagedRpcServers") == 0) { twoTables = true; // no params - } else if (strcmp(_argv[2], "slobrok.callback.listNamesServed") == 0 - || strcmp(_argv[2], "slobrok.internal.listManagedRpcServers") == 0 - || strcmp(_argv[2], "slobrok.admin.listAllRpcServers") == 0 - || strcmp(_argv[2], "slobrok.system.stop") == 0 - || strcmp(_argv[2], "slobrok.system.version") == 0 - || strcmp(_argv[2], "system.stop") == 0) + } else if (strcmp(argv[2], "slobrok.callback.listNamesServed") == 0 + || strcmp(argv[2], "slobrok.internal.listManagedRpcServers") == 0 + || strcmp(argv[2], "slobrok.admin.listAllRpcServers") == 0 + || strcmp(argv[2], "slobrok.system.stop") == 0 + || strcmp(argv[2], "slobrok.system.version") == 0 + || strcmp(argv[2], "system.stop") == 0) { // no params - } else if (strcmp(_argv[2], "slobrok.lookupRpcServer") == 0 - && _argc == 4) + } else if (strcmp(argv[2], "slobrok.lookupRpcServer") == 0 + && argc == 4) { twoTables = true; // one param - req->GetParams()->AddString(_argv[3]); - } else if ((strcmp(_argv[2], "slobrok.registerRpcServer") == 0 - || strcmp(_argv[2], "slobrok.unregisterRpcServer") == 0 - || strcmp(_argv[2], "slobrok.admin.addPeer") == 0 - || strcmp(_argv[2], "slobrok.admin.removePeer") == 0) - && _argc == 5) + req->GetParams()->AddString(argv[3]); + } else if ((strcmp(argv[2], "slobrok.registerRpcServer") == 0 + || strcmp(argv[2], "slobrok.unregisterRpcServer") == 0 + || strcmp(argv[2], "slobrok.admin.addPeer") == 0 + || strcmp(argv[2], "slobrok.admin.removePeer") == 0) + && argc == 5) { // two params - req->GetParams()->AddString(_argv[3]); - req->GetParams()->AddString(_argv[4]); + req->GetParams()->AddString(argv[3]); + req->GetParams()->AddString(argv[4]); } else { finiRPC(); - return usage(); + return usage(argv[0]); } _target->InvokeSync(req, 5.0); @@ -186,8 +186,8 @@ Slobrok_CMD::Main() return 0; } -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); Slobrok_CMD sb_cmd; - return sb_cmd.Entry(argc, argv); + return sb_cmd.main(argc, argv); } diff --git a/slobrok/src/apps/slobrok/slobrok.cpp b/slobrok/src/apps/slobrok/slobrok.cpp index 791b98996fe..43a2f84feb4 100644 --- a/slobrok/src/apps/slobrok/slobrok.cpp +++ b/slobrok/src/apps/slobrok/slobrok.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include @@ -14,10 +14,10 @@ LOG_SETUP("vespa-slobrok"); **/ namespace slobrok { -class App : public FastOS_Application +class App { public: - int Main() override; + int main(int argc, char **argv); }; static std::unique_ptr mainobj; @@ -47,13 +47,13 @@ hook_sigterm(void) int -App::Main() +App::main(int argc, char **argv) { uint32_t portnum = 2773; vespalib::string cfgId; int c; - while ((c = getopt(_argc, _argv, "c:s:p:N")) != -1) { + while ((c = getopt(argc, argv, "c:s:p:N")) != -1) { switch (c) { case 'c': cfgId = std::string(optarg); @@ -105,9 +105,8 @@ App::Main() } // namespace slobrok -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); slobrok::App slobrok; - return slobrok.Entry(argc, argv); + return slobrok.main(argc, argv); } diff --git a/slobrok/src/tests/startsome/rpc_info.cpp b/slobrok/src/tests/startsome/rpc_info.cpp index 6f0fd679003..a37cfa24889 100644 --- a/slobrok/src/tests/startsome/rpc_info.cpp +++ b/slobrok/src/tests/startsome/rpc_info.cpp @@ -1,12 +1,12 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include +#include #include #include #include -class RPCInfo : public FastOS_Application +class RPCInfo { public: @@ -67,17 +67,17 @@ public: } - int Main() override + int main(int argc, char **argv) { - if (_argc < 2) { + if (argc < 2) { printf("usage : rpc_info [verbose]\n"); return 1; } - bool verbose = (_argc > 2 && strcmp(_argv[2], "verbose") == 0); + bool verbose = (argc > 2 && strcmp(argv[2], "verbose") == 0); fnet::frt::StandaloneFRT server; FRT_Supervisor & supervisor = server.supervisor(); - FRT_Target *target = supervisor.GetTarget(_argv[1]); + FRT_Target *target = supervisor.GetTarget(argv[1]); FRT_RPCRequest *m_list = nullptr; FRT_RPCRequest *info = nullptr; @@ -85,7 +85,7 @@ public: info->SetMethodName("frt.rpc.ping"); target->InvokeSync(info, 5.0); if (info->IsError()) { - fprintf(stderr, "Error talking to %s\n", _argv[1]); + fprintf(stderr, "Error talking to %s\n", argv[1]); FreeReqs(m_list, info); return 1; } @@ -129,9 +129,8 @@ public: }; -int -main(int argc, char **argv) -{ - RPCInfo myapp; - return myapp.Entry(argc, argv); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + RPCInfo myapp; + return myapp.main(argc, argv); } diff --git a/slobrok/src/tests/startsome/tstdst.cpp b/slobrok/src/tests/startsome/tstdst.cpp index 8e58fc23b27..d83d79b3a00 100644 --- a/slobrok/src/tests/startsome/tstdst.cpp +++ b/slobrok/src/tests/startsome/tstdst.cpp @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include -#include +#include #include #include #include @@ -180,16 +180,16 @@ TstEnv::MainLoop() } -class App : public FastOS_Application +class App { public: - int Main() override { + int main(int argc, char **argv) { int sbport = 2773; int myport = 2774; const char *rpcsrvname = "testrpcsrv/17"; int c; - while ((c = getopt(_argc, _argv, "n:p:s:")) != -1) { + while ((c = getopt(argc, argv, "n:p:s:")) != -1) { switch (c) { case 'p': myport = atoi(optarg); @@ -215,9 +215,8 @@ public: } // namespace testrpcserver -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); testrpcserver::App tstdst; - return tstdst.Entry(argc, argv); + return tstdst.main(argc, argv); } diff --git a/storage/src/vespa/storage/tools/storage-cmd.cpp b/storage/src/vespa/storage/tools/storage-cmd.cpp index 8c2a1f40529..12299c7458e 100644 --- a/storage/src/vespa/storage/tools/storage-cmd.cpp +++ b/storage/src/vespa/storage/tools/storage-cmd.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -11,7 +11,7 @@ #include LOG_SETUP("vespa-storage-cmd"); -class RPCClient : public FastOS_Application +class RPCClient { private: static bool addArg(FRT_RPCRequest *req, const char *param) { @@ -49,8 +49,8 @@ private: } public: - int Main() override { - if (_argc < 3) { + int main(int argc, char **argv) { + if (argc < 3) { fprintf(stderr, "usage: vespa-storage-cmd [args]\n"); fprintf(stderr, "Calls RPC method on a storage/distributor process\n"); fprintf(stderr, "Call frt.rpc.getMethodList to get available RPC methods\n"); @@ -68,20 +68,20 @@ public: std::this_thread::sleep_for(10ms); } - slobrok::api::MirrorAPI::SpecList list = mirror.lookup(_argv[1]); + slobrok::api::MirrorAPI::SpecList list = mirror.lookup(argv[1]); if (list.size() == 0) { - fprintf(stderr, "No servers found matching %s\n", _argv[1]); + fprintf(stderr, "No servers found matching %s\n", argv[1]); } for (size_t j = 0; j < list.size(); j++) { FRT_Target *target = supervisor.supervisor().GetTarget(list[j].second.c_str()); // If not fleet controller, need to connect first. - if (strstr(_argv[1], "fleetcontroller") == nullptr) { + if (strstr(argv[1], "fleetcontroller") == nullptr) { FRT_RPCRequest *req = supervisor.supervisor().AllocRPCRequest(); req->SetMethodName("vespa.storage.connect"); - req->GetParams()->AddString(_argv[1]); + req->GetParams()->AddString(argv[1]); target->InvokeSync(req, 10.0); if (req->GetErrorCode() != FRTE_NO_ERROR) { @@ -94,11 +94,11 @@ public: } FRT_RPCRequest *req = supervisor.supervisor().AllocRPCRequest(); - req->SetMethodName(_argv[2]); + req->SetMethodName(argv[2]); - for (int i = 3; i < _argc; ++i) { - if (!addArg(req, _argv[i])) { - fprintf(stderr, "could not parse parameter: '%s'\n", _argv[i]); + for (int i = 3; i < argc; ++i) { + if (!addArg(req, argv[i])) { + fprintf(stderr, "could not parse parameter: '%s'\n", argv[i]); retCode = 2; break; } @@ -122,9 +122,8 @@ public: } }; -int -main(int argc, char **argv) -{ - RPCClient myapp; - return myapp.Entry(argc, argv); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + RPCClient myapp; + return myapp.main(argc, argv); } diff --git a/storageserver/src/apps/storaged/storage.cpp b/storageserver/src/apps/storaged/storage.cpp index c8352354175..87c03714492 100644 --- a/storageserver/src/apps/storaged/storage.cpp +++ b/storageserver/src/apps/storaged/storage.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -49,8 +49,7 @@ Process::UP createProcess(vespalib::stringref configId) { } // End of anonymous namespace -class StorageApp : public FastOS_Application, - private vespalib::ProgramOptions +class StorageApp : private vespalib::ProgramOptions { std::string _configId; bool _showSyntax; @@ -69,11 +68,11 @@ public: _signalCond.notify_one(); } void handleSignals(); + int main(int argc, char **argv); private: vespalib::duration getMaxShutDownTime() { return std::chrono::milliseconds(_maxShutdownTime); } - bool Init() override; - int Main() override; + bool init(int argc, char **argv); bool gotSignal() { return _lastSignal != 0; } }; @@ -98,10 +97,9 @@ StorageApp::StorageApp() StorageApp::~StorageApp() = default; -bool StorageApp::Init() +bool StorageApp::init(int argc, char **argv) { - FastOS_Application::Init(); - setCommandLineArguments(FastOS_Application::_argc, FastOS_Application::_argv); + setCommandLineArguments(argc, argv); try{ parse(); } catch (vespalib::InvalidCommandLineArgumentsException& e) { @@ -157,8 +155,11 @@ void StorageApp::handleSignals() } } -int StorageApp::Main() +int StorageApp::main(int argc, char **argv) { + if (!init(argc, argv)) { + return 255; + } try{ _process = createProcess(_configId); _process->setupConfig(600000ms); @@ -206,11 +207,11 @@ int StorageApp::Main() } // storage -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); storage::StorageApp app; storage::sigtramp = &app; - int retval = app.Entry(argc,argv); + int retval = app.main(argc,argv); storage::sigtramp = nullptr; LOG(debug, "Exiting"); return retval; diff --git a/vbench/src/apps/dumpurl/dumpurl.cpp b/vbench/src/apps/dumpurl/dumpurl.cpp index 515f4b5ae3e..9de22fc0887 100644 --- a/vbench/src/apps/dumpurl/dumpurl.cpp +++ b/vbench/src/apps/dumpurl/dumpurl.cpp @@ -3,17 +3,11 @@ #include #include #include -#include +#include #include using namespace vbench; -class App : public FastOS_Application -{ -public: - int Main() override; -}; - struct MyHttpHandler : public HttpResultHandler { void handleHeader(const string &name, const string &value) override { fprintf(stderr, "got header: '%s': '%s'\n", name.c_str(), value.c_str()); @@ -27,20 +21,14 @@ struct MyHttpHandler : public HttpResultHandler { } }; -int -App::Main() -{ - if (_argc != 4) { +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + if (argc != 4) { printf("usage: dumpurl \n"); return -1; } auto null_crypto = std::make_shared(); MyHttpHandler myHandler; - bool ok = HttpClient::fetch(*null_crypto, ServerSpec(_argv[1], atoi(_argv[2])), _argv[3], myHandler); + bool ok = HttpClient::fetch(*null_crypto, ServerSpec(argv[1], atoi(argv[2])), argv[3], myHandler); return ok ? 0 : 1; } - -int main(int argc, char **argv) { - App app; - return app.Entry(argc, argv); -} diff --git a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp index ad0a42e0c4e..017abfdf28c 100644 --- a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp +++ b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -221,13 +221,13 @@ Options::Options(Mode mode) Options::~Options() {} -struct StateApp : public FastOS_Application { +struct StateApp { Options _options; StateApp(std::string calledAs) : _options(getMode(calledAs)) {} - int Main() override { - _options.setCommandLineArguments(_argc, _argv); + int main(int argc, char **argv) { + _options.setCommandLineArguments(argc, argv); try{ _options.parse(); } catch (vespalib::InvalidCommandLineArgumentsException& e) { @@ -455,11 +455,9 @@ struct StateApp : public FastOS_Application { } // storage -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); assert(argc > 0); storage::StateApp client(argv[0]); - return client.Entry(argc, argv); + return client.main(argc, argv); } - diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp b/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp index 75d8f770c1a..b0c5545f3ac 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp +++ b/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp @@ -33,14 +33,14 @@ Application::Application() : Application::~Application() = default; - int -Application::Main() +int +Application::main(int argc, char **argv) { try { - if (_argc == 1) { + if (argc == 1) { _params.setListRoutes(true); _params.setListHops(true); - } else if (!parseArgs()) { + } else if (!parseArgs(argc, argv)) { return EXIT_SUCCESS; } @@ -102,73 +102,73 @@ Application::Main() } bool -Application::parseArgs() +Application::parseArgs(int argc, char **argv) { - for (int arg = 1; arg < _argc; arg++) { - if (strcasecmp(_argv[arg], "--documenttypesconfigid") == 0) { - if (++arg < _argc) { - _params.setDocumentTypesConfigId(_argv[arg]); + for (int arg = 1; arg < argc; arg++) { + if (strcasecmp(argv[arg], "--documenttypesconfigid") == 0) { + if (++arg < argc) { + _params.setDocumentTypesConfigId(argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'documenttypesconfigid'."); } - } else if (strcasecmp(_argv[arg], "--dump") == 0) { + } else if (strcasecmp(argv[arg], "--dump") == 0) { _params.setDump(true); - } else if (strcasecmp(_argv[arg], "--help") == 0 || - strcasecmp(_argv[arg], "-h") == 0) { + } else if (strcasecmp(argv[arg], "--help") == 0 || + strcasecmp(argv[arg], "-h") == 0) { printHelp(); return false; - } else if (strcasecmp(_argv[arg], "--hop") == 0) { - if (++arg < _argc) { - _params.getHops().push_back(_argv[arg]); + } else if (strcasecmp(argv[arg], "--hop") == 0) { + if (++arg < argc) { + _params.getHops().push_back(argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'hop'."); } - } else if (strcasecmp(_argv[arg], "--hops") == 0) { + } else if (strcasecmp(argv[arg], "--hops") == 0) { _params.setListHops(true); - } else if (strcasecmp(_argv[arg], "--identity") == 0) { - if (++arg < _argc) { - _params.getRPCNetworkParams().setIdentity(mbus::Identity(_argv[arg])); + } else if (strcasecmp(argv[arg], "--identity") == 0) { + if (++arg < argc) { + _params.getRPCNetworkParams().setIdentity(mbus::Identity(argv[arg])); } else { throw config::InvalidConfigException("Missing value for parameter 'identity'."); } - } else if (strcasecmp(_argv[arg], "--listenport") == 0) { - if (++arg < _argc) { - _params.getRPCNetworkParams().setListenPort(atoi(_argv[arg])); + } else if (strcasecmp(argv[arg], "--listenport") == 0) { + if (++arg < argc) { + _params.getRPCNetworkParams().setListenPort(atoi(argv[arg])); } else { throw config::InvalidConfigException("Missing value for parameter 'listenport'."); } - } else if (strcasecmp(_argv[arg], "--protocol") == 0) { - if (++arg < _argc) { - _params.setProtocol(_argv[arg]); + } else if (strcasecmp(argv[arg], "--protocol") == 0) { + if (++arg < argc) { + _params.setProtocol(argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'protocol'."); } - } else if (strcasecmp(_argv[arg], "--route") == 0) { - if (++arg < _argc) { - _params.getRoutes().push_back(_argv[arg]); + } else if (strcasecmp(argv[arg], "--route") == 0) { + if (++arg < argc) { + _params.getRoutes().push_back(argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'route'."); } - } else if (strcasecmp(_argv[arg], "--routes") == 0) { + } else if (strcasecmp(argv[arg], "--routes") == 0) { _params.setListRoutes(true); - } else if (strcasecmp(_argv[arg], "--routingconfigid") == 0) { - if (++arg < _argc) { - _params.setRoutingConfigId(_argv[arg]); + } else if (strcasecmp(argv[arg], "--routingconfigid") == 0) { + if (++arg < argc) { + _params.setRoutingConfigId(argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'routingconfigid'."); } - } else if (strcasecmp(_argv[arg], "--services") == 0) { + } else if (strcasecmp(argv[arg], "--services") == 0) { _params.setListServices(true); - } else if (strcasecmp(_argv[arg], "--slobrokconfigid") == 0) { - if (++arg < _argc) { - _params.setSlobrokId(_argv[arg]); + } else if (strcasecmp(argv[arg], "--slobrokconfigid") == 0) { + if (++arg < argc) { + _params.setSlobrokId(argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'slobrokconfigid'."); } - } else if (strcasecmp(_argv[arg], "--verify") == 0) { + } else if (strcasecmp(argv[arg], "--verify") == 0) { _params.setVerify(true); } else { - throw config::InvalidConfigException(vespalib::make_string("Unknown option '%s'.", _argv[arg])); + throw config::InvalidConfigException(vespalib::make_string("Unknown option '%s'.", argv[arg])); } } return true; diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/application.h b/vespaclient/src/vespa/vespaclient/vesparoute/application.h index b7a33134b0e..0e111a72359 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/application.h +++ b/vespaclient/src/vespa/vespaclient/vesparoute/application.h @@ -5,21 +5,20 @@ #include "params.h" #include #include -#include #include namespace vesparoute { /** * Command-line feeder running on document api. */ -class Application : public FastOS_Application { +class Application { private: std::unique_ptr _net; std::unique_ptr _mbus; Params _params; /** Parses the arguments of this application into the given params object. */ - bool parseArgs(); + bool parseArgs(int argc, char **argv); /** Prints help for this application. */ void printHelp() const; @@ -63,7 +62,7 @@ private: public: Application(); ~Application(); - int Main() override; + int main(int argc, char **argv); }; } diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/main.cpp b/vespaclient/src/vespa/vespaclient/vesparoute/main.cpp index bc55cc18366..d34989b30ee 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/main.cpp +++ b/vespaclient/src/vespa/vespaclient/vesparoute/main.cpp @@ -3,12 +3,10 @@ #include "application.h" #include -int -main(int argc, char** argv) -{ +int main(int argc, char** argv) { vespalib::SignalHandler::PIPE.ignore(); vesparoute::Application app; - int ret = app.Entry(argc, argv); + int ret = app.main(argc, argv); if (ret) { printf("Non-zero exit status: %d\n", ret); } diff --git a/vespalib/src/tests/btree/btree-scan-speed/btree_scan_speed_test.cpp b/vespalib/src/tests/btree/btree-scan-speed/btree_scan_speed_test.cpp index e2df9996dcb..352ef5ef70a 100644 --- a/vespalib/src/tests/btree/btree-scan-speed/btree_scan_speed_test.cpp +++ b/vespalib/src/tests/btree/btree-scan-speed/btree_scan_speed_test.cpp @@ -17,8 +17,6 @@ #include #include -#include - using vespalib::btree::BTree; using vespalib::btree::BTreeNode; using vespalib::btree::BTreeTraits; @@ -29,11 +27,12 @@ enum class ScanMethod FUNCTOR }; -class ScanSpeed : public FastOS_Application +class ScanSpeed { template void work_loop(ScanMethod scan_method); - int Main() override; +public: + int main(); }; @@ -162,7 +161,7 @@ ScanSpeed::work_loop(ScanMethod scan_method) int -ScanSpeed::Main() +ScanSpeed::main() { using SmallTraits = BTreeTraits<4, 4, 31, false>; using DefTraits = vespalib::btree::BTreeDefaultTraits; @@ -179,4 +178,7 @@ ScanSpeed::Main() return 0; } -FASTOS_MAIN(ScanSpeed); +int main(int, char **) { + ScanSpeed app; + return app.main(); +} diff --git a/vespalib/src/tests/btree/iteratespeed.cpp b/vespalib/src/tests/btree/iteratespeed.cpp index 92a756a6eaa..fceaf01a785 100644 --- a/vespalib/src/tests/btree/iteratespeed.cpp +++ b/vespalib/src/tests/btree/iteratespeed.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include @@ -32,14 +31,15 @@ enum class IterateMethod LAMBDA }; -class IterateSpeed : public FastOS_Application +class IterateSpeed { template void workLoop(int loops, bool enableForward, bool enableBackwards, bool enableLambda, int leafSlots); void usage(); - int Main() override; +public: + int main(int argc, char **argv); }; @@ -134,7 +134,7 @@ IterateSpeed::usage() } int -IterateSpeed::Main() +IterateSpeed::main(int argc, char **argv) { int c; int loops = 1; @@ -142,7 +142,7 @@ IterateSpeed::Main() bool forwards = false; bool lambda = false; int leafSlots = 0; - while ((c = getopt(_argc, _argv, "F:bc:fl")) != -1) { + while ((c = getopt(argc, argv, "F:bc:fl")) != -1) { switch (c) { case 'F': leafSlots = atoi(optarg); @@ -203,6 +203,7 @@ IterateSpeed::Main() } -FASTOS_MAIN(vespalib::btree::IterateSpeed); - - +int main(int argc, char **argv) { + vespalib::btree::IterateSpeed app; + return app.main(argc, argv); +} diff --git a/vespalib/src/vespa/vespalib/testkit/test_macros.h b/vespalib/src/vespa/vespalib/testkit/test_macros.h index ebf3e06d283..41816e13c2d 100644 --- a/vespalib/src/vespa/vespalib/testkit/test_macros.h +++ b/vespalib/src/vespa/vespalib/testkit/test_macros.h @@ -4,7 +4,6 @@ #include "test_master.h" #include "test_comparators.h" -#include #define TEST_STR(str) #str #define TEST_CAT_IMPL(a, b) a ## b @@ -18,22 +17,14 @@ #define TEST_TRACE() TEST_MASTER.trace(__FILE__, __LINE__) #define TEST_THREAD(name) TEST_MASTER.setThreadName(name) #define TEST_BARRIER() TEST_MASTER.awaitThreadBarrier(__FILE__, __LINE__) -#define TEST_MAIN() \ - void test_kit_main(); \ - struct TestKitApp : FastOS_Application \ - { \ - int Main() override; \ - }; \ - int main(int argc, char **argv) \ - { \ - TestKitApp app; \ - return app.Entry(argc, argv); \ - } \ - int TestKitApp::Main() { \ - TEST_MASTER.init(__FILE__); \ - test_kit_main(); \ - return (TEST_MASTER.fini() ? 0 : 1); \ - } \ +#define TEST_MAIN() \ + void test_kit_main(); \ + int main(int, char **) \ + { \ + TEST_MASTER.init(__FILE__); \ + test_kit_main(); \ + return (TEST_MASTER.fini() ? 0 : 1); \ + } \ void test_kit_main() //----------------------------------------------------------------------------- diff --git a/vespalib/src/vespa/vespalib/testkit/test_master.cpp b/vespalib/src/vespa/vespalib/testkit/test_master.cpp index 64282d23d6a..434d08d6c7a 100644 --- a/vespalib/src/vespa/vespalib/testkit/test_master.cpp +++ b/vespalib/src/vespa/vespalib/testkit/test_master.cpp @@ -2,6 +2,7 @@ #include "test_master.h" #include +#include #include #include @@ -176,6 +177,7 @@ void TestMaster::init(const char *name) { lock_guard guard(_lock); + SignalHandler::PIPE.ignore(); _name = skip_path(name); fprintf(stderr, "%s: info: running test suite '%s'\n", _name.c_str(), _name.c_str()); } diff --git a/vespalib/src/vespa/vespalib/testkit/testapp.cpp b/vespalib/src/vespa/vespalib/testkit/testapp.cpp index 4a7f0fd20e7..34d7e4eaa0e 100644 --- a/vespalib/src/vespa/vespalib/testkit/testapp.cpp +++ b/vespalib/src/vespa/vespalib/testkit/testapp.cpp @@ -4,25 +4,14 @@ namespace vespalib { -TestMaster &TestApp::master(TestMaster::master); - -TestApp::TestApp() - : FastOS_Application(), - _name("") -{ } - -TestApp::~TestApp() { } - -void -TestApp::ReportInit(const char *name) +int +TestApp::Entry(int argc, char **argv) { - _name = name; + _argc = argc; + _argv = argv; + return Main(); } -bool -TestApp::ReportConclusion() -{ - return true; -} +TestApp::~TestApp() = default; } // namespace vespalib diff --git a/vespalib/src/vespa/vespalib/testkit/testapp.h b/vespalib/src/vespa/vespalib/testkit/testapp.h index 8ffb9958555..bfa322ccac5 100644 --- a/vespalib/src/vespa/vespalib/testkit/testapp.h +++ b/vespalib/src/vespa/vespalib/testkit/testapp.h @@ -2,13 +2,9 @@ #pragma once #include "test_kit.h" -#include -#undef TEST_MASTER -#define TEST_MASTER vespalib::TestApp::master - -#define TEST_INIT(name) do { ReportInit(name); TEST_MASTER.init(name); } while(false) -#define TEST_DONE() do { ReportConclusion(); return TEST_MASTER.fini() ? 0 : 1; } while(false) +#define TEST_INIT(name) do { TEST_MASTER.init(name); } while(false) +#define TEST_DONE() do { return TEST_MASTER.fini() ? 0 : 1; } while(false) #define TEST_APPHOOK(app) \ int main(int argc, char **argv) \ @@ -25,163 +21,15 @@ namespace vespalib { -/** - * @brief TestApp is used to create executable unit tests - * - * TestApp is a subclass of FastOS_Application that is tailored to - * create small executable programs containing unit tests. The idea is - * that you create a class that subclasses TestApp and use a set of - * macros to test your code. It is similar to the concept used in - * cppunit except that your tests become programs rather than library - * code. - * - * Below follows an explanation of all the available macros. Note that - * while you can also invoke the methods in this class directly, most - * tests will only need to use macros. Also, some features like - * grabbing the text making up a boolean expression, the file name and - * the line number of a statement is only possible with macros. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
TEST_INIT(name) - * Invokes the ReportInit method. name is the name of this - * test. - *
TEST_GROUP(val) - * Invokes the SetGroupModulo method. val is an integer - * defining the number of successful tests that may be logged at - * once. If val is 0, all consecutive successful test cases - * will be reported at once. If val is 1, all tests will be - * reported by separate log messages (this is the default). - *
TEST_DEBUG(lhsFile, rhsFile) - * Invokes the OpenDebugFiles method. lhs and rhs are - * file names for files where we want the left hand side and right - * hand side values to be stored. Diffing these files will simplify - * debugging of failed tests. - *
TEST_PUSH_STATE(msg) - * Invokes the PushState function. msg is pushed on the - * internal state stack together with the current file and line - * number. The state stack is dumped when a test fails, unless the - * DumpState function is overridden. - *
TEST_POP_STATE() - * Invokes the PopState function. The topmost item on the state stack - * will be popped. If the state stack is empty, nothing will happen. - *
TEST_DO(statement) - * Pushes statement on the state stack, performs - * statement and finally pops the state stack. The intended - * use is to wrap function calls within TEST_DO in order to produce - * something that looks like a stack trace when the state stack is - * dumped. - *
EXPECT_TRUE(rc) - * Test that rc evaluates to true. rc must be an - * expression that can be evaluated as a boolean. This automatically - * creates a test case. The macro invokes the ReportTestResult - * method. - *
ASSERT_TRUE(rc) - * Does the same as EXPECT_TRUE except that the application is - * aborted if the test fails. This macro may be used to test that - * setup vital to the rest of the tests does not fail. - *
EXPECT_EQUAL(a, b) - * Test that a == b. - *
EXPECT_NOT_EQUAL(a, b) - * Test that a != b. - *
EXPECT_LESS(a, b) - * Test that a < b. - *
EXPECT_LESS_EQUAL(a, b) - * Test that a <= b. - *
EXPECT_GREATER(a, b) - * Test that a > b. - *
EXPECT_GREATER_EQUAL(a, b) - * Test that a >= b. - *
TEST_FLUSH() - * Invokes the FlushReport method. This is used to force the logging - * of successful test cases that are waiting to be logged due to - * grouping (see TEST_GROUP). - *
TEST_DONE() - * Invokes the ReportConclusion method and returns 0 if all test - * cases passed, 1 otherwise. This should be the last thing in your - * Main method. - *
TEST_APPHOOK(app) - * Creates the code needed to run the class app that must be - * a subclass of FastOS_Application. This will create a canonical - * main method launching your fastos application. - *
TEST_SETUP(test) - * Does the same as TEST_APPHOOK, but also creates a simple class - * named test that is a subclass of TestApp and contains only - * the Main method. If you want to add some helper methods to your - * test, use TEST_APPHOOK, otherwise use this one. - *
TEST_THREADS() - * This macro is used in tests that require thread support. If no - * thread support is available (fastos was compiled without - * threads), this macro will invoke the ReportNoThreads and call the - * TEST_DONE macro to exit the test. If thread support is available - * this macro does nothing. - *
- * - * Simple test example: - *
- * \#include 
- *
- * TEST_SETUP(Test)
- *
- * int
- * Test::Main()
- * {
- *     TEST_INIT("true_test");
- *     EXPECT_TRUE(true);
- *     TEST_DONE();
- * }
- * 
- **/ -class TestApp : public FastOS_Application +class TestApp { -private: - std::string _name; - public: - static TestMaster &master; + int _argc = 0; + char **_argv = nullptr; - TestApp(); + virtual int Main() = 0; + int Entry(int argc, char **argv); virtual ~TestApp(); - - /** - * @brief Obtain the name of this test - * - * @return test name - **/ - const char *GetName() { return _name.c_str(); } - - /** - * @brief Report test initialization - * - * @param name the name of this test - **/ - virtual void ReportInit(const char *name); - - /** - * @brief Report test summary - * - * @return true if all test cases passed - **/ - virtual bool ReportConclusion(); }; } // namespace vespalib - diff --git a/vespalib/src/vespa/vespalib/util/backtrace.cpp b/vespalib/src/vespa/vespalib/util/backtrace.cpp index 2241c292565..a020f6c33c0 100644 --- a/vespalib/src/vespa/vespalib/util/backtrace.cpp +++ b/vespalib/src/vespa/vespalib/util/backtrace.cpp @@ -13,9 +13,9 @@ namespace { /** * Convert input line of form eg. - * ./exception_test(_ZN27FastOS_ApplicationInterface5EntryEiPPc+0x0) [0x1234] + * ./exception_test(_ZN11Application5entryEiPPc+0x0) [0x1234] * to its demangled form - * ./exception_test(FastOS_ApplicationInterface::Entry(int, char**)+0x0) [0x1234] + * ./exception_test(Application::entry(int, char**)+0x0) [0x1234] * * Assumes everything between '(' and '+' is a mangled function signature. * diff --git a/vespalog/src/test/threads/testthreads.cpp b/vespalog/src/test/threads/testthreads.cpp index af0fe509080..d1767dd70ff 100644 --- a/vespalog/src/test/threads/testthreads.cpp +++ b/vespalog/src/test/threads/testthreads.cpp @@ -1,5 +1,4 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include #include #include #include @@ -77,10 +76,17 @@ LoggerThread::Run(FastOS_ThreadInterface *, void *) } -class ThreadTester : public FastOS_Application +class ThreadTester { public: - int Main() override; + int _argc = 0; + char **_argv = nullptr; + int Main(); + int Entry(int argc, char **argv) { + _argc = argc; + _argv = argv; + return Main(); + } }; int -- cgit v1.2.3