1 /* 2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 #include "precompiled.hpp" 25 #include "logTestUtils.inline.hpp" 26 #include "logging/logConfiguration.hpp" 27 #include "logging/logTagSet.hpp" 28 #include "logging/logTagSetDescriptions.hpp" 29 #include "memory/resourceArea.hpp" 30 #include "prims/jvm.h" 31 #include "unittest.hpp" 32 #include "utilities/ostream.hpp" 33 34 TEST_VM(LogTagSetDescriptions, describe) { 35 for (LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) { 36 char expected[1 * K]; 37 d->tagset->label(expected, sizeof(expected), "+"); 38 jio_snprintf(expected + strlen(expected), 39 sizeof(expected) - strlen(expected), 40 ": %s", d->descr); 41 42 ResourceMark rm; 43 stringStream stream; 44 LogConfiguration::describe(&stream); 45 EXPECT_PRED2(string_contains_substring, stream.as_string(), expected) 46 << "missing log tag set descriptions in LogConfiguration::describe"; 47 } 48 } 49 50 TEST_VM(LogTagSetDescriptions, command_line_help) { 51 const char* filename = "logtagset_descriptions"; 52 FILE* fp = fopen(filename, "w+"); 53 ASSERT_NE((void*)NULL, fp); 54 LogConfiguration::print_command_line_help(fp); 55 fclose(fp); 56 57 for (LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) { 58 char expected[1 * K]; 59 d->tagset->label(expected, sizeof(expected), "+"); 60 jio_snprintf(expected + strlen(expected), 61 sizeof(expected) - strlen(expected), 62 ": %s", d->descr); 63 64 EXPECT_TRUE(file_contains_substring(filename, expected)) << "missing log tag set descriptions in -Xlog:help output"; 65 } 66 delete_file(filename); 67 }