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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2