26 using namespace swift::misc::network;
28 namespace swiftcoretest
40 void checkSetupReader();
49 void CTestConnectivity::initTestCase() { QVERIFY2(
sApp,
"sApp not available"); }
51 void CTestConnectivity::checkSetupReader()
56 void CTestConnectivity::connectServer()
62 constexpr
int max = 5;
63 for (
int i = 0; i < max; i++)
65 bool ok = CNetworkUtils::canConnect(url, CNetworkUtils::getLongTimeoutMs());
66 if (!ok) { QSKIP(qPrintable(
"Cannot connect " + url.
getFullUrl())); }
68 int elapsedMs = timer.elapsed();
69 qDebug() <<
"Completed" << max <<
"connection tests in" << elapsedMs <<
"ms to" << url.
getFullUrl();
70 QVERIFY2(
true,
"connectServer");
73 void CTestConnectivity::pingServer()
77 const QString host(url.
getHost());
80 constexpr
int max = 5;
81 for (
int i = 0; i < max; i++)
83 bool ok = canPing(host);
84 if (!ok) { QSKIP(qPrintable(
"Cannot ping " + url.
getFullUrl())); }
86 int elapsedMs = timer.elapsed();
87 qDebug() <<
"Completed" << max <<
"ping tests in" << elapsedMs <<
"ms to" << url.
getFullUrl();
88 QVERIFY2(
true,
"pingServer");
93 int main(
int argc,
char *argv[])
95 QCoreApplication app(argc, argv);
100 if (!setup) { qWarning() <<
"No setup loaded"; }
101 int r = EXIT_FAILURE;
102 if (a.
start()) { r = QTest::qExec(&to, args); }
107 #include "testconnectivity.moc"
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
void addNetworkOptions()
Add the network options.
bool hasSetupReader() const
Setup reader?
data::CGlobalSetup getGlobalSetup() const
Global setup.
bool parseCommandLineArgsAndLoadSetup()
Combined function that does a startup check, parses the command line arguments and loads the setup.
virtual bool start()
Start services, if not yet parsed call CApplication::parse.
virtual void gracefulShutdown()
Graceful shutdown.
swift::misc::network::CUrl getDbHomePageUrl() const
Home page url.
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
const QString & getHost() const
Get host.
QString getFullUrl(bool withQuery=true) const
Qualified name.
Test connectivity such as canConnect ping and swift::core::db::CNetworkWatchdog.
Classes interacting with the swift database (aka "datastore").
Backend services of the swift project, like dealing with the network or the simulators.
Free functions in swift::misc.
#define SWIFTTEST_INIT(TestObject)
Implements a main() function that executes all tests in TestObject without instantiating a QApplicati...
int main(int argc, char *argv[])
main