< prev index next >

src/share/vm/utilities/ostream.cpp

Print this page




 526   FREE_C_HEAP_ARRAY(char, o_result);
 527 
 528   // %p-test.log
 529   jio_snprintf(i_result, JVM_MAXPATHLEN, "pid%u-test.log", pid);
 530   o_result = make_log_name_internal("%p-test.log", NULL, pid, tms);
 531   assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"%%p-test.log\", NULL)");
 532   FREE_C_HEAP_ARRAY(char, o_result);
 533 
 534   // %t.log
 535   jio_snprintf(i_result, JVM_MAXPATHLEN, "%s.log", tms);
 536   o_result = make_log_name_internal("%t.log", NULL, pid, tms);
 537   assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"%%t.log\", NULL)");
 538   FREE_C_HEAP_ARRAY(char, o_result);
 539 
 540   {
 541     // longest filename
 542     char longest_name[JVM_MAXPATHLEN];
 543     memset(longest_name, 'a', sizeof(longest_name));
 544     longest_name[JVM_MAXPATHLEN - 1] = '\0';
 545     o_result = make_log_name_internal((const char*)&longest_name, NULL, pid, tms);
 546     assert(strcmp(longest_name, o_result) == 0, err_msg("longest name does not match. expected '%s' but got '%s'", longest_name, o_result));
 547     FREE_C_HEAP_ARRAY(char, o_result);
 548   }
 549 
 550   {
 551     // too long file name
 552     char too_long_name[JVM_MAXPATHLEN + 100];
 553     int too_long_length = sizeof(too_long_name);
 554     memset(too_long_name, 'a', too_long_length);
 555     too_long_name[too_long_length - 1] = '\0';
 556     o_result = make_log_name_internal((const char*)&too_long_name, NULL, pid, tms);
 557     assert(o_result == NULL, err_msg("Too long file name should return NULL, but got '%s'", o_result));
 558   }
 559 
 560   {
 561     // too long with timestamp
 562     char longest_name[JVM_MAXPATHLEN];
 563     memset(longest_name, 'a', JVM_MAXPATHLEN);
 564     longest_name[JVM_MAXPATHLEN - 3] = '%';
 565     longest_name[JVM_MAXPATHLEN - 2] = 't';
 566     longest_name[JVM_MAXPATHLEN - 1] = '\0';
 567     o_result = make_log_name_internal((const char*)&longest_name, NULL, pid, tms);
 568     assert(o_result == NULL, err_msg("Too long file name after timestamp expansion should return NULL, but got '%s'", o_result));
 569   }
 570 
 571   {
 572     // too long with pid
 573     char longest_name[JVM_MAXPATHLEN];
 574     memset(longest_name, 'a', JVM_MAXPATHLEN);
 575     longest_name[JVM_MAXPATHLEN - 3] = '%';
 576     longest_name[JVM_MAXPATHLEN - 2] = 'p';
 577     longest_name[JVM_MAXPATHLEN - 1] = '\0';
 578     o_result = make_log_name_internal((const char*)&longest_name, NULL, pid, tms);
 579     assert(o_result == NULL, err_msg("Too long file name after pid expansion should return NULL, but got '%s'", o_result));
 580   }
 581 }
 582 #endif // PRODUCT
 583 
 584 fileStream::fileStream(const char* file_name) {
 585   _file = fopen(file_name, "w");
 586   if (_file != NULL) {
 587     _need_close = true;
 588   } else {
 589     warning("Cannot open file %s due to %s\n", file_name, strerror(errno));
 590     _need_close = false;
 591   }
 592 }
 593 
 594 fileStream::fileStream(const char* file_name, const char* opentype) {
 595   _file = fopen(file_name, opentype);
 596   if (_file != NULL) {
 597     _need_close = true;
 598   } else {
 599     warning("Cannot open file %s due to %s\n", file_name, strerror(errno));




 526   FREE_C_HEAP_ARRAY(char, o_result);
 527 
 528   // %p-test.log
 529   jio_snprintf(i_result, JVM_MAXPATHLEN, "pid%u-test.log", pid);
 530   o_result = make_log_name_internal("%p-test.log", NULL, pid, tms);
 531   assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"%%p-test.log\", NULL)");
 532   FREE_C_HEAP_ARRAY(char, o_result);
 533 
 534   // %t.log
 535   jio_snprintf(i_result, JVM_MAXPATHLEN, "%s.log", tms);
 536   o_result = make_log_name_internal("%t.log", NULL, pid, tms);
 537   assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"%%t.log\", NULL)");
 538   FREE_C_HEAP_ARRAY(char, o_result);
 539 
 540   {
 541     // longest filename
 542     char longest_name[JVM_MAXPATHLEN];
 543     memset(longest_name, 'a', sizeof(longest_name));
 544     longest_name[JVM_MAXPATHLEN - 1] = '\0';
 545     o_result = make_log_name_internal((const char*)&longest_name, NULL, pid, tms);
 546     assert(strcmp(longest_name, o_result) == 0, "longest name does not match. expected '%s' but got '%s'", longest_name, o_result);
 547     FREE_C_HEAP_ARRAY(char, o_result);
 548   }
 549 
 550   {
 551     // too long file name
 552     char too_long_name[JVM_MAXPATHLEN + 100];
 553     int too_long_length = sizeof(too_long_name);
 554     memset(too_long_name, 'a', too_long_length);
 555     too_long_name[too_long_length - 1] = '\0';
 556     o_result = make_log_name_internal((const char*)&too_long_name, NULL, pid, tms);
 557     assert(o_result == NULL, "Too long file name should return NULL, but got '%s'", o_result);
 558   }
 559 
 560   {
 561     // too long with timestamp
 562     char longest_name[JVM_MAXPATHLEN];
 563     memset(longest_name, 'a', JVM_MAXPATHLEN);
 564     longest_name[JVM_MAXPATHLEN - 3] = '%';
 565     longest_name[JVM_MAXPATHLEN - 2] = 't';
 566     longest_name[JVM_MAXPATHLEN - 1] = '\0';
 567     o_result = make_log_name_internal((const char*)&longest_name, NULL, pid, tms);
 568     assert(o_result == NULL, "Too long file name after timestamp expansion should return NULL, but got '%s'", o_result);
 569   }
 570 
 571   {
 572     // too long with pid
 573     char longest_name[JVM_MAXPATHLEN];
 574     memset(longest_name, 'a', JVM_MAXPATHLEN);
 575     longest_name[JVM_MAXPATHLEN - 3] = '%';
 576     longest_name[JVM_MAXPATHLEN - 2] = 'p';
 577     longest_name[JVM_MAXPATHLEN - 1] = '\0';
 578     o_result = make_log_name_internal((const char*)&longest_name, NULL, pid, tms);
 579     assert(o_result == NULL, "Too long file name after pid expansion should return NULL, but got '%s'", o_result);
 580   }
 581 }
 582 #endif // PRODUCT
 583 
 584 fileStream::fileStream(const char* file_name) {
 585   _file = fopen(file_name, "w");
 586   if (_file != NULL) {
 587     _need_close = true;
 588   } else {
 589     warning("Cannot open file %s due to %s\n", file_name, strerror(errno));
 590     _need_close = false;
 591   }
 592 }
 593 
 594 fileStream::fileStream(const char* file_name, const char* opentype) {
 595   _file = fopen(file_name, opentype);
 596   if (_file != NULL) {
 597     _need_close = true;
 598   } else {
 599     warning("Cannot open file %s due to %s\n", file_name, strerror(errno));


< prev index next >