+++ /dev/null
-#include <fstream>
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/CompilerOutputter.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <cppunit/ui/text/TestRunner.h>
-
-#include <glite/lb/consumer.h>
-#include <glite/lb/context-int.h>
-
-#include "lbs_db.h"
-#include "get_events.h"
-
-using namespace std;
-
-static const char *test_dir;
-
-class QueryEventsTest: public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(QueryEventsTest);
- CPPUNIT_TEST(oneJob);
- CPPUNIT_TEST_SUITE_END();
-
-private:
- edg_wll_Context ctx;
-
- ifstream qry_file;
-
- vector<pair<string,vector<string> > > queries;
-
-public:
- void oneJob();
- int ExecStmt(const char *, edg_wll_Stmt *);
-
- void setUp() {
- edg_wll_InitContext(&ctx);
- ctx->mysql = (void *) this; /* XXX */
- }
-
-};
-
-void QueryEventsTest::oneJob()
-{
- edg_wll_QueryRec job[2];
- const edg_wll_QueryRec *jobs[2] = { job,NULL} ;
- edg_wll_Event *events;
-
- job[0].attr = EDG_WLL_QUERY_ATTR_JOBID;
- job[0].op = EDG_WLL_QUERY_OP_EQUAL ;
- edg_wlc_JobIdParse("https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw",
- &job[0].value.j);
- job[1].attr = EDG_WLL_QUERY_ATTR_UNDEF;
-
- string file(test_dir);
- file += "/oneJob.qry";
- qry_file.open(file.c_str());
-
- while (!qry_file.eof()) {
- string query,line;
- vector<string> rows;
-
- getline(qry_file,query);
- cout << "read: " << query <<endl;
- rows.clear();
-
- while (!qry_file.eof()) {
- getline(qry_file,line);
- if (line == "") break;
-
- rows.push_back(line);
- }
- rows.push_back("END");
- queries.push_back(pair<string,vector<string> >(query,rows));
- }
-
- qry_file.close();
-
- CPPUNIT_ASSERT(!edg_wll_QueryEventsServer(ctx,1,jobs,NULL,&events));
-}
-
-int QueryEventsTest::ExecStmt(const char *qry, edg_wll_Stmt *stmt_out)
-{
- vector<pair<string,vector<string> > >::iterator stmt = queries.begin();
-
- for (; stmt != queries.end(); stmt++) {
- const char *q = stmt->first.c_str();
-
- /* XXX: there some spaces at the end of qry */
- if (!strncmp(q,qry,strlen(q))) break;
- }
-
- if (stmt == queries.end()) {
- cerr << "query not found" << endl;
- CPPUNIT_ASSERT(0);
- }
- vector<string>::iterator *rows = new vector<string>::iterator(stmt->second.begin());
-
- *stmt_out = (edg_wll_Stmt) rows;
- return stmt->second.size()-1;
-}
-
-extern "C" {
-
-int edg_wll_ExecStmt(edg_wll_Context ctx,char *qry,edg_wll_Stmt *stmt)
-{
- cout << "edg_wll_ExecStmt: " << qry << endl;
-
- class QueryEventsTest *tst = (class QueryEventsTest *)(ctx->mysql);
- return tst->ExecStmt(qry, stmt);
-}
-
-int edg_wll_FetchRow(edg_wll_Stmt stmt, char **cols)
-{
- vector<string>::iterator *rows = (vector<string>::iterator *) stmt;
- char *row,*p,i=0;
-
- if (**rows == "END") return 0;
- row = strdup((*rows)->c_str());
- (*rows)++;
- for (p = strtok(row,"\t"); p; p = strtok(NULL,"\t"))
- cols[i++] = strdup(p);
-
- return i;
-}
-
-void edg_wll_FreeStmt(edg_wll_Stmt *) {}
-
-int debug;
-
-int edg_wll_QueryColumns(edg_wll_Stmt stmt, char**cols) {}
-char *edg_wll_TimeToDB(long t) {}
-
-time_t edg_wll_DBToTime(char *c) {}
-edg_wll_ErrorCode edg_wll_DBConnect(edg_wll_Context ctx, char*str) {}
-
-
-
-
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(QueryEventsTest);
-
-int main (int ac,const char *av[])
-{
- CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
- CppUnit::TextUi::TestRunner runner;
-
- test_dir = ac >= 2 ? av[1] : "../test";
-
- runner.addTest(suite);
- return runner.run() ? 0 : 1;
-}
+++ /dev/null
-#include <iostream>
-#include <stdsoap2.h>
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/CompilerOutputter.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <cppunit/ui/text/TestRunner.h>
-
-#include <glite/lb/consumer.h>
-
-#include "bk_ws_H.h"
-#include "ws_typeref.h"
-
-using namespace std;
-
-class SoapConvTest: public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(SoapConvTest);
- CPPUNIT_TEST(Conditions);
- CPPUNIT_TEST(States);
- CPPUNIT_TEST_SUITE_END();
-
-private:
- struct soap *soap;
- edg_wll_QueryRec **stdConds;
- edg_wll_JobStat stdStat;
-
- int stdRecCmp(edg_wll_QueryRec &, edg_wll_QueryRec &);
- int stdCondsCmp(edg_wll_QueryRec **, edg_wll_QueryRec **);
- int soapRecCmp(struct edgwll__QueryRec &, struct edgwll__QueryRec &);
- int soapCondsCmp(struct edgwll__QueryConditions &, struct edgwll__QueryConditions &);
-
-public:
- void setUp();
-
- void Conditions();
- void States();
-};
-
-void SoapConvTest::setUp()
-{
- soap = soap_new();
-
- stdConds = (edg_wll_QueryRec **)calloc(17, sizeof(edg_wll_QueryRec *));
-
- stdConds[0] = (edg_wll_QueryRec *)calloc(4, sizeof(edg_wll_QueryRec));
- stdConds[0][0].attr = EDG_WLL_QUERY_ATTR_STATUS;
- stdConds[0][0].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[0][0].value.i = EDG_WLL_JOB_DONE;
- stdConds[0][1].attr = EDG_WLL_QUERY_ATTR_STATUS;
- stdConds[0][1].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[0][1].value.i = EDG_WLL_JOB_RUNNING;
- stdConds[0][2].attr = EDG_WLL_QUERY_ATTR_STATUS;
- stdConds[0][2].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[0][2].value.i = EDG_WLL_JOB_CANCELLED;
-
- stdConds[1] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[1][0].attr = EDG_WLL_QUERY_ATTR_OWNER;
- stdConds[1][0].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[1][0].value.c = NULL;
-
- stdConds[2] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[2][0].attr = EDG_WLL_QUERY_ATTR_JOBID;
- stdConds[2][0].op = EDG_WLL_QUERY_OP_EQUAL;
- edg_wlc_JobIdCreate("my.server.org", 9000, &(stdConds[2][0].value.j));
-
- stdConds[3] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[3][0].attr = EDG_WLL_QUERY_ATTR_LOCATION;
- stdConds[3][0].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[3][0].value.c = strdup("my_location");
-
- stdConds[4] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[4][0].attr = EDG_WLL_QUERY_ATTR_DESTINATION;
- stdConds[4][0].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[4][0].value.c = strdup("my_destination");
-
- stdConds[5] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[5][0].attr = EDG_WLL_QUERY_ATTR_DONECODE;
- stdConds[5][0].op = EDG_WLL_QUERY_OP_GREATER;
- stdConds[5][0].value.i = 1;
-
- stdConds[6] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[6][0].attr = EDG_WLL_QUERY_ATTR_USERTAG;
- stdConds[6][0].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[6][0].attr_id.tag = strdup("color");
- stdConds[6][0].value.c = strdup("red");
-
- stdConds[7] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[7][0].attr = EDG_WLL_QUERY_ATTR_TIME;
- stdConds[7][0].op = EDG_WLL_QUERY_OP_WITHIN;
- stdConds[7][0].value.t = (struct timeval){10, 1};
- stdConds[7][0].value2.t = (struct timeval){20, 1};
-
- stdConds[8] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[8][0].attr = EDG_WLL_QUERY_ATTR_LEVEL;
- stdConds[8][0].op = EDG_WLL_QUERY_OP_WITHIN;
- stdConds[8][0].value.i = 10;
- stdConds[8][0].value2.i = 20;
-
- stdConds[9] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[9][0].attr = EDG_WLL_QUERY_ATTR_HOST;
- stdConds[9][0].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[9][0].value.c = strdup("any.host");
-
- stdConds[10] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[10][0].attr = EDG_WLL_QUERY_ATTR_SOURCE;
- stdConds[10][0].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[10][0].value.i = 2;
-
- stdConds[11] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[11][0].attr = EDG_WLL_QUERY_ATTR_INSTANCE;
- stdConds[11][0].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[11][0].value.c = strdup("any.instance");
-
- stdConds[12] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[12][0].attr = EDG_WLL_QUERY_ATTR_EVENT_TYPE;
- stdConds[12][0].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[12][0].value.i = 1;
-
- stdConds[13] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[13][0].attr = EDG_WLL_QUERY_ATTR_RESUBMITTED;
- stdConds[13][0].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[13][0].value.c = strdup("where");
-
- stdConds[14] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[14][0].attr = EDG_WLL_QUERY_ATTR_PARENT;
- stdConds[14][0].op = EDG_WLL_QUERY_OP_EQUAL;
- edg_wlc_JobIdCreate("my.server.org", 8000, &(stdConds[14][0].value.j));
-
- stdConds[15] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[15][0].attr = EDG_WLL_QUERY_ATTR_EXITCODE;
- stdConds[15][0].op = EDG_WLL_QUERY_OP_LESS;
- stdConds[15][0].value.i = 255;
-/*
- * XXX: what is that for?
- stdConds[13] = (edg_wll_QueryRec *)calloc(2, sizeof(edg_wll_QueryRec));
- stdConds[13][0].attr = EDG_WLL_QUERY_ATTR_CHKPT_TAG;
- stdConds[13][0].op = EDG_WLL_QUERY_OP_EQUAL;
- stdConds[13][0].value.i = 1;
-*/
-}
-
-int SoapConvTest::stdCondsCmp(edg_wll_QueryRec **c1, edg_wll_QueryRec **c2)
-{
- int i, j;
-
-
- if ( (c1 && !c2) || (!c1 && c2) ) return 1;
- if ( c1 ) for ( i = 0; c1[i]; i++ ) {
- if ( !c2[i] ) return 2;
- for ( j = 0; c1[i][j].attr; j++ ) {
- if ( !c2[i][j].attr ) return 3;
- if ( stdRecCmp(c1[i][j], c2[i][j]) ) return 4;
- }
- if ( c2[i][j].attr ) return 3;
- }
- if ( c2[i] ) return 2;
-
- return 0;
-}
-
-int SoapConvTest::stdRecCmp(edg_wll_QueryRec &qr1, edg_wll_QueryRec &qr2)
-{
- if ( qr1.attr != qr2.attr ) return 1;
- if ( qr1.op != qr2.op ) return 1;
- switch ( qr1.attr) {
- case EDG_WLL_QUERY_ATTR_USERTAG:
- if ( strcmp(qr1.attr_id.tag, qr2.attr_id.tag) ) return 1;
- case EDG_WLL_QUERY_ATTR_OWNER:
- case EDG_WLL_QUERY_ATTR_LOCATION:
- case EDG_WLL_QUERY_ATTR_DESTINATION:
- case EDG_WLL_QUERY_ATTR_HOST:
- case EDG_WLL_QUERY_ATTR_INSTANCE:
- if ( (qr1.value.c && !qr2.value.c) || (!qr1.value.c && qr2.value.c) ) return 1;
- if ( qr1.value.c && qr2.value.c && strcmp(qr1.value.c, qr2.value.c) ) return 1;
- break;
- case EDG_WLL_QUERY_ATTR_JOBID:
- case EDG_WLL_QUERY_ATTR_PARENT: {
- char *s1, *s2;
- int rv;
-
- s1 = edg_wlc_JobIdUnparse(qr1.value.j);
- s2 = edg_wlc_JobIdUnparse(qr2.value.j);
- if ( !s1 || !s2 ) rv = 1;
- else rv = strcmp(s1, s2);
- free(s1); free(s2);
- return rv;
- }
- break;
- case EDG_WLL_QUERY_ATTR_STATUS:
- case EDG_WLL_QUERY_ATTR_DONECODE:
- case EDG_WLL_QUERY_ATTR_LEVEL:
- case EDG_WLL_QUERY_ATTR_SOURCE:
- case EDG_WLL_QUERY_ATTR_EVENT_TYPE:
- case EDG_WLL_QUERY_ATTR_RESUBMITTED:
- case EDG_WLL_QUERY_ATTR_EXITCODE:
- if ( (qr1.value.i != qr2.value.i)
- || (qr1.op == EDG_WLL_QUERY_OP_WITHIN && qr1.value2.i != qr2.value2.i) )
- return 1;
- break;
- case EDG_WLL_QUERY_ATTR_TIME:
- if ( (qr1.value.t.tv_sec != qr2.value.t.tv_sec
- || qr1.value.t.tv_usec != qr2.value.t.tv_usec)
- || (qr1.op == EDG_WLL_QUERY_OP_WITHIN
- && (qr1.value2.t.tv_sec != qr2.value2.t.tv_sec
- || qr1.value2.t.tv_usec != qr2.value2.t.tv_usec)) )
- return 1;
- break;
- /*
- * XXX: what about EDG_WLL_QUERY_ATTR_CHKPT_TAG ???
- */
- default:
- return 1;
- }
-
- return 0;
-}
-
-int SoapConvTest::soapCondsCmp(struct edgwll__QueryConditions &qc1, struct edgwll__QueryConditions &qc2)
-{
- int i, j;
-
-
- if ( qc1.__sizecondition != qc2.__sizecondition ) return 1;
- if ( (qc1.condition && !qc2.condition) || (!qc1.condition && qc2.condition) )
- for ( i = 0; i < qc1.__sizecondition; i++ ) {
- if ( qc1.condition[i]->attr != qc2.condition[i]->attr ) return 2;
- if ( qc1.condition[i]->__sizerecords != qc2.condition[i]->__sizerecords ) return 3;
- for ( j = 0; j < qc1.condition[i]->__sizerecords; j++ )
- if ( soapRecCmp(*(qc1.condition[i]->records[j]),
- *(qc2.condition[i]->records[j])) ) return 4;
- }
-
- return 0;
-}
-
-int SoapConvTest::soapRecCmp(struct edgwll__QueryRec &qr1, struct edgwll__QueryRec &qr2)
-{
- if ( qr1.op != qr2.op ) return 1;
- if ( (qr1.attrid->tag && !qr2.attrid->tag)
- || (!qr1.attrid->tag && qr2.attrid->tag)
- || (qr1.attrid->tag && strcmp(qr1.attrid->tag, qr2.attrid->tag)) ) return 2;
- if ( (qr1.attrid->state && !qr2.attrid->state)
- || (!qr1.attrid->state && qr2.attrid->state)
- || (qr1.attrid->state && (qr1.attrid->state != qr2.attrid->state)) ) return 3;
-
- if ( (qr1.value1 && !qr2.value1)
- || (!qr1.value1 && qr2.value1) ) return 3;
- if ( qr1.value1 ) {
- if ( (qr1.value1->i && !qr2.value1->i)
- || (!qr1.value1->i && qr2.value1->i)
- || (qr1.value1->i && qr1.value1->i != qr2.value1->i) )
- return 4;
- if ( (qr1.value1->c && !qr2.value1->c)
- || (!qr1.value1->c && qr2.value1->c)
- || (qr1.value1->c && strcmp(qr1.value1->c,qr2.value1->c)) )
- return 4;
- if ( (qr1.value1->t && !qr2.value1->t)
- || (!qr1.value1->t && qr2.value1->t)
- || (qr1.value1->t && memcmp(qr1.value1->t,qr2.value1->t,sizeof(*qr2.value1->t))) )
- return 4;
- }
-
- if ( (qr1.value2 && !qr2.value2)
- || (!qr1.value2 && qr2.value2) ) return 3;
- if ( qr1.value2 ) {
- if ( (qr1.value2->i && !qr2.value2->i)
- || (!qr1.value2->i && qr2.value2->i)
- || (qr1.value2->i && qr1.value2->i != qr2.value2->i) )
- return 4;
- if ( (qr1.value2->c && !qr2.value2->c)
- || (!qr1.value2->c && qr2.value2->c)
- || (qr1.value2->c && strcmp(qr1.value2->c,qr2.value2->c)) )
- return 4;
- if ( (qr1.value2->t && !qr2.value2->t)
- || (!qr1.value2->t && qr2.value2->t)
- || (qr1.value2->t && memcmp(qr1.value2->t,qr2.value2->t,sizeof(*qr2.value2->t))) )
- return 4;
- }
-
-
- return 0;
-}
-
-void SoapConvTest::Conditions()
-{
- struct edgwll__QueryConditions *soapConds, *soapConds2;
- edg_wll_QueryRec **stdConds2;
- int ret;
-
- ret = edg_wll_QueryCondsExtToSoap(soap, (const edg_wll_QueryRec**)stdConds, &soapConds);
- CPPUNIT_ASSERT_MESSAGE("edg_wll_QueryCondsExtToSoap()", ret == SOAP_OK);
- ret = edg_wll_SoapToQueryCondsExt(soapConds, &stdConds2);
- CPPUNIT_ASSERT_MESSAGE("edg_wll_SoapToQueryCondsExt()", !ret);
-
- CPPUNIT_ASSERT_MESSAGE("Converted std results differs", !stdCondsCmp(stdConds, stdConds2));
-
- ret = edg_wll_QueryCondsExtToSoap(soap, (const edg_wll_QueryRec**)stdConds2, &soapConds2);
- CPPUNIT_ASSERT_MESSAGE("edg_wll_QueryCondsExtToSoap()", ret == SOAP_OK);
-
- CPPUNIT_ASSERT_MESSAGE("Converted soap results differs", !soapCondsCmp(*soapConds, *soapConds2));
-}
-
-void SoapConvTest::States()
-{
- struct edgwll__JobStat *soapStat;
- edg_wll_JobStat stdStat2;
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(SoapConvTest);
-
-int main (int ac,const char *av[])
-{
- CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
- CppUnit::TextUi::TestRunner runner;
-
- runner.addTest(suite);
- return runner.run() ? 0 : 1;
-}
+++ /dev/null
-#include <iostream>
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/CompilerOutputter.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <cppunit/ui/text/TestRunner.h>
-
-
-#include <glite/lb/producer.h>
-#include "lb_xml_parse.h"
-#include <glite/lb/xml_parse.h>
-
-class XMLParseTest: public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(XMLParseTest);
- CPPUNIT_TEST(protoEventTest);
- CPPUNIT_TEST(protoStatusTest);
- CPPUNIT_TEST_SUITE_END();
-
-public:
- void protoEventTest();
- void protoStatusTest();
-
-
-};
-
-static char * compare_events(const edg_wll_Event *e1, const edg_wll_Event *e2)
-{
- if (e1->any.type != e2->any.type) return "type";
-@@@{
- selectType $event '_common_';
- for ($event->getFieldsOrdered) {
- my $f = selectField $event $_;
- my $fn = getName $f;
- my $ft = $f->{type};
-
- my $a = "e1->any.$fn";
- my $b = "e2->any.$fn";
-
- gen "\tif (!(".eval($main::compare{C}->{$ft}).")) return \"$fn\";\n";
- }
-
- gen "\tswitch(e1->any.type) {\n";
- for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} }
- $event->getTypes)
- {
- my $tu = uc $t;
- my $tl = lcfirst $t;
-
- selectType $event $t;
- gen "\t\tcase EDG_WLL_EVENT\_$tu :\n";
- for ($event->getFieldsOrdered) {
- my $f = selectField $event $_;
- my $fn = $f->{name};
- my $ft = $f->{type};
-
- my $a = "e1->$tl.$fn";
- my $b = "e2->$tl.$fn";
-
- gen "\t\t\tif (!(".eval($main::compare{C}->{$ft}).")) return \"$fn\";\n";
- }
- gen "\t\tbreak;\n";
- }
-@@@}
- default: return "default";
- } /* switch */
- return NULL;
-}
-
-static char * compare_states(const edg_wll_JobStat s1, const edg_wll_JobStat s2)
-{
-@@@{
- selectType $status '_common_';
- for (getFieldsOrdered $status) {
- my $f = selectField $status $_;
- my $fn = getName $f;
- my $ft = $f->{type};
-
- my $a = "s1.$fn";
- my $b = "s2.$fn";
-
- if ($ft eq 'intlist') {
- gen "\tif ( (s1.$_ != NULL) && (s2.$_ == NULL) || (s1.$_ == NULL) && (s2.$_ != NULL) ) return \"$fn\";\n";
- }
- elsif ($ft eq 'strlist') {
- }
- elsif ($ft eq 'taglist') {
- }
- elsif ($ft eq 'stslist') {
- }
- else {
- gen "\tif (!(".eval($main::compare{C}->{$ft}).")) return \"$fn\";\n";
- }
- }
-@@@}
- return NULL;
-}
-
-void XMLParseTest::protoEventTest()
-{
- edg_wll_Context ctx;
- edg_wll_Event *e1, *e2;
- char *message, *et, *ed;
-
- edg_wll_InitContext(&ctx);
- e1 = edg_wll_InitEvent(EDG_WLL_EVENT_REGJOB);
- e1->any.type = EDG_WLL_EVENT_REGJOB;
-
- e1->regJob.jdl = strdup("very long job = \"blabla\" \\\\ \n hugh\t;");
- e1->regJob.ns = strdup("ns address");
- e1->regJob.jobtype = EDG_WLL_REGJOB_SIMPLE;
- e1->regJob.seed = strdup("1234");
-
- gettimeofday(&e1->any.timestamp,NULL);
-
- e1->any.host = strdup("some.host");
- e1->any.level = 7;
- e1->any.priority = 0;
- edg_wlc_JobIdParse("https://some.host:1234/x67qr549qc",&e1->any.jobId);
- e1->any.seqcode = EDG_WLL_SEQ_BIGHELPER_INITIAL;
- e1->any.user = strdup("/O=Grid/CN=This User");
- e1->any.source = EDG_WLL_SOURCE_USER_INTERFACE;
- e1->any.src_instance = strdup("UI");
-
- if (edg_wll_QueryEventsToXML(ctx, e1, &message)) {
- edg_wll_Error(ctx,&et,&ed);
- CPPUNIT_ASSERT_MESSAGE(std::string("QueryEventsToXML():") + et + " " + ed, 0);
- }
-
- CPPUNIT_ASSERT_MESSAGE("message: ", message);
-
- if (edg_wll_ParseQueryEvents(ctx, message, &e2)) {
- edg_wll_Error(ctx,&et,&ed);
- CPPUNIT_ASSERT_MESSAGE(std::string("ParseQueryEvents():") + et + " " + ed, 0);
- }
-
- if ((et = compare_events(e1,e2))) {
- CPPUNIT_ASSERT_MESSAGE(std::string("compare_events():") + et, 0);
- }
-}
-
-void XMLParseTest::protoStatusTest()
-{
- edg_wll_Context ctx;
- edg_wll_JobStat s1, s2;
- char *message, *et, *ed;
- const struct timeval some_timeval = {14,12};
-
-
- edg_wll_InitContext(&ctx);
- edg_wll_InitStatus(&s1);
-
- s1.state = EDG_WLL_JOB_SUBMITTED;
- edg_wlc_JobIdParse("https://some.host:1234/x67qr549qc",&s1.jobId);
- s1.owner = strdup("/O=Grid/CN=This User");
- s1.jobtype = EDG_WLL_STAT_SIMPLE;
- s1.seed = strdup("4321");
- s1.condorId = strdup("condorId");
- s1.globusId = strdup("globusId");
- s1.localId = strdup("localId");
- s1.jdl = strdup("jdl");
- s1.matched_jdl = strdup("matched_jdl");
- s1.destination = strdup("destination");
- s1.condor_jdl = strdup("condor_jdl");
- s1.rsl = strdup("rsl");
- s1.reason = strdup("reason");
- s1.location = strdup("location");
- s1.ce_node = strdup("ce_node");
- s1.network_server = strdup("network_server");
- s1.subjob_failed = 1;
- s1.done_code = EDG_WLL_STAT_FAILED;
- s1.exit_code = 123;
- s1.resubmitted = 1;
- s1.cancelling = 1;
- s1.cancelReason = strdup("cancelReason");
- s1.cpuTime = 10;
- s1.stateEnterTime = some_timeval;
- s1.lastUpdateTime = some_timeval;
- s1.expectUpdate = 20;
- s1.expectFrom = strdup("expectFrom");
- s1.acl = strdup("acl");
-
- if (edg_wll_JobStatusToXML(ctx, s1, &message)) {
- edg_wll_Error(ctx,&et,&ed);
- CPPUNIT_ASSERT_MESSAGE(std::string("QueryEventsToXML():") + et + " " + ed, 0);
- }
-
- CPPUNIT_ASSERT_MESSAGE("message: ", message);
-
- if (edg_wll_ParseJobStat(ctx, message, (long) strlen(message), &s2)) {
- edg_wll_Error(ctx,&et,&ed);
- CPPUNIT_ASSERT_MESSAGE(std::string("ParseJobStat():") + et + " " + ed, 0);
- }
-
- if ((et = compare_states(s1,s2))) {
- CPPUNIT_ASSERT_MESSAGE(std::string("compare_states():") + et, 0);
- }
-
-
-
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(XMLParseTest);
-
-int main (int ac,const char *av[])
-{
- CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
- CppUnit::TextUi::TestRunner runner;
-
- runner.addTest(suite);
- return runner.run() ? 0 : 1;
-}