00001
00018 #define MDCLIENTMAIN
00019 #include "mdclient.h"
00020
00021 using namespace std;
00022
00023 main(int argc, char **argv) {
00024
00025 char debug[10];
00026 int rc;
00027
00028 cout << "mdclient compiled " __DATE__ " " __TIME__ " \n";
00029
00030 if (argc < 3 ) {
00031
00032 cerr << "Usage: mdclient <deviceType> <serverURL> <thirdOption>\n\nwhere\n\n"
00033 " <serverURL> = . defaults to '" MD_SERVER_URL "'\n"
00034 " <device> = . defaults to '" DEFAULT_DEVICE "'\n"
00035 " <thirdOption> = 'n' or 'N'\n\n"
00036
00037 "The master daemon must be running at the specified <serverURL>.\n"
00038 "<thirdOption> = n causes non-repeatable testbucket(s) to be skipped.\n"
00039 "Any other 3rd ooption causes a simple connectivity test and exit.\n"
00040 "Otherwise performs the full MD core API test suite.\n\n";
00041
00042
00043
00044 exit(1);
00045
00046 }
00047
00048 phase = string("setup");
00049 if (argc > 3) {
00050 if (*argv[3] == 'n' || *argv[3] == 'N') repeatableOnly = true;
00051 else doSanityCheck = true;
00052 }
00053 defaultDevice = (*argv[1] == '.') ? DEFAULT_DEVICE : argv[1];
00054 serverURL = (*argv[2] == '.') ? MD_SERVER_URL : argv[2];
00055
00056 if (doSanityCheck) {
00057
00058 cout << "Doing sanity check with simple client: get a handle for " << defaultDevice << " from " << serverURL << "\n";
00059
00060 string const serverUrl(serverURL);
00061 string const methodName("device.registeR");
00062
00063 xmlrpc_c::clientSimple monClient;
00064 xmlrpc_c::value result;
00065
00066 monClient.call(serverUrl, methodName, "is", &result, 0, DEFAULT_DEVICE);
00067
00068 int const handle((xmlrpc_c::value_int(result)));
00069
00070 if ((mdServerHandle=handle) <= 0)
00071 {cout << serverURL << " returned: " << handle << " instead of a valid handle.\n"
00072 " Run terminates in error.\n";
00073 exit(1);
00074 }
00075
00076 cout << "Got " << defaultDevice << " handle: " << handle << "\n";
00077 cout << "Sanity check completed OK.\n";
00078 exit(0);
00079
00080 }
00081
00082 mdCoreAPITestSuite tests;
00083
00084 try {
00085
00086 xmlrpc_env_init(&env);
00087 xmlrpc_client_setup_global_const(&env);
00088 xmlrpc_client_init2(&env, 0, "mdclient", "1.0", NULL, 0);
00089
00090 tests.run(0);
00091
00092 } catch(exception const& e) {
00093 cout << "During " << phase << " caught std exception: " << e.what() << "\n";
00094 cout << "Terminating in error.\n" ;
00095 rc = 1;
00096 }
00097 catch(XmlRpcFault const& e) {
00098 cout << "XmlRpcFault during " << phase << ": " << e.getFaultString() << "\n";
00099 cout << "Terminating in error.\n" ;
00100 rc = 1;
00101 }
00102
00103 cout << tests.tests << " Variation(s).\n"
00104 << tests.failures << " Failure(s).\n";
00105
00106 return rc;
00107 }
00108