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

   1 karl  1.26 //%2006////////////////////////////////////////////////////////////////////////
   2 mike  1.2  //
   3 karl  1.18 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
   4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   6 karl  1.16 // IBM Corp.; EMC Corporation, The Open Group.
   7 karl  1.18 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   9 karl  1.21 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
  11 karl  1.26 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  12            // EMC Corporation; Symantec Corporation; The Open Group.
  13 mike  1.2  //
  14            // Permission is hereby granted, free of charge, to any person obtaining a copy
  15            // of this software and associated documentation files (the "Software"), to
  16            // deal in the Software without restriction, including without limitation the
  17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  18            // sell copies of the Software, and to permit persons to whom the Software is
  19            // furnished to do so, subject to the following conditions:
  20 kumpf 1.9  // 
  21 mike  1.2  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  22            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
  23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  24            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29            //
  30 karl  1.29 //=============================================================================
  31 mike  1.2  //
  32            //%/////////////////////////////////////////////////////////////////////////////
  33            
  34            #include <fstream>
  35            #include <cstring>
  36            #include <Pegasus/Common/System.h>
  37            #include <Pegasus/Common/Tracer.h>
  38 thilo.boehm 1.39 #include <Pegasus/Common/TraceMemoryHandler.h>
  39 a.arora     1.17 #include <Pegasus/Common/AutoPtr.h>
  40 sushma.fernandes 1.30 #include <Pegasus/Common/SharedPtr.h>
  41                       #include <Pegasus/Common/CIMClass.h>
  42                       #include <Pegasus/Common/CIMMessage.h>
  43                       #include <Pegasus/Common/XmlWriter.h>
  44                       #include <Pegasus/Common/AcceptLanguageList.h>
  45                       #include <Pegasus/Common/ContentLanguageList.h>
  46 mike             1.2  
  47                       PEGASUS_USING_STD;
  48                       PEGASUS_USING_PEGASUS;
  49                       
  50 marek            1.35 
  51                       // Trace Levels 0 and 5 are defined as private constants of the tracer
  52                       // class to avoid inappropriate use in the trace calls and macros.
  53                       // Therefore these tracel levels need to be set in the tests using the
  54                       // constant values directly.
  55                       const Uint32 PEGASUS_TRACER_LEVEL0 =  0;
  56                       const Uint32 PEGASUS_TRACER_LEVEL5 = (1 << 4);
  57                       
  58                       
  59 mike             1.2  // Trace files for test purposes
  60 kumpf            1.11 // Will be created in the $(PEGASUS_TMP) directory, or if not set,
  61                       // in the current directory
  62 kumpf            1.15 CString FILE1;
  63                       CString FILE2;
  64                       CString FILE3;
  65                       CString FILE4;
  66 thilo.boehm      1.39 CString FILE5;
  67                       
  68                       // A message string for testing the tracer with variable arguments
  69                       #define VAR_TEST_MESSAGE "Variable length part of message"
  70                       
  71 mike             1.2  
  72 kumpf            1.43 //
  73                       // Reads the last trace message from a given trace file and compares the
  74 mike             1.2  // given string with the string read from file
  75                       //
  76                       // return 0 if the strings match
  77                       // return 1 if the strings do not match
  78                       //
  79 kumpf            1.31 Uint32 compare(const char* fileName, const char* expectedMessage)
  80 mike             1.2  {
  81 kumpf            1.31     int expectedMessageLength = strlen(expectedMessage);
  82                       
  83                           // Compute the size of the message in the trace file.  Include the final
  84                           // EOL character added by the Tracer.  This size will be used to seek
  85                           // from the end of the file back to the beginning of the trace message.
  86                           int seekBytes = expectedMessageLength + 1;
  87                       
  88                       #if defined(PEGASUS_OS_TYPE_WINDOWS)
  89                           // Windows converts all '\n' characters to "\r\n" sequences in the trace
  90                           // file.  Increase the seekBytes by the number of '\r' characters added
  91                           // when the message is written to the file.
  92                           for (const char* newlineChar = expectedMessage;
  93                                ((newlineChar = strchr(newlineChar, '\n')) != 0);
  94                                newlineChar++)
  95                           {
  96                               seekBytes++;
  97                           }
  98                       
  99                           // Count the '\r' character added with the final '\n' written by the Tracer
 100                           seekBytes++;
 101                       #endif
 102 kumpf            1.31 
 103                           AutoArrayPtr<char> actualMessage(new char[expectedMessageLength + 1]);
 104                       
 105                           // Read the trace message from the file, minus the message prefix and
 106                           // minus the trailing newline.
 107 mike             1.2      fstream file;
 108 kumpf            1.31     file.open(fileName, fstream::in);
 109 mike             1.2      if (!file.good())
 110                           {
 111 kumpf            1.31         return 1;
 112 mike             1.2      }
 113 kumpf            1.31     file.seekg(-seekBytes, fstream::end);
 114                           file.read(actualMessage.get(), expectedMessageLength);
 115                           file.close();
 116                           actualMessage[expectedMessageLength] = 0;
 117                       
 118                           // Compare the expected and actual messages
 119                           Uint32 retCode = strcmp(expectedMessage, actualMessage.get());
 120                       
 121 thilo.boehm      1.39     // Diagnostic to determine string differences
 122 kumpf            1.31     if (retCode)
 123                               cout << "Compare Error: expectedMessage= \n\"" << expectedMessage <<
 124                                   "\". actualMessage= \n\"" << actualMessage.get() << "\"" << endl;
 125 karl             1.27 
 126 mike             1.2      return retCode;
 127                       }
 128                       
 129                       //
 130                       // Description:
 131                       // Trace properties file, level and component are not set
 132                       // Should not log a trace message
 133                       //
 134                       // Type:
 135 kumpf            1.43 // Negative
 136 mike             1.2  //
 137                       // return 0 if the test passed
 138                       // return 1 if the test failed
 139                       //
 140                       Uint32 test1()
 141                       {
 142                           const char* METHOD_NAME = "test1";
 143 kumpf            1.10     PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 144 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL2,"%s %d",
 145                               "This message should not appear value=",123));
 146 kumpf            1.10     PEG_METHOD_EXIT();
 147 kumpf            1.34     return System::exists(FILE1) ? 1 : 0;
 148 mike             1.2  }
 149                       
 150                       //
 151                       // Description:
 152                       // Trace properties level and component are not set
 153                       // Should not log a trace message
 154                       //
 155                       // Type:
 156 kumpf            1.43 // Negative
 157 mike             1.2  //
 158                       // return 0 if the test passed
 159                       // return 1 if the test failed
 160                       //
 161                       Uint32 test2()
 162                       {
 163                           const char* METHOD_NAME = "test2";
 164                           Tracer::setTraceFile(FILE1);
 165 kumpf            1.10     PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 166 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL2,"%s %d",
 167                               "This message should not appear value=",123));
 168 thilo.boehm      1.42     Uint32 fileSize = 0;
 169 kumpf            1.34     System::getFileSize(FILE1, fileSize);
 170                           return (fileSize == 0) ? 0 : 1;
 171 mike             1.2  }
 172                       
 173                       //
 174                       // Description:
 175                       // Trace properties component is not set
 176                       // Should not log a trace message
 177                       //
 178                       // Type:
 179 kumpf            1.43 // Negative
 180 mike             1.2  //
 181                       // return 0 if the test passed
 182                       // return 1 if the test failed
 183                       //
 184                       Uint32 test3()
 185                       {
 186                           const char* METHOD_NAME = "test3";
 187                           Tracer::setTraceLevel(Tracer::LEVEL1);
 188 kumpf            1.10     PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 189 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL2,"%s",
 190                               "This message should not appear"));
 191 thilo.boehm      1.42     Uint32 fileSize = 0;
 192 kumpf            1.34     System::getFileSize(FILE1, fileSize);
 193                           return (fileSize == 0) ? 0 : 1;
 194 mike             1.2  }
 195                       
 196                       //
 197                       // Description:
 198                       // Trace properties file, level and component are set
 199                       // should log a trace message
 200                       //
 201                       // Type:
 202 kumpf            1.43 // Positive
 203 mike             1.2  //
 204                       // return 0 if the test passed
 205                       // return 1 if the test failed
 206                       //
 207                       Uint32 test4()
 208                       {
 209                           const char* METHOD_NAME = "test4";
 210 marek            1.37     Tracer::setTraceLevel(Tracer::LEVEL1);
 211 mike             1.2      Tracer::setTraceComponents("Config");
 212 marek            1.37     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL1,METHOD_NAME);
 213                           return(compare(FILE1,METHOD_NAME));
 214 mike             1.2  }
 215                       
 216                       //
 217                       // Description:
 218                       // Trace component is set to an invalid component
 219                       // should not log a trace message
 220                       //
 221                       // Type:
 222 kumpf            1.43 // Negative
 223 mike             1.2  //
 224                       // return 0 if the test passed
 225                       // return 1 if the test failed
 226                       //
 227                       Uint32 test5()
 228                       {
 229                           const char* METHOD_NAME = "test5";
 230                           Tracer::setTraceComponents("Wrong Component Name");
 231 karl             1.27 
 232                           PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 233 marek            1.37     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL1,METHOD_NAME);
 234 karl             1.27     PEG_METHOD_EXIT();
 235 marek            1.37     return(compare(FILE1,"test4"));
 236 mike             1.2  }
 237                       
 238                       //
 239                       // Description:
 240 kumpf            1.43 // Trace level is set to LEVEL 2 and logs a LEVEL 4 message
 241 mike             1.2  // should not log a trace message
 242                       //
 243                       // Type:
 244 kumpf            1.43 // Negative
 245 mike             1.2  //
 246                       // return 0 if the test passed
 247                       // return 1 if the test failed
 248                       //
 249                       
 250                       Uint32 test6()
 251                       {
 252                           const char* METHOD_NAME = "test6";
 253                           Tracer::setTraceComponents("Config");
 254                           Tracer::setTraceLevel(Tracer::LEVEL2);
 255 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL2,"%s %s",
 256                               "Test Message for Level2 in",METHOD_NAME));
 257                           PEG_TRACE((TRC_CONFIG,Tracer::LEVEL2,"%s %s",
 258                               "Test Message for Level2 in",METHOD_NAME));
 259                           PEG_TRACE((TRC_CONFIG,Tracer::LEVEL4,"%s",
 260                               "This Message should not appear"));
 261 mike             1.2      return(compare(FILE1,"Test Message for Level2 in test6"));
 262                       }
 263                       
 264                       //
 265                       // Description:
 266                       // Trace level is set to an invalid level
 267                       // should not log a trace message
 268                       //
 269                       // Type:
 270 kumpf            1.43 // Negative
 271 mike             1.2  //
 272                       // return 0 if the test passed
 273                       // return 1 if the test failed
 274                       //
 275                       Uint32 test7()
 276                       {
 277                           const char* METHOD_NAME = "test7";
 278                           Tracer::setTraceLevel(100);
 279 karl             1.27     PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 280                           PEG_METHOD_EXIT();
 281 mike             1.2      return(compare(FILE1,"Test Message for Level2 in test6"));
 282                       }
 283                       
 284                       //
 285                       // Description:
 286 kumpf            1.43 // Changes the trace file to FILE2
 287 mike             1.2  //
 288                       // Type:
 289 kumpf            1.43 // Positive
 290 mike             1.2  //
 291                       // return 0 if the test passed
 292                       // return 1 if the test failed
 293                       //
 294                       Uint32 test9()
 295                       {
 296                           const char* METHOD_NAME = "test9";
 297                           Tracer::setTraceLevel(Tracer::LEVEL3);
 298                           Tracer::setTraceFile(FILE2);
 299                       
 300 kumpf            1.10     PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 301 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL3,"%s %s",
 302                               "Test Message for Level3 in",METHOD_NAME));
 303 mike             1.2      return(compare(FILE2,"Test Message for Level3 in test9"));
 304                       }
 305                       
 306                       //
 307                       // Description:
 308                       // Passes invalid component in the trace call
 309                       // should not log a trace message
 310                       //
 311                       // Type:
 312 kumpf            1.43 // Negative
 313 mike             1.2  //
 314                       // return 0 if the test passed
 315                       // return 1 if the test failed
 316                       //
 317 marek            1.35 // This test not required with change to
 318 karl             1.27 // use and test macros only.
 319 mike             1.2  
 320                       Uint32 test10()
 321                       {
 322                           const char* METHOD_NAME = "test10";
 323                           Tracer::setTraceComponents("ALL");
 324 karl             1.27     PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 325                           PEG_METHOD_EXIT();
 326 mike             1.2      return(compare(FILE2,"Test Message for Level3 in test9"));
 327                       }
 328                       
 329                       //
 330                       // Description:
 331 marek            1.35 // Trace is set to level 0
 332                       // should not log a trace message
 333 mike             1.2  //
 334                       // Type:
 335 marek            1.35 // Negative
 336 mike             1.2  //
 337                       // return 0 if the test passed
 338                       // return 1 if the test failed
 339                       //
 340                       
 341                       Uint32 test11()
 342                       {
 343                           const char* METHOD_NAME = "test11";
 344                           Tracer::setTraceComponents("ALL");
 345 marek            1.35     Tracer::setTraceLevel(PEGASUS_TRACER_LEVEL0);
 346                           PEG_TRACE((TRC_CONFIG,Tracer::LEVEL1,"%s %s",
 347                               "Test Message for Level0 in",METHOD_NAME));
 348                           return(compare(FILE2,"Test Message for Level3 in test9"));
 349 mike             1.2  }
 350                       
 351                       //
 352                       // Description:
 353                       // Implements trace call for Tracer::Level1
 354                       // should log a trace message
 355                       //
 356                       // Type:
 357 kumpf            1.43 // Positive
 358 mike             1.2  //
 359                       // return 0 if the test passed
 360                       // return 1 if the test failed
 361                       //
 362                       
 363                       Uint32 test12()
 364                       {
 365                           const char* METHOD_NAME = "test12";
 366                           Tracer::setTraceComponents("ALL");
 367                           Tracer::setTraceLevel(Tracer::LEVEL4);
 368 marek            1.35     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL1,"%s %s",
 369                               "Test Message for Level1 in",METHOD_NAME));
 370                           return(compare(FILE2,"Test Message for Level1 in test12"));
 371 mike             1.2  }
 372                       
 373                       //
 374                       // Description:
 375                       // Implements trace call for Tracer::Level2
 376                       // should log a trace message
 377                       //
 378                       // Type:
 379 kumpf            1.43 // Positive
 380 mike             1.2  //
 381                       // return 0 if the test passed
 382                       // return 1 if the test failed
 383                       //
 384                       
 385                       Uint32 test13()
 386                       {
 387                           const char* METHOD_NAME = "test13";
 388                           Tracer::setTraceComponents("ALL");
 389                           Tracer::setTraceLevel(Tracer::LEVEL4);
 390 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL2,"%s %s",
 391                               "Test Message for Level2 in",METHOD_NAME));
 392 mike             1.2      return(compare(FILE2,"Test Message for Level2 in test13"));
 393                       }
 394                       
 395                       //
 396                       // Description:
 397                       // Implements trace call for Tracer::Level3
 398                       // should log a trace message
 399                       //
 400                       // Type:
 401 kumpf            1.43 // Positive
 402 mike             1.2  //
 403                       // return 0 if the test passed
 404                       // return 1 if the test failed
 405                       //
 406                       
 407                       Uint32 test14()
 408                       {
 409                           const char* METHOD_NAME = "test14";
 410                           Tracer::setTraceComponents("ALL");
 411                           Tracer::setTraceLevel(Tracer::LEVEL4);
 412                           Tracer::setTraceFile(FILE3);
 413 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL3,"%s %s",
 414                               "Test Message for Level3 in",METHOD_NAME));
 415 mike             1.2      return(compare(FILE3,"Test Message for Level3 in test14"));
 416                       }
 417                       
 418                       //
 419                       // Description:
 420                       // Implements trace call for Tracer::Level4
 421                       // should log a trace message
 422                       //
 423                       // Type:
 424 kumpf            1.43 // Positive
 425 mike             1.2  //
 426                       // return 0 if the test passed
 427                       // return 1 if the test failed
 428                       //
 429                       
 430                       Uint32 test15()
 431                       {
 432                           const char* METHOD_NAME = "test15";
 433                           Tracer::setTraceComponents("ALL");
 434                           Tracer::setTraceLevel(Tracer::LEVEL4);
 435 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL4,"%s %s",
 436                               "Test Message for Level4 in",METHOD_NAME));
 437 mike             1.2      return(compare(FILE3,"Test Message for Level4 in test15"));
 438                       }
 439                       
 440                       //
 441                       // Description:
 442 marek            1.35 // Implements trace call for Tracer::Level5 (trace enter/exit)
 443                       // should log a trace message
 444                       //
 445                       // Type:
 446 kumpf            1.43 // Positive
 447 marek            1.35 //
 448                       // return 0 if the test passed
 449                       // return 1 if the test failed
 450                       //
 451                       
 452                       Uint32 test15a()
 453                       {
 454                           const char* METHOD_NAME = "test15a";
 455                           Tracer::setTraceComponents("ALL");
 456                           Tracer::setTraceLevel(PEGASUS_TRACER_LEVEL5);
 457                           PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 458                           return(compare(FILE3,"Entering method test15a"));
 459                       }
 460                       
 461                       //
 462                       // Description:
 463                       // Implements trace call for Tracer::Level5 (trace enter/exit)
 464                       // should log a trace message
 465                       //
 466                       // Type:
 467 kumpf            1.43 // Positive
 468 marek            1.35 //
 469                       // return 0 if the test passed
 470                       // return 1 if the test failed
 471                       //
 472                       
 473                       Uint32 test15b()
 474                       {
 475                           const char* METHOD_NAME = "test15b";
 476                           Tracer::setTraceComponents("ALL");
 477                           Tracer::setTraceLevel(PEGASUS_TRACER_LEVEL5);
 478                           PEG_METHOD_ENTER(TRC_CONFIG,METHOD_NAME);
 479                           PEG_METHOD_EXIT();
 480                           return(compare(FILE3,"Exiting method test15b"));
 481                       }
 482                       
 483                       //
 484                       // Description:
 485 mike             1.2  // calls the setTraceComponents with null string
 486 marek            1.35 // should not log a trace message
 487 mike             1.2  //
 488                       // Type:
 489 kumpf            1.43 // Negative
 490 mike             1.2  //
 491                       // return 0 if the test passed
 492                       // return 1 if the test failed
 493                       //
 494                       
 495                       Uint32 test16()
 496                       {
 497                           const char* METHOD_NAME = "test16";
 498 marek            1.37     Tracer::setTraceComponents("ALL");
 499                           Tracer::setTraceLevel(PEGASUS_TRACER_LEVEL5);
 500 kumpf            1.43     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,"test16 - check value");
 501 mike             1.2      Tracer::setTraceComponents("");
 502                           Tracer::setTraceLevel(Tracer::LEVEL4);
 503 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL4,"%s %s",
 504                           "This Message should not appear in",METHOD_NAME));
 505 marek            1.37     return(compare(FILE3,"test16 - check value"));
 506 mike             1.2  }
 507                       
 508                       //
 509                       // Description:
 510                       // calls the setTraceComponents with one valid and another invalid component
 511                       // should log a trace message
 512                       //
 513                       // Type:
 514 kumpf            1.43 // Negative
 515 mike             1.2  //
 516                       // return 0 if the test passed
 517                       // return 1 if the test failed
 518                       //
 519                       
 520                       Uint32 test17()
 521                       {
 522                           const char* METHOD_NAME = "test17";
 523 marek            1.37     Tracer::setTraceComponents("ALL");
 524                           Tracer::setTraceLevel(PEGASUS_TRACER_LEVEL5);
 525 kumpf            1.43     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,"test17 - check value");
 526 kumpf            1.3      Tracer::setTraceComponents("InvalidComp");
 527 mike             1.2      Tracer::setTraceLevel(Tracer::LEVEL4);
 528 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL4,"%s %s",
 529                           "This Message should not appear in",METHOD_NAME));
 530 marek            1.37     return(compare(FILE3,"test17 - check value"));
 531 mike             1.2  }
 532 kumpf            1.3  //
 533                       // Description:
 534                       // calls the _traceBuffer call
 535                       // should log a trace message
 536                       //
 537                       // Type:
 538                       // Positive
 539                       //
 540                       // return 0 if the test passed
 541                       // return 1 if the test failed
 542                       //
 543                       
 544                       Uint32 test18()
 545                       {
 546                           const char* METHOD_NAME = "test18";
 547                           Tracer::setTraceComponents("Config,InvalidComp");
 548                           Tracer::setTraceLevel(Tracer::LEVEL4);
 549 marek            1.33     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,
 550 marek            1.28         "This Message should appear in");
 551                           return(compare(FILE3,"This Message should appear in"));
 552 kumpf            1.3  }
 553 mike             1.2  
 554 kumpf            1.4  //
 555                       // Description:
 556                       // Trace a string.
 557 marek            1.33 // Calls the PEG_TRACE macro
 558 kumpf            1.4  // should log a trace message
 559                       //
 560                       // Type:
 561                       // Positive
 562                       //
 563                       // return 0 if the test passed
 564                       // return 1 if the test failed
 565                       //
 566                       
 567                       Uint32 test20()
 568                       {
 569                           const char* METHOD_NAME = "test20";
 570                           Tracer::setTraceFile(FILE4);
 571                           Tracer::setTraceComponents("ALL");
 572                           Tracer::setTraceLevel(Tracer::LEVEL4);
 573                       
 574                           PEG_METHOD_ENTER(TRC_CONFIG, METHOD_NAME);
 575 marek            1.33     PEG_TRACE((TRC_CONFIG,Tracer::LEVEL4,
 576                           "Test Message for Level4 in test20"));
 577 kumpf            1.4      return(compare(FILE4,"Test Message for Level4 in test20"));
 578                       }
 579                       
 580                       //
 581                       // Description:
 582                       // Trace a CIMException.
 583                       // Calls the traceCIMException() method
 584                       // should log a trace message
 585                       //
 586                       // Type:
 587                       // Positive
 588                       //
 589                       // return 0 if the test passed
 590                       // return 1 if the test failed
 591                       //
 592                       
 593                       Uint32 test21()
 594                       {
 595                           const char* METHOD_NAME = "test21";
 596                           Tracer::setTraceFile(FILE4);
 597                           Tracer::setTraceComponents("ALL");
 598 kumpf            1.4      Tracer::setTraceLevel(Tracer::LEVEL4);
 599                       
 600                           PEG_METHOD_ENTER(TRC_CONFIG, METHOD_NAME);
 601                       
 602                           // test tracing CIMException
 603                           try
 604                           {
 605                               throw PEGASUS_CIM_EXCEPTION(
 606 kumpf            1.43             CIM_ERR_NOT_SUPPORTED,
 607 kumpf            1.4              "CIM Exception Message for Level4 in test21.");
 608                           }
 609 kumpf            1.12     catch (CIMException& e)
 610 kumpf            1.4      {
 611                               Tracer::traceCIMException(TRC_CONFIG,Tracer::LEVEL4, e);
 612                           }
 613                       
 614                           return 0;
 615                       }
 616                       
 617                       //
 618                       // Description:
 619                       // Trace a string using macro.
 620                       // should log a trace message
 621                       //
 622                       // Type:
 623                       // Positive
 624                       //
 625                       // return 0 if the test passed
 626                       // return 1 if the test failed
 627                       //
 628                       Uint32 test22()
 629                       {
 630                           const char* METHOD_NAME = "test22";
 631 kumpf            1.4      Tracer::setTraceFile(FILE4);
 632                           Tracer::setTraceComponents("ALL");
 633                           Tracer::setTraceLevel(Tracer::LEVEL4);
 634                       
 635                           PEG_METHOD_ENTER(TRC_CONFIG, METHOD_NAME);
 636                       
 637 thilo.boehm      1.38     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,
 638                               "Test message for Level4 in test22.");
 639 kumpf            1.4  
 640                           return(compare(FILE4,"Test message for Level4 in test22."));
 641                       }
 642                       
 643 marek            1.28 //
 644                       // Description:
 645                       // Trace a character string using macro.
 646                       // should log a trace message
 647                       //
 648                       // Type:
 649                       // Positive
 650                       //
 651                       // return 0 if the test passed
 652                       // return 1 if the test failed
 653                       //
 654                       Uint32 test23()
 655                       {
 656                           const char* METHOD_NAME = "test23";
 657                           Tracer::setTraceFile(FILE4);
 658                           Tracer::setTraceComponents("ALL");
 659                           Tracer::setTraceLevel(Tracer::LEVEL4);
 660                       
 661                           PEG_METHOD_ENTER(TRC_CONFIG, METHOD_NAME);
 662                       
 663 karl             1.29     PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,
 664                                             "Test message for Level4 in test23.");
 665 marek            1.28 
 666                           return(compare(FILE4,"Test message for Level4 in test23."));
 667                       }
 668                       
 669 r.kieninger      1.36 //
 670                       // Description:
 671                       // Change traceFacility to Logger
 672                       // No more trace messages should be written
 673                       //
 674                       // Type:
 675                       // Negative
 676                       //
 677                       // return 0 if the test passed
 678                       // return 1 if the test failed
 679                       //
 680                       Uint32 test24()
 681                       {
 682                           const char* METHOD_NAME = "test24";
 683                           Tracer::setTraceFacility("Log");
 684                           Tracer::setTraceFile(FILE4);
 685                           Tracer::setTraceComponents("ALL");
 686                           Tracer::setTraceLevel(Tracer::LEVEL4);
 687                       
 688                           PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,
 689                                             "Test message for traceFacility=Log in test24.");
 690 r.kieninger      1.36 
 691                           return(compare(FILE4,"Test message for Level4 in test23."));
 692                       }
 693                       
 694                       //
 695                       // Description:
 696                       // Change traceFacility back to File
 697                       // Trace messages should be written again
 698                       //
 699                       // Type:
 700                       // Positive
 701                       //
 702                       // return 0 if the test passed
 703                       // return 1 if the test failed
 704                       //
 705                       Uint32 test25()
 706                       {
 707                           const char* METHOD_NAME = "test25";
 708                           Tracer::setTraceFacility("File");
 709                           Tracer::setTraceFile(FILE4);
 710                           Tracer::setTraceComponents("ALL");
 711 r.kieninger      1.36     Tracer::setTraceLevel(Tracer::LEVEL4);
 712                       
 713                           PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL4,
 714                                             "Test message for traceFacility=File in test25.");
 715                       
 716                           return(compare(FILE4,"Test message for traceFacility=File in test25."));
 717                       }
 718                       
 719 kumpf            1.43 //
 720 sushma.fernandes 1.30 // Description:
 721                       // Test the getHTTPRequestMessage method.
 722                       //
 723                       // Type:
 724                       // Positive
 725                       // Tests with a HTTP Request without a basic authorization header.
 726                       // Message is written to trace file without any changes.
 727                       //
 728                       // return 0 if the test passed
 729                       // return 1 if the test failed
 730                       //
 731 r.kieninger      1.36 Uint32 test26()
 732 sushma.fernandes 1.30 {
 733                           Tracer::setTraceFile(FILE4);
 734                           Tracer::setTraceComponents("xmlio");
 735                           Tracer::setTraceLevel(Tracer::LEVEL2);
 736                       
 737                           Uint32 queueId = 18;
 738                           CIMPropertyList propertyList;
 739                           Buffer params;
 740                           AcceptLanguageList al;
 741 kumpf            1.43     ContentLanguageList cl;
 742 sushma.fernandes 1.30 
 743                           XmlWriter::appendClassNameIParameter(
 744                               params, "ClassName", CIMName("testclass"));
 745                           Buffer buffer = XmlWriter::formatSimpleIMethodReqMessage(
 746                               "localhost",
 747 kumpf            1.43         CIMNamespaceName("test/cimv2"),
 748 sushma.fernandes 1.30         CIMName ("EnumerateInstanceNames"),
 749 kumpf            1.43         "12345",
 750 sushma.fernandes 1.30         HTTP_METHOD__POST,
 751                               "Basic: Authorization AAAAA",
 752                               al,
 753                               cl,
 754                               params);
 755                       
 756                           SharedArrayPtr<char> reqMsg(Tracer::getHTTPRequestMessage(
 757                                   buffer));
 758                       
 759                           PEG_TRACE((
 760 kumpf            1.43         TRC_XML_IO,
 761 sushma.fernandes 1.30         Tracer::LEVEL2,
 762                               "<!-- Request: queue id: %u -->\n%s",
 763                               queueId,
 764                               reqMsg.get()));
 765                       
 766                           return(compare(FILE4, buffer.getData()));
 767 kumpf            1.43 }
 768                       
 769                       //
 770 sushma.fernandes 1.30 // Description:
 771                       // Test the getHTTPRequestMessage method.
 772                       //
 773                       // Type:
 774                       // Positive
 775                       // Tests with a HTTP Request that contains a Basic authorization header.
 776 kumpf            1.43 // The user/password info in the message is suppressed before writing it to
 777 sushma.fernandes 1.30 // the trace file.
 778                       //
 779                       // return 0 if the test passed
 780                       // return 1 if the test failed
 781                       //
 782 r.kieninger      1.36 Uint32 test27()
 783 kumpf            1.43 {
 784 sushma.fernandes 1.30     Tracer::setTraceFile(FILE4);
 785                           Tracer::setTraceComponents("xmlio");
 786                           Tracer::setTraceLevel(Tracer::LEVEL2);
 787                       
 788                           Uint32 queueId = 18;
 789                           CIMPropertyList propertyList;
 790                           Buffer params;
 791                           AcceptLanguageList al;
 792                           ContentLanguageList cl;
 793                           String authHeader = "Authorization: Basic ABCDEABCDE==";
 794                           String MSGID = "32423424";
 795                       
 796                           XmlWriter::appendClassNameIParameter(
 797 kumpf            1.43         params,
 798                               "ClassName",
 799 sushma.fernandes 1.30         CIMName("testclass"));
 800                           Buffer buffer = XmlWriter::formatSimpleIMethodReqMessage(
 801                               "localhost",
 802 kumpf            1.43         CIMNamespaceName("test/cimv2"),
 803 sushma.fernandes 1.30         CIMName ("EnumerateInstanceNames"),
 804 kumpf            1.43         MSGID,
 805 sushma.fernandes 1.30         HTTP_METHOD__POST,
 806                               authHeader,
 807                               al,
 808                               cl,
 809                               params);
 810                       
 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                           // Setting a null trace file should fail.
 928                           PEGASUS_TEST_ASSERT(Tracer::setTraceFile(0));
 929                       
 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