summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2022-04-06 12:18:08 +0000
committerHåvard Pettersen <havardpe@oath.com>2022-04-08 13:45:13 +0000
commit9fbcf76d088740aacf535e6482f86c833cfae871 (patch)
treec62dcd0f9cdcee9876b37c60f741958c14147f80 /searchcore
parent69454cef2fe53694eb5541e5f622a4e973c081bf (diff)
remove FastOS_Application
fixup (per application): - maybe ignore SIGPIPE - wire argc/argv untangle Vespa Test Framework strip down deprecated TestApp
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/apps/proton/proton.cpp25
-rw-r--r--searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp15
-rw-r--r--searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp16
-rw-r--r--searchcore/src/apps/vespa-feed-bm/vespa_feed_bm.cpp25
-rw-r--r--searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp84
-rw-r--r--searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp50
-rw-r--r--searchcore/src/apps/vespa-redistribute-bm/vespa_redistribute_bm.cpp25
-rw-r--r--searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp65
-rw-r--r--searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp2
-rw-r--r--searchcore/src/tests/proton/matching/query_test.cpp22
10 files changed, 149 insertions, 180 deletions
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 <vespa/fnet/transport.h>
#include <vespa/fastos/thread.h>
#include <vespa/fastos/file.h>
-#include <vespa/fastos/app.h>
#include <iostream>
#include <thread>
#include <fcntl.h>
@@ -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<config::ConfigContext>(configServerSpec));
auto protonUP = std::make_unique<proton::Proton>(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 <vespa/searchlib/fef/fef.h>
#include <vespa/searchlib/fef/test/plugin/setup.h>
#include <vespa/config/subscription/configsubscriber.hpp>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <optional>
#include <vespa/log/log.h>
@@ -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 <vespa/vespalib/objects/nbostream.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/config/helper/configgetter.hpp>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
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 <typename CFG>
@@ -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 <vespa/document/repo/document_type_repo_factory.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/datatype/datatype.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <vespa/searchcore/bmcluster/avg_sampler.h>
#include <vespa/searchcore/bmcluster/bm_cluster.h>
#include <vespa/searchcore/bmcluster/bm_cluster_controller.h>
@@ -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 <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/fastlib/io/bufferedfile.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <iostream>
#include <sstream>
#include <openssl/evp.h>
@@ -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> 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<GenTestDocsApp>();
+ 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 <vespa/vespalib/util/host_name.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/time.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <sys/time.h>
#include <thread>
#include <cstdlib>
@@ -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 <port|spec|--local|--id=name> <cmd> [args]\n", _argv[0]);
+ fprintf(stderr, "usage: %s <port|spec|--local|--id=name> <cmd> [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 &params = *_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<unsigned int>(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 &params = *_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 <vespa/document/repo/document_type_repo_factory.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/datatype/datatype.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <vespa/searchcore/bmcluster/avg_sampler.h>
#include <vespa/searchcore/bmcluster/bm_cluster.h>
#include <vespa/searchcore/bmcluster/bm_cluster_controller.h>
@@ -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 <vespa/document/update/documentupdate.h>
#include <vespa/config/helper/configgetter.hpp>
#include <vespa/fnet/transport.h>
-#include <vespa/fastos/app.h>
+#include <vespa/vespalib/util/signalhandler.h>
#include <iostream>
#include <thread>
@@ -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<const ITermData *> 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