00001
00002
00003 #include "rodsServer.h"
00004 #include "reGlobalsExtern.h"
00005 #include "reDefines.h"
00006 #include <sys/time.h>
00007 time_t time_offset(const time_t *base, const struct tm *off);
00008 void
00009 retest_usage (char *prog)
00010 {
00011 printf ("Usage: %s [-D objPath] [-R rescName] [-T dataType] [-H clientHost] [-S dataSize] [-U dataOwnerName] [-Z dataOwnerZone][-n otherUserName] [-z otherUserZone] [-t otherUserType] [-p proxyUserName] [-q proxyUserZone] <ruleSet> <action> [arg ...]\n", prog);
00012 }
00013
00014 int main(int argc, char **argv)
00015 {
00016 int status;
00017 int c,i,j;
00018 int uFlag = 0;;
00019 char tmpStr[100];
00020 char retestflagEV[200];
00021 char reloopbackflagEV[200];
00022 ruleExecInfo_t *rei;
00023 char *args[MAX_NUM_OF_ARGS_IN_ACTION];
00024 char ruleSet[RULE_SET_DEF_LENGTH];
00025 hrtime_t ht1, ht2, ht3;
00026 time_t now = time(0);
00027 struct tm off = {0};
00028 time_t new;
00029 struct tm *mytm;
00030
00031 rei = mallocAndZero(sizeof(ruleExecInfo_t));
00032 if (argc < 2) {
00033 retest_usage(argv[0]);
00034 exit(1);
00035 }
00036 if (getenv(RETESTFLAG) == NULL) {
00037 sprintf(retestflagEV,"RETESTFLAG=%i",COMMAND_TEST_1);
00038 putenv(retestflagEV);
00039 }
00040 if (getenv(RELOOPBACKFLAG) == NULL) {
00041 sprintf(reloopbackflagEV,"RELOOPBACKFLAG=%i",LOOP_BACK_1);
00042 putenv(reloopbackflagEV);
00043 }
00044
00045 rei->doi = mallocAndZero(sizeof(dataObjInfo_t));
00046 rei->rgi = mallocAndZero(sizeof(rescGrpInfo_t));
00047 rei->rgi->rescInfo = mallocAndZero(sizeof(rescInfo_t));
00048 rei->uoip = mallocAndZero(sizeof(userInfo_t));
00049 rei->uoic = mallocAndZero(sizeof(userInfo_t));
00050 rei->uoio = mallocAndZero(sizeof(userInfo_t));
00051 rei->coi = mallocAndZero(sizeof(collInfo_t));
00052
00053 rei->next = NULL;
00054
00055 strcpy(rei->doi->objPath,"/home/sekar.sdsc");
00056 strcpy(rei->doi->rescName,"unix-sdsc");
00057 strcpy(rei->doi->dataType,"text");
00058 strcpy(rei->uoic->authInfo.host,"");
00059 rei->doi->dataSize = 100;
00060
00061 rei->doinp = NULL;
00062 rei->rsComm = NULL;
00063
00064
00065 while ((c=getopt(argc, argv,"D:T:R:H:S:U:Z:n:z:t:p:q:h")) != EOF) {
00066 switch (c) {
00067 case 'D':
00068 strcpy(rei->doi->objPath,optarg);
00069 break;
00070 case 'R':
00071 strcpy(rei->doi->rescName,optarg);
00072 break;
00073 case 'S':
00074 rei->doi->dataSize = atol(optarg);
00075 break;
00076 case 'T':
00077 strcpy(rei->doi->dataType,optarg);
00078 break;
00079 case 'U':
00080 strcpy(rei->doi->dataOwnerName,optarg);
00081 break;
00082 case 'Z':
00083 strcpy(rei->doi->dataOwnerZone,optarg);
00084 break;
00085 case 'p':
00086 strcpy(rei->uoip->userName,optarg);
00087 break;
00088 case 'q':
00089 strcpy(rei->uoip->rodsZone,optarg);
00090 break;
00091 case 'n':
00092 strcpy(rei->uoio->userName,optarg);
00093 break;
00094 case 'z':
00095 strcpy(rei->uoio->rodsZone,optarg);
00096 break;
00097 case 't':
00098 strcpy(rei->uoio->userType,optarg);
00099 break;
00100 case 'H':
00101 strcpy(rei->uoic->authInfo.host,optarg);
00102 break;
00103 case 'h':
00104 retest_usage (argv[0]);
00105 exit (0);
00106 default:
00107 retest_usage (argv[0]);
00108 exit (1);
00109 }
00110 }
00111 print_uoi(rei->uoio);
00112 for (i = optind+2; i < argc; i++) {
00113 args[i-optind-2] = strdup(argv[i]);
00114 }
00115 if (optind+1 == argc) {
00116 retest_usage(argv[0]);
00117 exit(1);
00118 }
00119
00120 strcpy(ruleSet,argv[optind]);
00121 ht1 = gethrtime();
00122 initRuleStruct(ruleSet,"core", "core");
00123 ht2 = gethrtime();
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 i = applyRuleArgPA(argv[optind+1], args, argc - optind-2, NULL, rei, SAVE_REI);
00193
00194 ht3 = gethrtime();
00195 if (reTestFlag == COMMAND_TEST_1|| reTestFlag == COMMAND_TEST_MSI) {
00196 fprintf(stdout,"Rule Initialization Time = %.2f millisecs\n", (float) (ht2 - ht1)/1000000);
00197 fprintf(stdout,"Rule Execution Time = %.2f millisecs\n", (float) (ht3-ht1)/1000000);
00198 }
00199 if (reTestFlag == HTML_TEST_1 || reTestFlag == HTML_TEST_MSI) {
00200 fprintf(stdout,"Rule Initialization Time = %.2f millisecs<BR>n", (float) (ht2 - ht1)/1000000);
00201 fprintf(stdout,"Rule Execution Time = %.2f millisecs<BR>\n", (float) (ht3-ht1)/1000000);
00202 }
00203 if (i != 0) {
00204 rodsLogError(LOG_ERROR,i,"reTest Failed:");
00205 exit(1);
00206 }
00207 exit(0);
00208 }
00209
00210 time_t time_offset(const time_t *base, const struct tm *off) {
00211 struct tm *t;
00212
00213 t = localtime(base);
00214 if (!t) return (time_t)(-1);
00215
00216 t->tm_sec += off->tm_sec;
00217 t->tm_min += off->tm_min;
00218 t->tm_hour += off->tm_hour;
00219 t->tm_mday += off->tm_mday;
00220 t->tm_mon += off->tm_mon;
00221 t->tm_year += off->tm_year;
00222
00223 return mktime(t);
00224 }
00225