(file) Return to Tracer.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common / tests / Tracer

   1 martin 1.46 //%LICENSE////////////////////////////////////////////////////////////////
   2 martin 1.47 //
   3 martin 1.46 // Licensed to The Open Group (TOG) under one or more contributor license
   4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
   5             // this work for additional information regarding copyright ownership.
   6             // Each contributor licenses this file to you under the OpenPegasus Open
   7             // Source License; you may not use this file except in compliance with the
   8             // License.
   9 martin 1.47 //
  10 martin 1.46 // Permission is hereby granted, free of charge, to any person obtaining a
  11             // copy of this software and associated documentation files (the "Software"),
  12             // to deal in the Software without restriction, including without limitation
  13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  14             // and/or sell copies of the Software, and to permit persons to whom the
  15             // Software is furnished to do so, subject to the following conditions:
  16 martin 1.47 //
  17 martin 1.46 // The above copyright notice and this permission notice shall be included
  18             // in all copies or substantial portions of the Software.
  19 martin 1.47 //
  20 martin 1.46 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21 martin 1.47 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22 martin 1.46 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27 martin 1.47 //
  28 martin 1.46 //////////////////////////////////////////////////////////////////////////
  29 mike   1.2  //
  30             //%/////////////////////////////////////////////////////////////////////////////
  31             
  32             #include <fstream>
  33             #include <cstring>
  34             #include <Pegasus/Common/System.h>
  35             #include <Pegasus/Common/Tracer.h>
  36 thilo.boehm 1.39 #include <Pegasus/Common/TraceMemoryHandler.h>
  37 a.arora     1.17 #include <Pegasus/Common/AutoPtr.h>
  38 sushma.fernandes 1.30 #include <Pegasus/Common/SharedPtr.h>
  39                       #include <Pegasus/Common/CIMClass.h>
  40                       #include <Pegasus/Common/CIMMessage.h>
  41                       #include <Pegasus/Common/XmlWriter.h>
  42                       #include <Pegasus/Common/AcceptLanguageList.h>
  43                       #include <Pegasus/Common/ContentLanguageList.h>
  44 mike             1.2  
  45                       PEGASUS_USING_STD;
  46                       PEGASUS_USING_PEGASUS;
  47                       
  48 marek            1.35 
  49                       // Trace Levels 0 and 5 are defined as private constants of the tracer
  50                       // class to avoid inappropriate use in the trace calls and macros.
  51                       // Therefore these tracel levels need to be set in the tests using the
  52                       // constant values directly.
  53                       const Uint32 PEGASUS_TRACER_LEVEL0 =  0;
  54                       const Uint32 PEGASUS_TRACER_LEVEL5 = (1 << 4);
  55                       
  56                       
  57 mike             1.2  // Trace files for test purposes
  58 kumpf            1.11 // Will be created in the $(PEGASUS_TMP) directory, or if not set,
  59                       // in the current directory
  60 kumpf            1.15 CString FILE1;
  61                       CString FILE2;
  62                       CString FILE3;
  63                       CString FILE4;
  64 thilo.boehm      1.39 CString FILE5;
  65                       
  66                       // A message string for testing the tracer with variable arguments
  67                       #define VAR_TEST_MESSAGE "Variable length part of message"
  68                       
  69 mike             1.2  
  70 kumpf            1.43 //
  71                       // Reads the last trace message from a given trace file and compares the
  72 mike             1.2  // given string with the string read from file
  73                       //
  74                       // return 0 if the strings match
  75                       // return 1 if the strings do not match
  76                       //
  77 kumpf            1.31 Uint32 compare(const char* fileName, const char* expectedMessage)
  78 mike             1.2  {
  79 kumpf            1.31     int expectedMessageLength = strlen(expectedMessage);
  80                       
  81                           // Compute the size of the message in the trace file.  Include the final
  82                           // EOL character added by the Tracer.  This size will be used to seek
  83                           // from the end of the file back to the beginning of the trace message.
  84                           int seekBytes = expectedMessageLength + 1;
  85                       
  86                       #if defined(PEGASUS_OS_TYPE_WINDOWS)
  87                           // Windows converts all '\n' characters to "\r\n" sequences in the trace
  88                           // file.  Increase the seekBytes by the number of '\r' characters added
  89                           // when the message is written to the file.
  90                           for (const char* newlineChar = expectedMessage;
  91                                ((newlineChar = strchr(newlineChar, '\n')) != 0);
  92                                newlineChar++)
  93                           {
  94                               seekBytes++;
  95                           }
  96                       
  97                           // Count the '\r' character added with the final '\n' written by the Tracer
  98                           seekBytes++;
  99                       #endif
 100 kumpf            1.31 
 101                           AutoArrayPtr<char> actualMessage(new char[expectedMessageLength + 1]);
 102                       
 103                           // Read the trace message from the file, minus the message prefix and
 104                           // minus the trailing newline.
 105 mike             1.2      fstream file;
 106 kumpf            1.31     file.open(fileName, fstream::in);
 107 mike             1.2      if (!file.good())
 108                           {
 109 kumpf            1.31         return 1;
 110 mike             1.2      }
 111 kumpf            1.31     file.seekg(-seekBytes, fstream::end);
 112                           file.read(actualMessage.get(), expectedMessageLength);
 113                           file.close();
 114                           actualMessage[expectedMessageLength] = 0;
 115                       
 116                           // Compare the expected and actual messages
 117                           Uint32 retCode = strcmp(expectedMessage, actualMessage.get());
 118                       
 119 thilo.boehm      1.39     // Diagnostic to determine string differences
 120 kumpf            1.31     if (retCode)
 121                               cout << "Compare Error: expectedMessage= \n\"" << expectedMessage <<
 122                                   "\". actualMessage= \n\"" << actualMessage.get() << "\"" << endl;
 123 karl             1.27 
 124 mike             1.2      return retCode;
 125                       }
 126                       
 127                       //
 128                       // Description:
 129                       // Trace properties file, level and component are not set
 130                       // Should not log a trace message
 131                       //
 132                       // Type:
 133 kumpf            1.43 // Negative
 134 mike             1.2  //
 135                       // return 0 if the test passed
 136                       // return 1 if the test failed
 137                       //
 138                       Uint32 test1()
 139                       {
 140                           const char* METHOD_NAME = "test1";
 141 kumpf            1.10     PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 142 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL2,"%s %d",
 143                               "This message should not appear value=",123));
 144 kumpf            1.10     PEG_METHOD_EXIT();
 145 kumpf            1.34     return System::exists(FILE1) ? 1 : 0;
 146 mike             1.2  }
 147                       
 148                       //
 149                       // Description:
 150                       // Trace properties level and component are not set
 151                       // Should not log a trace message
 152                       //
 153                       // Type:
 154 kumpf            1.43 // Negative
 155 mike             1.2  //
 156                       // return 0 if the test passed
 157                       // return 1 if the test failed
 158                       //
 159                       Uint32 test2()
 160                       {
 161                           const char* METHOD_NAME = "test2";
 162                           Tracer::setTraceFile(FILE1);
 163 kumpf            1.10     PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 164 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL2,"%s %d",
 165                               "This message should not appear value=",123));
 166 thilo.boehm      1.42     Uint32 fileSize = 0;
 167 kumpf            1.34     System::getFileSize(FILE1, fileSize);
 168                           return (fileSize == 0) ? 0 : 1;
 169 mike             1.2  }
 170                       
 171                       //
 172                       // Description:
 173                       // Trace properties component is not set
 174                       // Should not log a trace message
 175                       //
 176                       // Type:
 177 kumpf            1.43 // Negative
 178 mike             1.2  //
 179                       // return 0 if the test passed
 180                       // return 1 if the test failed
 181                       //
 182                       Uint32 test3()
 183                       {
 184                           const char* METHOD_NAME = "test3";
 185                           Tracer::setTraceLevel(Tracer::LEVEL1);
 186 kumpf            1.10     PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 187 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL2,"%s",
 188                               "This message should not appear"));
 189 thilo.boehm      1.42     Uint32 fileSize = 0;
 190 kumpf            1.34     System::getFileSize(FILE1, fileSize);
 191                           return (fileSize == 0) ? 0 : 1;
 192 mike             1.2  }
 193                       
 194                       //
 195                       // Description:
 196                       // Trace properties file, level and component are set
 197                       // should log a trace message
 198                       //
 199                       // Type:
 200 kumpf            1.43 // Positive
 201 mike             1.2  //
 202                       // return 0 if the test passed
 203                       // return 1 if the test failed
 204                       //
 205                       Uint32 test4()
 206                       {
 207                           const char* METHOD_NAME = "test4";
 208 marek            1.37     Tracer::setTraceLevel(Tracer::LEVEL1);
 209 mike             1.2      Tracer::setTraceComponents("Config");
 210 marek            1.37     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL1,METHOD_NAME);
 211                           return(compare(FILE1,METHOD_NAME));
 212 mike             1.2  }
 213                       
 214                       //
 215                       // Description:
 216                       // Trace component is set to an invalid component
 217                       // should not log a trace message
 218                       //
 219                       // Type:
 220 kumpf            1.43 // Negative
 221 mike             1.2  //
 222                       // return 0 if the test passed
 223                       // return 1 if the test failed
 224                       //
 225                       Uint32 test5()
 226                       {
 227                           const char* METHOD_NAME = "test5";
 228                           Tracer::setTraceComponents("Wrong Component Name");
 229 karl             1.27 
 230                           PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 231 marek            1.37     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL1,METHOD_NAME);
 232 karl             1.27     PEG_METHOD_EXIT();
 233 marek            1.37     return(compare(FILE1,"test4"));
 234 mike             1.2  }
 235                       
 236                       //
 237                       // Description:
 238 kumpf            1.43 // Trace level is set to LEVEL 2 and logs a LEVEL 4 message
 239 mike             1.2  // should not log a trace message
 240                       //
 241                       // Type:
 242 kumpf            1.43 // Negative
 243 mike             1.2  //
 244                       // return 0 if the test passed
 245                       // return 1 if the test failed
 246                       //
 247                       
 248                       Uint32 test6()
 249                       {
 250                           const char* METHOD_NAME = "test6";
 251                           Tracer::setTraceComponents("Config");
 252                           Tracer::setTraceLevel(Tracer::LEVEL2);
 253 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL2,"%s %s",
 254                               "Test Message for Level2 in",METHOD_NAME));
 255                           PEG_TRACE((TRC_CONFIG,Tracer::LEVEL2,"%s %s",
 256                               "Test Message for Level2 in",METHOD_NAME));
 257                           PEG_TRACE((TRC_CONFIG,Tracer::LEVEL4,"%s",
 258                               "This Message should not appear"));
 259 mike             1.2      return(compare(FILE1,"Test Message for Level2 in test6"));
 260                       }
 261                       
 262                       //
 263                       // Description:
 264                       // Trace level is set to an invalid level
 265                       // should not log a trace message
 266                       //
 267                       // Type:
 268 kumpf            1.43 // Negative
 269 mike             1.2  //
 270                       // return 0 if the test passed
 271                       // return 1 if the test failed
 272                       //
 273                       Uint32 test7()
 274                       {
 275                           const char* METHOD_NAME = "test7";
 276                           Tracer::setTraceLevel(100);
 277 karl             1.27     PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 278                           PEG_METHOD_EXIT();
 279 mike             1.2      return(compare(FILE1,"Test Message for Level2 in test6"));
 280                       }
 281                       
 282                       //
 283                       // Description:
 284 kumpf            1.43 // Changes the trace file to FILE2
 285 mike             1.2  //
 286                       // Type:
 287 kumpf            1.43 // Positive
 288 mike             1.2  //
 289                       // return 0 if the test passed
 290                       // return 1 if the test failed
 291                       //
 292                       Uint32 test9()
 293                       {
 294                           const char* METHOD_NAME = "test9";
 295                           Tracer::setTraceLevel(Tracer::LEVEL3);
 296                           Tracer::setTraceFile(FILE2);
 297                       
 298 kumpf            1.10     PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 299 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL3,"%s %s",
 300                               "Test Message for Level3 in",METHOD_NAME));
 301 mike             1.2      return(compare(FILE2,"Test Message for Level3 in test9"));
 302                       }
 303                       
 304                       //
 305                       // Description:
 306                       // Passes invalid component in the trace call
 307                       // should not log a trace message
 308                       //
 309                       // Type:
 310 kumpf            1.43 // Negative
 311 mike             1.2  //
 312                       // return 0 if the test passed
 313                       // return 1 if the test failed
 314                       //
 315 marek            1.35 // This test not required with change to
 316 karl             1.27 // use and test macros only.
 317 mike             1.2  
 318                       Uint32 test10()
 319                       {
 320                           const char* METHOD_NAME = "test10";
 321                           Tracer::setTraceComponents("ALL");
 322 karl             1.27     PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 323                           PEG_METHOD_EXIT();
 324 mike             1.2      return(compare(FILE2,"Test Message for Level3 in test9"));
 325                       }
 326                       
 327                       //
 328                       // Description:
 329 marek            1.35 // Trace is set to level 0
 330                       // should not log a trace message
 331 mike             1.2  //
 332                       // Type:
 333 marek            1.35 // Negative
 334 mike             1.2  //
 335                       // return 0 if the test passed
 336                       // return 1 if the test failed
 337                       //
 338                       
 339                       Uint32 test11()
 340                       {
 341                           const char* METHOD_NAME = "test11";
 342                           Tracer::setTraceComponents("ALL");
 343 marek            1.35     Tracer::setTraceLevel(PEGASUS_TRACER_LEVEL0);
 344                           PEG_TRACE((TRC_CONFIG,Tracer::LEVEL1,"%s %s",
 345                               "Test Message for Level0 in",METHOD_NAME));
 346                           return(compare(FILE2,"Test Message for Level3 in test9"));
 347 mike             1.2  }
 348                       
 349                       //
 350                       // Description:
 351                       // Implements trace call for Tracer::Level1
 352                       // should log a trace message
 353                       //
 354                       // Type:
 355 kumpf            1.43 // Positive
 356 mike             1.2  //
 357                       // return 0 if the test passed
 358                       // return 1 if the test failed
 359                       //
 360                       
 361                       Uint32 test12()
 362                       {
 363                           const char* METHOD_NAME = "test12";
 364                           Tracer::setTraceComponents("ALL");
 365                           Tracer::setTraceLevel(Tracer::LEVEL4);
 366 marek            1.35     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL1,"%s %s",
 367                               "Test Message for Level1 in",METHOD_NAME));
 368                           return(compare(FILE2,"Test Message for Level1 in test12"));
 369 mike             1.2  }
 370                       
 371                       //
 372                       // Description:
 373                       // Implements trace call for Tracer::Level2
 374                       // should log a trace message
 375                       //
 376                       // Type:
 377 kumpf            1.43 // Positive
 378 mike             1.2  //
 379                       // return 0 if the test passed
 380                       // return 1 if the test failed
 381                       //
 382                       
 383                       Uint32 test13()
 384                       {
 385                           const char* METHOD_NAME = "test13";
 386                           Tracer::setTraceComponents("ALL");
 387                           Tracer::setTraceLevel(Tracer::LEVEL4);
 388 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL2,"%s %s",
 389                               "Test Message for Level2 in",METHOD_NAME));
 390 mike             1.2      return(compare(FILE2,"Test Message for Level2 in test13"));
 391                       }
 392                       
 393                       //
 394                       // Description:
 395                       // Implements trace call for Tracer::Level3
 396                       // should log a trace message
 397                       //
 398                       // Type:
 399 kumpf            1.43 // Positive
 400 mike             1.2  //
 401                       // return 0 if the test passed
 402                       // return 1 if the test failed
 403                       //
 404                       
 405                       Uint32 test14()
 406                       {
 407                           const char* METHOD_NAME = "test14";
 408                           Tracer::setTraceComponents("ALL");
 409                           Tracer::setTraceLevel(Tracer::LEVEL4);
 410                           Tracer::setTraceFile(FILE3);
 411 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL3,"%s %s",
 412                               "Test Message for Level3 in",METHOD_NAME));
 413 mike             1.2      return(compare(FILE3,"Test Message for Level3 in test14"));
 414                       }
 415                       
 416                       //
 417                       // Description:
 418                       // Implements trace call for Tracer::Level4
 419                       // should log a trace message
 420                       //
 421                       // Type:
 422 kumpf            1.43 // Positive
 423 mike             1.2  //
 424                       // return 0 if the test passed
 425                       // return 1 if the test failed
 426                       //
 427                       
 428                       Uint32 test15()
 429                       {
 430                           const char* METHOD_NAME = "test15";
 431                           Tracer::setTraceComponents("ALL");
 432                           Tracer::setTraceLevel(Tracer::LEVEL4);
 433 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL4,"%s %s",
 434                               "Test Message for Level4 in",METHOD_NAME));
 435 mike             1.2      return(compare(FILE3,"Test Message for Level4 in test15"));
 436                       }
 437                       
 438                       //
 439                       // Description:
 440 marek            1.35 // Implements trace call for Tracer::Level5 (trace enter/exit)
 441                       // should log a trace message
 442                       //
 443                       // Type:
 444 kumpf            1.43 // Positive
 445 marek            1.35 //
 446                       // return 0 if the test passed
 447                       // return 1 if the test failed
 448                       //
 449                       
 450                       Uint32 test15a()
 451                       {
 452                           const char* METHOD_NAME = "test15a";
 453                           Tracer::setTraceComponents("ALL");
 454                           Tracer::setTraceLevel(PEGASUS_TRACER_LEVEL5);
 455                           PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 456                           return(compare(FILE3,"Entering method test15a"));
 457                       }
 458                       
 459                       //
 460                       // Description:
 461                       // Implements trace call for Tracer::Level5 (trace enter/exit)
 462                       // should log a trace message
 463                       //
 464                       // Type:
 465 kumpf            1.43 // Positive
 466 marek            1.35 //
 467                       // return 0 if the test passed
 468                       // return 1 if the test failed
 469                       //
 470                       
 471                       Uint32 test15b()
 472                       {
 473                           const char* METHOD_NAME = "test15b";
 474                           Tracer::setTraceComponents("ALL");
 475                           Tracer::setTraceLevel(PEGASUS_TRACER_LEVEL5);
 476                           PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 477                           PEG_METHOD_EXIT();
 478                           return(compare(FILE3,"Exiting method test15b"));
 479                       }
 480                       
 481                       //
 482                       // Description:
 483 mike             1.2  // calls the setTraceComponents with null string
 484 marek            1.35 // should not log a trace message
 485 mike             1.2  //
 486                       // Type:
 487 kumpf            1.43 // Negative
 488 mike             1.2  //
 489                       // return 0 if the test passed
 490                       // return 1 if the test failed
 491                       //
 492                       
 493                       Uint32 test16()
 494                       {
 495                           const char* METHOD_NAME = "test16";
 496 marek            1.37     Tracer::setTraceComponents("ALL");
 497                           Tracer::setTraceLevel(PEGASUS_TRACER_LEVEL5);
 498 kumpf            1.43     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,"test16 - check value");
 499 mike             1.2      Tracer::setTraceComponents("");
 500                           Tracer::setTraceLevel(Tracer::LEVEL4);
 501 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL4,"%s %s",
 502                           "This Message should not appear in",METHOD_NAME));
 503 marek            1.37     return(compare(FILE3,"test16 - check value"));
 504 mike             1.2  }
 505                       
 506                       //
 507                       // Description:
 508                       // calls the setTraceComponents with one valid and another invalid component
 509                       // should log a trace message
 510                       //
 511                       // Type:
 512 kumpf            1.43 // Negative
 513 mike             1.2  //
 514                       // return 0 if the test passed
 515                       // return 1 if the test failed
 516                       //
 517                       
 518                       Uint32 test17()
 519                       {
 520                           const char* METHOD_NAME = "test17";
 521 marek            1.37     Tracer::setTraceComponents("ALL");
 522                           Tracer::setTraceLevel(PEGASUS_TRACER_LEVEL5);
 523 kumpf            1.43     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,"test17 - check value");
 524 kumpf            1.3      Tracer::setTraceComponents("InvalidComp");
 525 mike             1.2      Tracer::setTraceLevel(Tracer::LEVEL4);
 526 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL4,"%s %s",
 527                           "This Message should not appear in",METHOD_NAME));
 528 marek            1.37     return(compare(FILE3,"test17 - check value"));
 529 mike             1.2  }
 530 kumpf            1.3  //
 531                       // Description:
 532                       // calls the _traceBuffer call
 533                       // should log a trace message
 534                       //
 535                       // Type:
 536                       // Positive
 537                       //
 538                       // return 0 if the test passed
 539                       // return 1 if the test failed
 540                       //
 541                       
 542                       Uint32 test18()
 543                       {
 544                           const char* METHOD_NAME = "test18";
 545                           Tracer::setTraceComponents("Config,InvalidComp");
 546                           Tracer::setTraceLevel(Tracer::LEVEL4);
 547 marek            1.33     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,
 548 marek            1.28         "This Message should appear in");
 549                           return(compare(FILE3,"This Message should appear in"));
 550 kumpf            1.3  }
 551 mike             1.2  
 552 kumpf            1.4  //
 553                       // Description:
 554                       // Trace a string.
 555 marek            1.33 // Calls the PEG_TRACE macro
 556 kumpf            1.4  // should log a trace message
 557                       //
 558                       // Type:
 559                       // Positive
 560                       //
 561                       // return 0 if the test passed
 562                       // return 1 if the test failed
 563                       //
 564                       
 565                       Uint32 test20()
 566                       {
 567                           const char* METHOD_NAME = "test20";
 568                           Tracer::setTraceFile(FILE4);
 569                           Tracer::setTraceComponents("ALL");
 570                           Tracer::setTraceLevel(Tracer::LEVEL4);
 571                       
 572                           PEG_METHOD_ENTER(TRC_CONFIG, METHOD_NAME);
 573 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL4,
 574                           "Test Message for Level4 in test20"));
 575 kumpf            1.4      return(compare(FILE4,"Test Message for Level4 in test20"));
 576                       }
 577                       
 578                       //
 579                       // Description:
 580                       // Trace a CIMException.
 581                       // Calls the traceCIMException() method
 582                       // should log a trace message
 583                       //
 584                       // Type:
 585                       // Positive
 586                       //
 587                       // return 0 if the test passed
 588                       // return 1 if the test failed
 589                       //
 590                       
 591                       Uint32 test21()
 592                       {
 593                           const char* METHOD_NAME = "test21";
 594                           Tracer::setTraceFile(FILE4);
 595                           Tracer::setTraceComponents("ALL");
 596 kumpf            1.4      Tracer::setTraceLevel(Tracer::LEVEL4);
 597                       
 598                           PEG_METHOD_ENTER(TRC_CONFIG, METHOD_NAME);
 599                       
 600                           // test tracing CIMException
 601                           try
 602                           {
 603                               throw PEGASUS_CIM_EXCEPTION(
 604 kumpf            1.43             CIM_ERR_NOT_SUPPORTED,
 605 kumpf            1.4              "CIM Exception Message for Level4 in test21.");
 606                           }
 607 kumpf            1.12     catch (CIMException& e)
 608 kumpf            1.4      {
 609                               Tracer::traceCIMException(TRC_CONFIG,Tracer::LEVEL4, e);
 610                           }
 611                       
 612                           return 0;
 613                       }
 614                       
 615                       //
 616                       // Description:
 617                       // Trace a string using macro.
 618                       // should log a trace message
 619                       //
 620                       // Type:
 621                       // Positive
 622                       //
 623                       // return 0 if the test passed
 624                       // return 1 if the test failed
 625                       //
 626                       Uint32 test22()
 627                       {
 628                           const char* METHOD_NAME = "test22";
 629 kumpf            1.4      Tracer::setTraceFile(FILE4);
 630                           Tracer::setTraceComponents("ALL");
 631                           Tracer::setTraceLevel(Tracer::LEVEL4);
 632                       
 633                           PEG_METHOD_ENTER(TRC_CONFIG, METHOD_NAME);
 634                       
 635 thilo.boehm      1.38     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,
 636                               "Test message for Level4 in test22.");
 637 kumpf            1.4  
 638                           return(compare(FILE4,"Test message for Level4 in test22."));
 639                       }
 640                       
 641 marek            1.28 //
 642                       // Description:
 643                       // Trace a character string using macro.
 644                       // should log a trace message
 645                       //
 646                       // Type:
 647                       // Positive
 648                       //
 649                       // return 0 if the test passed
 650                       // return 1 if the test failed
 651                       //
 652                       Uint32 test23()
 653                       {
 654                           const char* METHOD_NAME = "test23";
 655                           Tracer::setTraceFile(FILE4);
 656                           Tracer::setTraceComponents("ALL");
 657                           Tracer::setTraceLevel(Tracer::LEVEL4);
 658                       
 659                           PEG_METHOD_ENTER(TRC_CONFIG, METHOD_NAME);
 660                       
 661 karl             1.29     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,
 662                                             "Test message for Level4 in test23.");
 663 marek            1.28 
 664                           return(compare(FILE4,"Test message for Level4 in test23."));
 665                       }
 666                       
 667 r.kieninger      1.36 //
 668                       // Description:
 669                       // Change traceFacility to Logger
 670                       // No more trace messages should be written
 671                       //
 672                       // Type:
 673                       // Negative
 674                       //
 675                       // return 0 if the test passed
 676                       // return 1 if the test failed
 677                       //
 678                       Uint32 test24()
 679                       {
 680                           const char* METHOD_NAME = "test24";
 681                           Tracer::setTraceFacility("Log");
 682                           Tracer::setTraceFile(FILE4);
 683                           Tracer::setTraceComponents("ALL");
 684                           Tracer::setTraceLevel(Tracer::LEVEL4);
 685                       
 686                           PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,
 687                                             "Test message for traceFacility=Log in test24.");
 688 r.kieninger      1.36 
 689                           return(compare(FILE4,"Test message for Level4 in test23."));
 690                       }
 691                       
 692                       //
 693                       // Description:
 694                       // Change traceFacility back to File
 695                       // Trace messages should be written again
 696                       //
 697                       // Type:
 698                       // Positive
 699                       //
 700                       // return 0 if the test passed
 701                       // return 1 if the test failed
 702                       //
 703                       Uint32 test25()
 704                       {
 705                           const char* METHOD_NAME = "test25";
 706                           Tracer::setTraceFacility("File");
 707                           Tracer::setTraceFile(FILE4);
 708                           Tracer::setTraceComponents("ALL");
 709 r.kieninger      1.36     Tracer::setTraceLevel(Tracer::LEVEL4);
 710                       
 711                           PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,
 712                                             "Test message for traceFacility=File in test25.");
 713                       
 714                           return(compare(FILE4,"Test message for traceFacility=File in test25."));
 715                       }
 716                       
 717 kumpf            1.43 //
 718 sushma.fernandes 1.30 // Description:
 719                       // Test the getHTTPRequestMessage method.
 720                       //
 721                       // Type:
 722                       // Positive
 723                       // Tests with a HTTP Request without a basic authorization header.
 724                       // Message is written to trace file without any changes.
 725                       //
 726                       // return 0 if the test passed
 727                       // return 1 if the test failed
 728                       //
 729 r.kieninger      1.36 Uint32 test26()
 730 sushma.fernandes 1.30 {
 731                           Tracer::setTraceFile(FILE4);
 732                           Tracer::setTraceComponents("xmlio");
 733                           Tracer::setTraceLevel(Tracer::LEVEL2);
 734                       
 735                           Uint32 queueId = 18;
 736                           CIMPropertyList propertyList;
 737                           Buffer params;
 738                           AcceptLanguageList al;
 739 kumpf            1.43     ContentLanguageList cl;
 740 sushma.fernandes 1.30 
 741                           XmlWriter::appendClassNameIParameter(
 742                               params, "ClassName", CIMName("testclass"));
 743                           Buffer buffer = XmlWriter::formatSimpleIMethodReqMessage(
 744                               "localhost",
 745 kumpf            1.43         CIMNamespaceName("test/cimv2"),
 746 sushma.fernandes 1.30         CIMName ("EnumerateInstanceNames"),
 747 kumpf            1.43         "12345",
 748 sushma.fernandes 1.30         HTTP_METHOD__POST,
 749                               "Basic: Authorization AAAAA",
 750                               al,
 751                               cl,
 752 mike             1.45         params,
 753                               false);
 754 sushma.fernandes 1.30 
 755                           SharedArrayPtr<char> reqMsg(Tracer::getHTTPRequestMessage(
 756                                   buffer));
 757                       
 758                           PEG_TRACE((
 759 kumpf            1.43         TRC_XML_IO,
 760 sushma.fernandes 1.30         Tracer::LEVEL2,
 761                               "<!-- Request: queue id: %u -->\n%s",
 762                               queueId,
 763                               reqMsg.get()));
 764                       
 765                           return(compare(FILE4, buffer.getData()));
 766 kumpf            1.43 }
 767                       
 768                       //
 769 sushma.fernandes 1.30 // Description:
 770                       // Test the getHTTPRequestMessage method.
 771                       //
 772                       // Type:
 773                       // Positive
 774                       // Tests with a HTTP Request that contains a Basic authorization header.
 775 kumpf            1.43 // The user/password info in the message is suppressed before writing it to
 776 sushma.fernandes 1.30 // the trace file.
 777                       //
 778                       // return 0 if the test passed
 779                       // return 1 if the test failed
 780                       //
 781 r.kieninger      1.36 Uint32 test27()
 782 kumpf            1.43 {
 783 sushma.fernandes 1.30     Tracer::setTraceFile(FILE4);
 784                           Tracer::setTraceComponents("xmlio");
 785                           Tracer::setTraceLevel(Tracer::LEVEL2);
 786                       
 787                           Uint32 queueId = 18;
 788                           CIMPropertyList propertyList;
 789                           Buffer params;
 790                           AcceptLanguageList al;
 791                           ContentLanguageList cl;
 792                           String authHeader = "Authorization: Basic ABCDEABCDE==";
 793                           String MSGID = "32423424";
 794                       
 795                           XmlWriter::appendClassNameIParameter(
 796 kumpf            1.43         params,
 797                               "ClassName",
 798 sushma.fernandes 1.30         CIMName("testclass"));
 799                           Buffer buffer = XmlWriter::formatSimpleIMethodReqMessage(
 800                               "localhost",
 801 kumpf            1.43         CIMNamespaceName("test/cimv2"),
 802 sushma.fernandes 1.30         CIMName ("EnumerateInstanceNames"),
 803 kumpf            1.43         MSGID,
 804 sushma.fernandes 1.30         HTTP_METHOD__POST,
 805                               authHeader,
 806                               al,
 807                               cl,
 808 mike             1.45         params,
 809                               false);
 810 sushma.fernandes 1.30 
 811                           PEG_TRACE((
 812 kumpf            1.43         TRC_XML_IO,
 813 sushma.fernandes 1.30         Tracer::LEVEL2,
 814                               "<!-- Request: queue id: %u -->\n%s",
 815                               queueId,
 816                               Tracer::getHTTPRequestMessage(
 817                                   buffer).get()));
 818 kumpf            1.43 
 819 sushma.fernandes 1.30     String testStr(buffer.getData());
 820                           Uint32 pos = testStr.find("ABCDEABCDE==");
 821 kumpf            1.43 
 822 sushma.fernandes 1.30     for ( Uint32 i = pos; i < pos+strlen("ABCDEABCDE=="); i++)
 823                               testStr[i] = 'X';
 824                       
 825                           return(compare(FILE4, testStr.getCString()));
 826                       }
 827                       
 828 thilo.boehm      1.39 
 829                       //----------------------------------------------------------
 830                       // Tests for the traceMemoryHandler
 831                       //----------------------------------------------------------
 832                       typedef struct TTTParmType
 833                       {
 834                           Thread *trd;
 835                           TraceMemoryHandler *trcHandler;
 836                           const char* trcMessage;
 837                           Uint32 msgLen;
 838                           Uint32 number;
 839                           Boolean isVariableMsg;
 840                       } TTTParm;
 841                       
 842                       
 843                       void traceVariableArgs( TraceMemoryHandler *trcHdler,
 844                                               const char* msg, Uint32 msgLen, const char* fmt, ...)
 845                       {
 846                           va_list ap;
 847                           va_start(ap, fmt);
 848                           trcHdler->handleMessage(msg, msgLen, fmt, ap);
 849 thilo.boehm      1.39     va_end(ap);
 850                       }
 851                       
 852                       ThreadReturnType PEGASUS_THREAD_CDECL tracerThread( void* parm )
 853                       {
 854                           Thread *my_handle = (Thread *)parm;
 855                           TTTParm * my_parm = (TTTParm *)my_handle->get_parm();
 856 kumpf            1.43 
 857 thilo.boehm      1.40     Threads::yield();
 858 thilo.boehm      1.39     for (Uint32 x=0; x < my_parm->number; x++)
 859                           {
 860                               if (x % 911 == 0 )
 861                               {
 862                                   // Give other threads time to run.
 863 thilo.boehm      1.40             Threads::yield();
 864 thilo.boehm      1.39         }
 865                               if (my_parm->isVariableMsg)
 866                               {
 867                                   traceVariableArgs(my_parm->trcHandler,
 868                                                     my_parm->trcMessage,
 869                                                     my_parm->msgLen,
 870                                                     my_parm->trcMessage,
 871                                                     VAR_TEST_MESSAGE);
 872                               }
 873                               else
 874                               {
 875                                   my_parm->trcHandler->handleMessage(my_parm->trcMessage,
 876                                                                      my_parm->msgLen);
 877 kumpf            1.43         }
 878 thilo.boehm      1.39     }
 879 kumpf            1.43 
 880 thilo.boehm      1.39     return ThreadReturnType(0);
 881                       }
 882                       
 883                       Uint32 testMemoryHandler(const char* filename)
 884                       {
 885                           #define NUM_TEST_THREADS 99
 886                           Uint32 rc = 0;
 887                       
 888                           TraceMemoryHandler *trcHdler = new TraceMemoryHandler();
 889 thilo.boehm      1.42 
 890 thilo.boehm      1.39     const char* trcMsg1 = "1START A short trace message. END1";
 891                           const char* trcMsg2 = "2START A trace message which is a little longer "
 892                                                 "than the previous trace message. END2";
 893                           const char* trcMsg3 = "3START A trace message which is much longer than "
 894                                                 "the previous trace messages, which were small and a "
 895                                                 "little larger, but this one is at least double the "
 896                                                 "size as both others together. END3";
 897                           const char* trcMsg4 = "4START <%s> END4";
 898                           const char* trcMsgs[] = { trcMsg1, trcMsg2, trcMsg3, trcMsg4 };
 899                           Uint32 numMsgs = sizeof(trcMsgs) / sizeof(const char*);
 900                       
 901                           TTTParm *tttParms[NUM_TEST_THREADS];
 902 kumpf            1.43 
 903 thilo.boehm      1.39     for (int x=0; x < NUM_TEST_THREADS; x++)
 904                           {
 905                               Uint32 msgNumber = x%numMsgs;
 906                               tttParms[x] = new TTTParm();
 907                               tttParms[x]->trd = 0;
 908                               tttParms[x]->trcHandler = trcHdler;
 909                               tttParms[x]->trcMessage = trcMsgs[msgNumber];
 910                               tttParms[x]->msgLen = strlen(trcMsgs[msgNumber]);
 911                               tttParms[x]->number = 100000;
 912                               // Is the message a variable one (= the last in the list)?
 913                               tttParms[x]->isVariableMsg = (msgNumber == (numMsgs-1));
 914                           }
 915 kumpf            1.43 
 916 thilo.boehm      1.39     for (int x=0; x < NUM_TEST_THREADS; x++)
 917                           {
 918                               tttParms[x]->trd = new Thread(tracerThread, tttParms[x], false);
 919                               tttParms[x]->trd->run();
 920                           }
 921                       
 922                           for (int x=0; x < NUM_TEST_THREADS; x++)
 923                           {
 924                               tttParms[x]->trd->join();
 925                           }
 926 kumpf            1.43 
 927 kumpf            1.44     // Setting an empty trace file name should fail.
 928                           PEGASUS_TEST_ASSERT(Tracer::setTraceFile(""));
 929 kumpf            1.43 
 930                           if (Tracer::setTraceFile(filename))
 931 thilo.boehm      1.39     {
 932 thilo.boehm      1.42         cout << "Failure in call to setTraceFile for file \""
 933 thilo.boehm      1.39                 << filename << "\"\n" << endl;
 934                               PEGASUS_TEST_ASSERT(0);
 935                           }
 936 kumpf            1.43 
 937 thilo.boehm      1.39     trcHdler->flushTrace();
 938 kumpf            1.43 
 939 thilo.boehm      1.39     // To test the variable messages, we replace the variable message
 940                           // in the list with a resolved copy.
 941                           Uint32 lastMsg = numMsgs-1;
 942                           char resolvedMsg[1024];
 943                           memcpy( resolvedMsg, trcMsgs[lastMsg], strlen(trcMsgs[lastMsg]) );
 944                           sprintf( resolvedMsg+strlen(trcMsgs[lastMsg]),
 945                                    trcMsgs[lastMsg],
 946                                    VAR_TEST_MESSAGE );
 947                           trcMsgs[lastMsg] = resolvedMsg;
 948                       
 949 kumpf            1.43 
 950 thilo.boehm      1.39     // Now analyze the dumped buffer content, to ensure no messages
 951                           // were damaged.
 952 kumpf            1.43     // For this we read the buffer content line by line and check if it
 953 thilo.boehm      1.39     // matches one of the messages from the list above.
 954                           {
 955                               fstream file;
 956                               file.open(filename, fstream::in);
 957                               if (!file.good())
 958                               {
 959                                   cout << "Failed to open file \"" << filename << "\"\n" << endl;
 960                                   PEGASUS_TEST_ASSERT(0);
 961                               }
 962 kumpf            1.43 
 963                               // Keep the first line on the side, since this is probably the
 964 thilo.boehm      1.39         // wrapped remainder of the very last messsage in the buffer.
 965                               char firstLine[256];
 966                               file.getline( firstLine, 256 );
 967                       
 968                               char currentLine[256];
 969                               file.getline( currentLine, 256 );
 970                       
 971                               while( !file.eof() )
 972                               {
 973                                   Boolean found = false;
 974                                   for (Uint32 x=0; x < numMsgs; x++)
 975                                   {
 976                                       if ( strcmp(trcMsgs[x], currentLine) == 0 )
 977                                       {
 978                                           found = true;
 979                                           continue;
 980                                       }
 981                                   }
 982                                   if ( !found )
 983                                   {
 984                                       if ( strncmp(currentLine, "*EOTRACE*", strlen("*EOTRACE*")) )
 985 thilo.boehm      1.39                 {
 986                                           // if we got here, this is either an error, or we reached
 987                                           // the end of the trace buffer, where it had wrapped.
 988                                           // To check this we paste together the message in the
 989 kumpf            1.43                     // first line we read, and which is supposed to be the
 990 thilo.boehm      1.39                     // remainder of the wrapped message.
 991                                           strcat(currentLine, firstLine);
 992                                           for (Uint32 x=0; x < numMsgs; x++)
 993                                           {
 994                                               if ( strcmp(trcMsgs[x], currentLine) == 0 )
 995                                               {
 996                                                   found = true;
 997                                                   continue;
 998                                               }
 999                                           }
1000                                           if ( !found )
1001                                           {
1002                                               // Diagnostics about the error
1003                                               cout << "Compare Error: unexpected message= \n\""
1004                                                    << currentLine << "\"\n" << endl;
1005                                               PEGASUS_TEST_ASSERT(0);
1006                                           }
1007                                       }
1008                                   }
1009                                   file.getline( currentLine, 256 );
1010                               }
1011 thilo.boehm      1.39         file.close();
1012                           }
1013                       
1014                       
1015                           for (int x=0; x < NUM_TEST_THREADS; x++)
1016                           {
1017                               delete( tttParms[x]->trd );
1018                               delete( tttParms[x] );
1019                           }
1020                       
1021 thilo.boehm      1.41     // test the wrapping of a too long message:
1022                           {
1023                               #define FIX_PART_OF_MESSAGE "LongMsg:"
1024                       
1025 kumpf            1.43         // The trace buffer is not at that size used for tracing
1026 thilo.boehm      1.41         // then it is defined with PEGASUS_TRC_DEFAULT_BUFFER_SIZE_KB*1024
1027                               // The resulting message is shriked by:
1028                               // * the controll structure traceArea_t ( privat of TraceMemoryHandler)
1029                               // * the fixed message part
1030                               // * the markers,  '\n' and '\0'
1031 kumpf            1.43         Uint32 bufferDelta = 2* sizeof(Uint32)+ sizeof(char*)
1032                                                  + PEGASUS_TRC_BUFFER_EYE_CATCHER_LEN
1033 thilo.boehm      1.41                            + strlen(FIX_PART_OF_MESSAGE)
1034                                                  + strlen(PEGASUS_TRC_BUFFER_TRUNC_MARKER) + 1
1035 kumpf            1.43                            + strlen(PEGASUS_TRC_BUFFER_EOT_MARKER)+ 1
1036                                                  // this adds the '2' before the truncation marker
1037 thilo.boehm      1.41                            // should appear in the message
1038                                                  + 1;
1039                       
1040                               Uint32 sizeOfVeryLongMSG=PEGASUS_TRC_DEFAULT_BUFFER_SIZE_KB*1024;
1041                       
1042                               // Construct the big message:
1043                               //  LongMsg:111...11122222222222222
1044                               char* veryLongMSG = (char *)malloc(sizeOfVeryLongMSG);
1045                               memset((void*)veryLongMSG,'1',sizeOfVeryLongMSG-bufferDelta);
1046                               memset((void*)&(veryLongMSG[sizeOfVeryLongMSG-bufferDelta]),
1047                                      '2',bufferDelta);
1048                               veryLongMSG[sizeOfVeryLongMSG-1] = 0 ;
1049                       
1050                               traceVariableArgs(trcHdler,
1051                                                 FIX_PART_OF_MESSAGE,
1052                                                 strlen(FIX_PART_OF_MESSAGE),
1053                                                "%s",
1054                                                 veryLongMSG);
1055                       
1056 thilo.boehm      1.42         Tracer::setTraceFile(filename);
1057 thilo.boehm      1.41         trcHdler->flushTrace();
1058                       
1059                               // resuse the buffer for reading the result file.
1060                               memset((void*)veryLongMSG,0,sizeOfVeryLongMSG);
1061                       
1062                               fstream file;
1063                               file.open(filename, fstream::in);
1064                               if (!file.good())
1065                               {
1066                                   cout << "Failed to open file \"" << filename << "\"\n" << endl;
1067                                   PEGASUS_TEST_ASSERT(0);
1068                               }
1069                       
1070                               // The first line must be the trucated big message.
1071                               file.getline( veryLongMSG, sizeOfVeryLongMSG );
1072                       
1073                               // The second line must be the end of trace marker
1074                               char lastLine[256];
1075                               file.getline( lastLine, 256 );
1076                       
1077                               // The result must be in the two lines. Close the file
1078 thilo.boehm      1.41         file.close();
1079                       
1080                               // the last line must be only the end of trace marker.
1081                               if ( strncmp(lastLine, "*EOTRACE*", strlen("*EOTRACE*")) )
1082                               {
1083                                       cout << "Compare Error: unexpected message= \n\""
1084                                            << lastLine << "\"\n" << endl;
1085                                       PEGASUS_TEST_ASSERT(0);
1086                               }
1087                       
1088                               char* cursor = veryLongMSG;
1089                       
1090 kumpf            1.43         // The big messsage has the format:
1091 thilo.boehm      1.41         //  LongMsg:111...1112*TRUNC*
1092                               // To validate that the message is truncated at the right position,
1093                               // only one '2' has to show up before the truncation marker.
1094 kumpf            1.43 
1095 thilo.boehm      1.41         if ( strncmp(cursor, FIX_PART_OF_MESSAGE
1096                                            , strlen(FIX_PART_OF_MESSAGE)) )
1097                               {
1098                                       cout << "Compare Error: unexpected message= \n\""
1099                                            << cursor << "\"\n" << endl;
1100                                       PEGASUS_TEST_ASSERT(0);
1101                               }
1102                       
1103                               cursor = cursor + strlen(FIX_PART_OF_MESSAGE);
1104                               int noErrors = 0;
1105                               for (int i = 0 ; i < (int)(sizeOfVeryLongMSG-bufferDelta); i++)
1106                               {
1107                                   if (cursor[i] != '1')
1108                                   {
1109                                       noErrors++;
1110                                       cout << "Compare Error: unexpected char '"
1111 kumpf            1.43                      <<  cursor[i] << "' at position "
1112 thilo.boehm      1.41                      << strlen(FIX_PART_OF_MESSAGE) + i
1113                                            << " expecting '1'." << endl;
1114                                       // limmit the number of printed errors to 20
1115                                       if (noErrors > 20 )
1116                                       {
1117                                           cout << "Too manny missmatches. Abort long message test"
1118                                                << endl;
1119                                           PEGASUS_TEST_ASSERT(0);
1120                                       }
1121                       
1122                                   }
1123                               }
1124                       
1125                               // If any error occures in the above test, exit the test.
1126                               if (noErrors != 0)
1127                               {
1128                                 PEGASUS_TEST_ASSERT(0);
1129                               }
1130                       
1131                               if (cursor[(sizeOfVeryLongMSG-bufferDelta)] != '2')
1132                               {
1133 thilo.boehm      1.41             cout << "Compare Error: unexpected char '"
1134 kumpf            1.43                  << cursor[(sizeOfVeryLongMSG-bufferDelta)] << "' at position "
1135                                        << strlen(FIX_PART_OF_MESSAGE) +
1136 thilo.boehm      1.41                        (sizeOfVeryLongMSG-bufferDelta)
1137                                        << " expecting '2'." << endl;
1138                               }
1139                       
1140                               cursor = cursor + (sizeOfVeryLongMSG-bufferDelta) + 1;
1141                               if ( strcmp(cursor, "*TRUNC*") )
1142                               {
1143                                       cout << "Compare Error: unexpected message= \n\""
1144                                            << cursor << "\"\n" << endl;
1145                                       PEGASUS_TEST_ASSERT(0);
1146                               }
1147                       
1148                               free(veryLongMSG);
1149                           }
1150                       
1151 thilo.boehm      1.39     delete( trcHdler );
1152                           return rc;
1153                       }
1154                       
1155                       
1156                       
1157 karl             1.7  int main(int argc, char** argv)
1158 mike             1.2  {
1159                       
1160                       // Execute the tests only if trace calls are included
1161                       
1162                       #ifdef PEGASUS_REMOVE_TRACE
1163 karl             1.7      cout << argv[0] << " +++++ passed all tests" << endl;
1164 mike             1.2      return 0;
1165                       #else
1166 kumpf            1.11 
1167                           const char* tmpDir = getenv ("PEGASUS_TMP");
1168                           if (tmpDir == NULL)
1169                           {
1170                               tmpDir = ".";
1171                           }
1172                           String f1 (tmpDir);
1173 kumpf            1.13     f1.append("/testtracer1.trace");
1174 kumpf            1.14     FILE1 = f1.getCString();
1175 kumpf            1.11     String f2 (tmpDir);
1176 kumpf            1.13     f2.append("/testtracer2.trace");
1177 kumpf            1.14     FILE2 = f2.getCString();
1178 kumpf            1.11     String f3 (tmpDir);
1179 kumpf            1.13     f3.append("/testtracer3.trace");
1180 kumpf            1.14     FILE3 = f3.getCString();
1181 kumpf            1.11     String f4 (tmpDir);
1182 kumpf            1.13     f4.append("/testtracer4.trace");
1183 kumpf            1.14     FILE4 = f4.getCString();
1184 thilo.boehm      1.39     String f5 (tmpDir);
1185                           f5.append("/testtracer5.trace");
1186                           FILE5 = f5.getCString();
1187 kumpf            1.11 
1188 mike             1.2      System::removeFile(FILE1);
1189                           System::removeFile(FILE2);
1190                           System::removeFile(FILE3);
1191 kumpf            1.4      System::removeFile(FILE4);
1192 thilo.boehm      1.39     System::removeFile(FILE5);
1193 kumpf            1.34     if (test1() != 0)
1194 mike             1.2      {
1195                              cout << "Tracer test (test1) failed" << endl;
1196                              exit(1);
1197                           }
1198 kumpf            1.34     if (test2() != 0)
1199 mike             1.2      {
1200                              cout << "Tracer test (test2) failed" << endl;
1201                              exit(1);
1202                           }
1203 kumpf            1.34     if (test3() != 0)
1204 mike             1.2      {
1205                              cout << "Tracer test (test3) failed" << endl;
1206                              exit(1);
1207                           }
1208                           if (test4() != 0)
1209                           {
1210                              cout << "Tracer test (test4) failed" << endl;
1211                              exit(1);
1212                           }
1213                           if (test5() != 0)
1214                           {
1215                              cout << "Tracer test (test5) failed" << endl;
1216                              exit(1);
1217                           }
1218                           if (test6() != 0)
1219                           {
1220                              cout << "Tracer test (test6) failed" << endl;
1221                              exit(1);
1222                           }
1223                           if (test7() != 0)
1224                           {
1225 mike             1.2         cout << "Tracer test (test7) failed" << endl;
1226                              exit(1);
1227                           }
1228                           if (test9() != 0)
1229                           {
1230                              cout << "Tracer test (test9) failed" << endl;
1231                              exit(1);
1232                           }
1233 kumpf            1.43     /***************************
1234 karl             1.27        Test 10 bypassed when tests changed to
1235                              use macros.  It did an invalid call which is
1236                              not possible with macros
1237                       
1238 mike             1.2      if (test10() != 0)
1239                           {
1240                              cout << "Tracer test (test10) failed" << endl;
1241                              exit(1);
1242                           }
1243 karl             1.27     ******************************/
1244 mike             1.2      if (test11() != 0)
1245                           {
1246                              cout << "Tracer test (test11) failed" << endl;
1247                              exit(1);
1248                           }
1249                           if (test12() != 0)
1250                           {
1251                              cout << "Tracer test (test12) failed" << endl;
1252                              exit(1);
1253                           }
1254                           if (test13() != 0)
1255                           {
1256                              cout << "Tracer test (test13) failed" << endl;
1257                              exit(1);
1258                           }
1259                           if (test14() != 0)
1260                           {
1261                              cout << "Tracer test (test14) failed" << endl;
1262                              exit(1);
1263                           }
1264                           if (test15() != 0)
1265 mike             1.2      {
1266                              cout << "Tracer test (test15) failed" << endl;
1267                              exit(1);
1268                           }
1269 marek            1.37 # ifndef PEGASUS_REMOVE_METHODTRACE
1270 marek            1.35     if (test15a() != 0)
1271                           {
1272                              cout << "Tracer test (test15a) failed" << endl;
1273                              exit(1);
1274                           }
1275                           if (test15b() != 0)
1276                           {
1277                              cout << "Tracer test (test15b) failed" << endl;
1278                              exit(1);
1279                           }
1280 marek            1.37 # endif
1281 mike             1.2      if (test16() != 0)
1282                           {
1283                              cout << "Tracer test (test16) failed" << endl;
1284 kumpf            1.3         exit(1);
1285                           }
1286                           if (test17() != 0)
1287                           {
1288                              cout << "Tracer test (test17) failed" << endl;
1289                              exit(1);
1290                           }
1291                           if (test18() != 0)
1292                           {
1293                              cout << "Tracer test (test18) failed" << endl;
1294                              exit(1);
1295                           }
1296 kumpf            1.4      if (test20() != 0)
1297                           {
1298                              cout << "Tracer test (test20) failed" << endl;
1299                              exit(1);
1300                           }
1301                           if (test21() != 0)
1302                           {
1303                              cout << "Tracer test (test21) failed" << endl;
1304                              exit(1);
1305                           }
1306                           if (test22() != 0)
1307                           {
1308                              cout << "Tracer test (test22) failed" << endl;
1309                              exit(1);
1310                           }
1311 marek            1.28     if (test23() != 0)
1312                           {
1313                              cout << "Tracer test (test23) failed" << endl;
1314                              exit(1);
1315                           }
1316 sushma.fernandes 1.30     if (test24() != 0)
1317                           {
1318                              cout << "Tracer test (test24) failed" << endl;
1319                              exit(1);
1320                           }
1321                       
1322                           if (test25() != 0)
1323                           {
1324                              cout << "Tracer test (test25) failed" << endl;
1325                              exit(1);
1326                           }
1327 r.kieninger      1.36     if (test26() != 0)
1328                           {
1329                              cout << "Tracer test (test26) failed" << endl;
1330                              exit(1);
1331                           }
1332                       
1333                           if (test27() != 0)
1334                           {
1335                              cout << "Tracer test (test27) failed" << endl;
1336                              exit(1);
1337                           }
1338 sushma.fernandes 1.30 
1339 thilo.boehm      1.39     if (testMemoryHandler(FILE5) != 0)
1340                           {
1341                              cout << "Tracer test (testMemoryHandler) failed" << endl;
1342                              exit(1);
1343                           }
1344                       
1345                       
1346 karl             1.7      cout << argv[0] << " +++++ passed all tests" << endl;
1347 mike             1.2      System::removeFile(FILE1);
1348                           System::removeFile(FILE2);
1349                           System::removeFile(FILE3);
1350 kumpf            1.4      System::removeFile(FILE4);
1351 thilo.boehm      1.39     System::removeFile(FILE5);
1352 mike             1.2      return 0;
1353                       #endif
1354                       }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2