mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 18:44:38 +02:00
8147348: LogTagLevelExpression not properly initialized in configure_stdout
Reviewed-by: brutisso, sla
This commit is contained in:
parent
4ca382aeee
commit
127158a210
4 changed files with 65 additions and 59 deletions
|
@ -36,52 +36,54 @@ void Test_log_length() {
|
||||||
remove("loglengthoutput.txt");
|
remove("loglengthoutput.txt");
|
||||||
|
|
||||||
// Write long message to output file
|
// Write long message to output file
|
||||||
LogConfiguration::parse_log_arguments("loglengthoutput.txt", "logging=trace",
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
outputStream* logstream = LogHandle(logging)::trace_stream();
|
LogHandle(logging) log;
|
||||||
logstream->print_cr("01:1234567890-"
|
bool success = LogConfiguration::parse_log_arguments("loglengthoutput.txt", "logging=trace",
|
||||||
"02:1234567890-"
|
NULL, NULL, log.error_stream());
|
||||||
"03:1234567890-"
|
assert(success, "test unable to configure logging");
|
||||||
"04:1234567890-"
|
log.trace("01:1234567890-"
|
||||||
"05:1234567890-"
|
"02:1234567890-"
|
||||||
"06:1234567890-"
|
"03:1234567890-"
|
||||||
"07:1234567890-"
|
"04:1234567890-"
|
||||||
"08:1234567890-"
|
"05:1234567890-"
|
||||||
"09:1234567890-"
|
"06:1234567890-"
|
||||||
"10:1234567890-"
|
"07:1234567890-"
|
||||||
"11:1234567890-"
|
"08:1234567890-"
|
||||||
"12:1234567890-"
|
"09:1234567890-"
|
||||||
"13:1234567890-"
|
"10:1234567890-"
|
||||||
"14:1234567890-"
|
"11:1234567890-"
|
||||||
"15:1234567890-"
|
"12:1234567890-"
|
||||||
"16:1234567890-"
|
"13:1234567890-"
|
||||||
"17:1234567890-"
|
"14:1234567890-"
|
||||||
"18:1234567890-"
|
"15:1234567890-"
|
||||||
"19:1234567890-"
|
"16:1234567890-"
|
||||||
"20:1234567890-"
|
"17:1234567890-"
|
||||||
"21:1234567890-"
|
"18:1234567890-"
|
||||||
"22:1234567890-"
|
"19:1234567890-"
|
||||||
"23:1234567890-"
|
"20:1234567890-"
|
||||||
"24:1234567890-"
|
"21:1234567890-"
|
||||||
"25:1234567890-"
|
"22:1234567890-"
|
||||||
"26:1234567890-"
|
"23:1234567890-"
|
||||||
"27:1234567890-"
|
"24:1234567890-"
|
||||||
"28:1234567890-"
|
"25:1234567890-"
|
||||||
"29:1234567890-"
|
"26:1234567890-"
|
||||||
"30:1234567890-"
|
"27:1234567890-"
|
||||||
"31:1234567890-"
|
"28:1234567890-"
|
||||||
"32:1234567890-"
|
"29:1234567890-"
|
||||||
"33:1234567890-"
|
"30:1234567890-"
|
||||||
"34:1234567890-"
|
"31:1234567890-"
|
||||||
"35:1234567890-"
|
"32:1234567890-"
|
||||||
"36:1234567890-"
|
"33:1234567890-"
|
||||||
"37:1234567890-");
|
"34:1234567890-"
|
||||||
|
"35:1234567890-"
|
||||||
|
"36:1234567890-"
|
||||||
|
"37:1234567890-");
|
||||||
|
LogConfiguration::parse_log_arguments("loglengthoutput.txt", "all=off",
|
||||||
|
NULL, NULL, log.error_stream());
|
||||||
|
|
||||||
// Look for end of message in output file
|
// Look for end of message in output file
|
||||||
FILE* fp;
|
FILE* fp = fopen("loglengthoutput.txt", "r");
|
||||||
fp = fopen("loglengthoutput.txt", "r");
|
assert(fp, "File read error");
|
||||||
assert (fp, "File read error");
|
|
||||||
char output[600];
|
char output[600];
|
||||||
if (fgets(output, 600, fp) != NULL) {
|
if (fgets(output, 600, fp) != NULL) {
|
||||||
assert(strstr(output, "37:1234567890-"), "logging print size error");
|
assert(strstr(output, "37:1234567890-"), "logging print size error");
|
||||||
|
@ -89,5 +91,12 @@ void Test_log_length() {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
remove("loglengthoutput.txt");
|
remove("loglengthoutput.txt");
|
||||||
}
|
}
|
||||||
#endif // PRODUCT
|
|
||||||
|
|
||||||
|
void Test_configure_stdout() {
|
||||||
|
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(logging));
|
||||||
|
assert(log_is_enabled(Info, logging), "configure_stdout did not enable requested logging");
|
||||||
|
assert(!log_is_enabled(Info, logging, gc), "configure_stdout enabled too much logging");
|
||||||
|
LogConfiguration::configure_stdout(LogLevel::Off, false, LOG_TAGS(logging));
|
||||||
|
assert(!log_is_enabled(Info, logging), "configure_stdout did not disable requested logging");
|
||||||
|
}
|
||||||
|
#endif // PRODUCT
|
||||||
|
|
|
@ -29,21 +29,8 @@
|
||||||
|
|
||||||
const char* LogTagLevelExpression::DefaultExpressionString = "all";
|
const char* LogTagLevelExpression::DefaultExpressionString = "all";
|
||||||
|
|
||||||
void LogTagLevelExpression::clear() {
|
|
||||||
_ntags = 0;
|
|
||||||
_ncombinations = 0;
|
|
||||||
for (size_t combination = 0; combination < MaxCombinations; combination++) {
|
|
||||||
_level[combination] = LogLevel::Invalid;
|
|
||||||
_allow_other_tags[combination] = false;
|
|
||||||
for (size_t tag = 0; tag < LogTag::MaxTags; tag++) {
|
|
||||||
_tags[combination][tag] = LogTag::__NO_TAG;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LogTagLevelExpression::parse(const char* str, outputStream* errstream) {
|
bool LogTagLevelExpression::parse(const char* str, outputStream* errstream) {
|
||||||
bool success = true;
|
bool success = true;
|
||||||
clear();
|
|
||||||
if (str == NULL || strcmp(str, "") == 0) {
|
if (str == NULL || strcmp(str, "") == 0) {
|
||||||
str = DefaultExpressionString;
|
str = DefaultExpressionString;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,11 @@ class LogTagLevelExpression : public StackObj {
|
||||||
bool _allow_other_tags[MaxCombinations];
|
bool _allow_other_tags[MaxCombinations];
|
||||||
|
|
||||||
void new_combination() {
|
void new_combination() {
|
||||||
|
// Make sure either all tags are set or the last tag is __NO_TAG
|
||||||
|
if (_ntags < LogTag::MaxTags) {
|
||||||
|
_tags[_ncombinations][_ntags] = LogTag::__NO_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
_ncombinations++;
|
_ncombinations++;
|
||||||
_ntags = 0;
|
_ntags = 0;
|
||||||
}
|
}
|
||||||
|
@ -64,10 +69,13 @@ class LogTagLevelExpression : public StackObj {
|
||||||
_allow_other_tags[_ncombinations] = true;
|
_allow_other_tags[_ncombinations] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LogTagLevelExpression() : _ntags(0), _ncombinations(0) {
|
LogTagLevelExpression() : _ntags(0), _ncombinations(0) {
|
||||||
|
for (size_t combination = 0; combination < MaxCombinations; combination++) {
|
||||||
|
_level[combination] = LogLevel::Invalid;
|
||||||
|
_allow_other_tags[combination] = false;
|
||||||
|
_tags[combination][0] = LogTag::__NO_TAG;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parse(const char* str, outputStream* errstream = NULL);
|
bool parse(const char* str, outputStream* errstream = NULL);
|
||||||
|
|
|
@ -53,6 +53,7 @@ void Test_linked_list();
|
||||||
void TestResourcehash_test();
|
void TestResourcehash_test();
|
||||||
void TestChunkedList_test();
|
void TestChunkedList_test();
|
||||||
void Test_log_length();
|
void Test_log_length();
|
||||||
|
void Test_configure_stdout();
|
||||||
void Test_TempNewSymbol();
|
void Test_TempNewSymbol();
|
||||||
void GlobalDefinitions_test();
|
void GlobalDefinitions_test();
|
||||||
void GCTimer_test();
|
void GCTimer_test();
|
||||||
|
@ -110,6 +111,7 @@ void InternalVMTests::run() {
|
||||||
run_unit_test(TestChunkedList_test());
|
run_unit_test(TestChunkedList_test());
|
||||||
run_unit_test(JSON_test());
|
run_unit_test(JSON_test());
|
||||||
run_unit_test(Test_log_length());
|
run_unit_test(Test_log_length());
|
||||||
|
run_unit_test(Test_configure_stdout());
|
||||||
run_unit_test(DirectivesParser_test());
|
run_unit_test(DirectivesParser_test());
|
||||||
run_unit_test(Test_TempNewSymbol());
|
run_unit_test(Test_TempNewSymbol());
|
||||||
#if INCLUDE_VM_STRUCTS
|
#if INCLUDE_VM_STRUCTS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue