2014-01-11 20:12:57 +00:00
|
|
|
/*! \brief apig-cli
|
2014-01-05 22:58:00 +00:00
|
|
|
* Master Daemon standalone client
|
|
|
|
*
|
|
|
|
* This MD sample client driver has the same functionality as the
|
|
|
|
* xmlrpc-c xmlrpc command line utility program but additionally
|
|
|
|
* runs a test suite using the test harness reused from the
|
2014-01-11 20:12:57 +00:00
|
|
|
* xmlrpc-c cpp test. This is a unit testing not tests such as
|
|
|
|
* EPP OTE Certification.
|
2014-01-05 22:58:00 +00:00
|
|
|
*
|
2014-01-11 20:12:57 +00:00
|
|
|
* In a dual role, it also serves as the core of APIG with SWIG
|
|
|
|
* generated versions for Ruby, PHP and pythong.
|
2014-01-05 22:58:00 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MDCLIENTMAIN
|
|
|
|
#include "mdclient.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
main(int argc, char **argv) {
|
|
|
|
|
|
|
|
char debug[10];
|
|
|
|
int rc;
|
|
|
|
|
2014-01-11 19:34:15 +00:00
|
|
|
cout << "apig-cli compiled " __DATE__ " " __TIME__ " \n";
|
2014-01-05 22:58:00 +00:00
|
|
|
|
|
|
|
if (argc < 3 ) {
|
|
|
|
|
|
|
|
cerr << "Usage: apig-cli <deviceType> <serverURL> <thirdOption>\n\nwhere\n\n"
|
|
|
|
" <serverURL> = . defaults to '" MD_SERVER_URL "'\n"
|
|
|
|
" <device> = . defaults to '" DEFAULT_DEVICE "'\n"
|
|
|
|
" <thirdOption> = 'n' or 'N'\n\n"
|
|
|
|
|
2014-01-11 19:34:15 +00:00
|
|
|
"The XMLRPC at <serverURL> is presumed a master daemon varint .\n"
|
2014-01-05 22:58:00 +00:00
|
|
|
"<thirdOption> = n causes non-repeatable testbucket(s) to be skipped.\n"
|
|
|
|
"Any other 3rd ooption causes a simple connectivity test and exit.\n"
|
2014-01-11 19:34:15 +00:00
|
|
|
"Otherwise performs the full AC core APIG test suite.\n\n";
|
2014-01-05 22:58:00 +00:00
|
|
|
|
2014-01-11 19:34:15 +00:00
|
|
|
"If XMLRPC_TRACE_XML is defined will pause " <<
|
|
|
|
PAUSE_SECS << " at selected points in the tests.\n\n";
|
2014-01-05 22:58:00 +00:00
|
|
|
exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
phase = string("setup");
|
|
|
|
if (argc > 3) {
|
|
|
|
if (*argv[3] == 'n' || *argv[3] == 'N') repeatableOnly = true;
|
|
|
|
else doSanityCheck = true;
|
|
|
|
}
|
|
|
|
defaultDevice = (*argv[1] == '.') ? DEFAULT_DEVICE : argv[1];
|
|
|
|
serverURL = (*argv[2] == '.') ? MD_SERVER_URL : argv[2];
|
|
|
|
|
|
|
|
if (doSanityCheck) {
|
|
|
|
|
|
|
|
cout << "Doing sanity check with simple client: get a handle for " << defaultDevice << " from " << serverURL << "\n";
|
|
|
|
|
|
|
|
string const serverUrl(serverURL);
|
|
|
|
string const methodName("device.registeR");
|
|
|
|
|
|
|
|
xmlrpc_c::clientSimple monClient;
|
|
|
|
xmlrpc_c::value result;
|
|
|
|
|
|
|
|
monClient.call(serverUrl, methodName, "is", &result, 0, DEFAULT_DEVICE);
|
|
|
|
|
|
|
|
int const handle((xmlrpc_c::value_int(result)));
|
|
|
|
|
|
|
|
if ((mdServerHandle=handle) <= 0)
|
|
|
|
{cout << serverURL << " returned: " << handle << " instead of a valid handle.\n"
|
|
|
|
" Run terminates in error.\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
cout << "Got " << defaultDevice << " handle: " << handle << "\n";
|
|
|
|
cout << "Sanity check completed OK.\n";
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
mdCoreAPITestSuite tests;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
xmlrpc_env_init(&env);
|
|
|
|
xmlrpc_client_setup_global_const(&env);
|
|
|
|
xmlrpc_client_init2(&env, 0, "mdclient", "1.0", NULL, 0);
|
|
|
|
|
|
|
|
tests.run(0);
|
|
|
|
|
|
|
|
} catch(exception const& e) {
|
|
|
|
cout << "During " << phase << " caught std exception: " << e.what() << "\n";
|
|
|
|
cout << "Terminating in error.\n" ;
|
|
|
|
rc = 1;
|
|
|
|
}
|
|
|
|
catch(XmlRpcFault const& e) {
|
|
|
|
cout << "XmlRpcFault during " << phase << ": " << e.getFaultString() << "\n";
|
|
|
|
cout << "Terminating in error.\n" ;
|
|
|
|
rc = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cout << tests.tests << " Variation(s).\n"
|
|
|
|
<< tests.failures << " Failure(s).\n";
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|