223 ASSERT_NE(-1, ret); |
223 ASSERT_NE(-1, ret); |
224 EXPECT_TRUE(is_described(buf)) << "'" << buf << "' not described after reconfiguration"; |
224 EXPECT_TRUE(is_described(buf)) << "'" << buf << "' not described after reconfiguration"; |
225 |
225 |
226 // Now reconfigure logging on stderr with no decorators |
226 // Now reconfigure logging on stderr with no decorators |
227 set_log_config("stderr", "all=off", "none"); |
227 set_log_config("stderr", "all=off", "none"); |
228 EXPECT_TRUE(is_described("#1: stderr all=off none\n")) << "Expecting no decorators"; |
228 EXPECT_TRUE(is_described("#1: stderr all=off none (reconfigured)\n")) << "Expecting no decorators"; |
229 } |
229 } |
230 |
230 |
231 // Test that invalid options cause configuration errors |
231 // Test that invalid options cause configuration errors |
232 TEST_VM_F(LogConfigurationTest, invalid_configure_options) { |
232 TEST_VM_F(LogConfigurationTest, invalid_configure_options) { |
233 LogConfiguration::disable_logging(); |
233 LogConfiguration::disable_logging(); |
412 ret = jio_snprintf(buf, sizeof(buf), "file=%s", TestLogFileName); |
412 ret = jio_snprintf(buf, sizeof(buf), "file=%s", TestLogFileName); |
413 ASSERT_NE(-1, ret); |
413 ASSERT_NE(-1, ret); |
414 delete_file(buf); |
414 delete_file(buf); |
415 } |
415 } |
416 |
416 |
|
417 static size_t count_occurrences(const char* haystack, const char* needle) { |
|
418 size_t count = 0; |
|
419 for (const char* p = strstr(haystack, needle); p != NULL; p = strstr(p + 1, needle)) { |
|
420 count++; |
|
421 } |
|
422 return count; |
|
423 } |
|
424 |
|
425 TEST_OTHER_VM(LogConfiguration, output_reconfigured) { |
|
426 ResourceMark rm; |
|
427 stringStream ss; |
|
428 |
|
429 EXPECT_FALSE(is_described("(reconfigured)")); |
|
430 |
|
431 bool success = LogConfiguration::parse_log_arguments("#1", "all=warning", NULL, NULL, &ss); |
|
432 ASSERT_TRUE(success); |
|
433 EXPECT_EQ(0u, ss.size()); |
|
434 |
|
435 LogConfiguration::describe(&ss); |
|
436 EXPECT_EQ(1u, count_occurrences(ss.as_string(), "(reconfigured)")); |
|
437 |
|
438 ss.reset(); |
|
439 LogConfiguration::configure_stdout(LogLevel::Info, false, LOG_TAGS(logging)); |
|
440 LogConfiguration::describe(&ss); |
|
441 EXPECT_EQ(2u, count_occurrences(ss.as_string(), "(reconfigured)")); |
|
442 } |
|
443 |
417 TEST_VM_F(LogConfigurationTest, suggest_similar_selection) { |
444 TEST_VM_F(LogConfigurationTest, suggest_similar_selection) { |
418 static const char* nonexisting_tagset = "logging+start+exit+safepoint+gc"; |
445 static const char* nonexisting_tagset = "logging+start+exit+safepoint+gc"; |
419 |
446 |
420 ResourceMark rm; |
447 ResourceMark rm; |
421 stringStream ss; |
448 stringStream ss; |