142 static void Test_logconfiguration_subscribe_helper() {
143 Test_logconfiguration_subscribe_triggered++;
144 }
145
146 void Test_logconfiguration_subscribe() {
147 ResourceMark rm;
148 LogHandle(logging) log;
149
150 LogConfiguration::register_update_listener(&Test_logconfiguration_subscribe_helper);
151
152 LogConfiguration::parse_log_arguments("stdout", "logging=trace", NULL, NULL, log.error_stream());
153 assert(Test_logconfiguration_subscribe_triggered == 1, "subscription not triggered (1)");
154
155 LogConfiguration::configure_stdout(LogLevel::Debug, true, LOG_TAGS(gc));
156 assert(Test_logconfiguration_subscribe_triggered == 2, "subscription not triggered (2)");
157
158 LogConfiguration::disable_logging();
159 assert(Test_logconfiguration_subscribe_triggered == 3, "subscription not triggered (3)");
160 }
161
162 #endif // PRODUCT
|
142 static void Test_logconfiguration_subscribe_helper() {
143 Test_logconfiguration_subscribe_triggered++;
144 }
145
146 void Test_logconfiguration_subscribe() {
147 ResourceMark rm;
148 LogHandle(logging) log;
149
150 LogConfiguration::register_update_listener(&Test_logconfiguration_subscribe_helper);
151
152 LogConfiguration::parse_log_arguments("stdout", "logging=trace", NULL, NULL, log.error_stream());
153 assert(Test_logconfiguration_subscribe_triggered == 1, "subscription not triggered (1)");
154
155 LogConfiguration::configure_stdout(LogLevel::Debug, true, LOG_TAGS(gc));
156 assert(Test_logconfiguration_subscribe_triggered == 2, "subscription not triggered (2)");
157
158 LogConfiguration::disable_logging();
159 assert(Test_logconfiguration_subscribe_triggered == 3, "subscription not triggered (3)");
160 }
161
162 void Test_logtagset_duplicates() {
163 for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
164 char ts_name[512];
165 ts->label(ts_name, sizeof(ts_name), ",");
166
167 // verify that NO_TAG is never followed by a real tag
168 for (size_t i = 0; i < LogTag::MaxTags; i++) {
169 if (ts->tag(i) == LogTag::__NO_TAG) {
170 for (i++; i < LogTag::MaxTags; i++) {
171 assert(ts->tag(i) == LogTag::__NO_TAG,
172 "NO_TAG was followed by a real tag (%s) in tagset %s",
173 LogTag::name(ts->tag(i)), ts_name);
174 }
175 }
176 }
177
178 // verify that there are no duplicate tagsets (same tags in different order)
179 for (LogTagSet* other = ts->next(); other != NULL; other = other->next()) {
180 if (ts->ntags() != other->ntags()) {
181 continue;
182 }
183 bool equal = true;
184 for (size_t i = 0; i < ts->ntags(); i++) {
185 LogTagType tag = ts->tag(i);
186 if (!other->contains(tag)) {
187 equal = false;
188 break;
189 }
190 }
191 // Since tagsets are implemented using template arguments, using both of
192 // the (logically equivalent) tagsets (t1, t2) and (t2, t1) somewhere will
193 // instantiate two different LogTagSetMappings. This causes multiple
194 // tagset instances to be created for the same logical set. We want to
195 // avoid this to save time, memory and prevent any confusion around it.
196 if (equal) {
197 char other_name[512];
198 other->label(other_name, sizeof(other_name), ",");
199 assert(false, "duplicate LogTagSets found: '%s' vs '%s' "
200 "(tags must always be specified in the same order for each tagset)",
201 ts_name, other_name);
202 }
203 }
204 }
205 }
206
207 #endif // PRODUCT
|