/* * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
// Verify that copying the selection also works as expected
LogSelection copy = selection;
EXPECT_EQ(2u, copy.ntags());
EXPECT_EQ(LogLevel::Trace, copy.level());
tags[0] = PREFIX_LOG_TAG(gc);
tags[1] = PREFIX_LOG_TAG(_NO_TAG);
LogSelection copy2(tags, true, LogLevel::Off); // start with a completely different selection
copy2 = selection; // and test copy assignment
EXPECT_EQ(2u, copy2.ntags());
EXPECT_EQ(LogLevel::Trace, copy2.level());
}
EXPECT_EQ(1u, selection.tag_sets_selected()) << "there should be a single (it's not a wildcard selection) " "tag set selected by this (in gtest libjvm)";
EXPECT_EQ(LogTagSet::ntagsets(), LogSelection::parse("all").tag_sets_selected()) << "all should select every tag set";
EXPECT_EQ(0u, LogSelection::parse(NON_EXISTING_TAG_SET).tag_sets_selected()) << "(assuming the tag set doesn't exist) the selection shouldn't select any tag sets";
}
// Verify valid expressions parse without problems for (size_t i = 0; i < ARRAY_SIZE(valid_expression); i++) {
EXPECT_NE(LogSelection::Invalid, LogSelection::parse(valid_expression[i])) << "Valid expression '" << valid_expression[i] << "' did not parse";
}
// Test 'all' with each level for (LogLevelType level = LogLevel::First; level <= LogLevel::Last; level = static_cast<LogLevelType>(level + 1)) { char buf[64]; int ret = jio_snprintf(buf, sizeof(buf), "all=%s", LogLevel::name(level));
ASSERT_NE(-1, ret);
LogSelection sel = LogSelection::parse(buf);
EXPECT_EQ(LogTagSet::ntagsets(), sel.tag_sets_selected()) << "'all' should select all tag sets";
EXPECT_EQ(level, sel.level());
}
// Test with 5 tags
LogTagType expected_tags[] = { PREFIX_LOG_TAG(logging), PREFIX_LOG_TAG(test), PREFIX_LOG_TAG(start),
PREFIX_LOG_TAG(exit), PREFIX_LOG_TAG(safepoint) };
LogSelection expected(expected_tags, false, LogLevel::Debug);
LogSelection five_tag_selection = LogSelection::parse("logging+test+start+exit+safepoint=debug");
EXPECT_EQ(5u, five_tag_selection.ntags()) << "parsed wrong number of tags";
EXPECT_EQ(expected, five_tag_selection);
EXPECT_EQ(LogLevel::Debug, five_tag_selection.level());
// Use only the invalid substr
EXPECT_EQ(LogSelection::Invalid, LogSelection::parse(invalid_selection_substr[j])) << "'" << invalid_selection_substr[j] << "'" << " considered legal";
}
// Suffix/prefix with some unique invalid prefixes/suffixes
jio_snprintf(buf, sizeof(buf), "*%s", valid_expression[i]);
EXPECT_EQ(LogSelection::Invalid, LogSelection::parse(buf)) << "'" << buf << "'" << " considered legal";
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.