< prev index next >

test/hotspot/gtest/logging/test_log.cpp

Print this page




   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 "gc/shared/gcTraceTime.inline.hpp"
  26 #include "logTestFixture.hpp"
  27 #include "logTestUtils.inline.hpp"
  28 #include "logging/log.hpp"
  29 #include "prims/jvm.h"
  30 #include "unittest.hpp"
  31 
  32 class LogTest : public LogTestFixture {
  33 };
  34 
  35 #define LOG_PREFIX_STR "THE_PREFIX "
  36 #define LOG_LINE_STR "a log line"
  37 
  38 size_t Test_log_prefix_prefixer(char* buf, size_t len) {
  39   int ret = jio_snprintf(buf, len, LOG_PREFIX_STR);
  40   assert(ret > 0, "Failed to print prefix. Log buffer too small?");
  41   return (size_t) ret;
  42 }
  43 
  44 #ifdef ASSERT // 'test' tag is debug only
  45 TEST_VM_F(LogTest, prefix) {
  46   set_log_config(TestLogFileName, "logging+test=trace");
  47   log_trace(logging, test)(LOG_LINE_STR);
  48   EXPECT_TRUE(file_contains_substring(TestLogFileName, LOG_PREFIX_STR LOG_LINE_STR));
  49 }




   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 "jvm.h"
  26 #include "gc/shared/gcTraceTime.inline.hpp"
  27 #include "logTestFixture.hpp"
  28 #include "logTestUtils.inline.hpp"
  29 #include "logging/log.hpp"

  30 #include "unittest.hpp"
  31 
  32 class LogTest : public LogTestFixture {
  33 };
  34 
  35 #define LOG_PREFIX_STR "THE_PREFIX "
  36 #define LOG_LINE_STR "a log line"
  37 
  38 size_t Test_log_prefix_prefixer(char* buf, size_t len) {
  39   int ret = jio_snprintf(buf, len, LOG_PREFIX_STR);
  40   assert(ret > 0, "Failed to print prefix. Log buffer too small?");
  41   return (size_t) ret;
  42 }
  43 
  44 #ifdef ASSERT // 'test' tag is debug only
  45 TEST_VM_F(LogTest, prefix) {
  46   set_log_config(TestLogFileName, "logging+test=trace");
  47   log_trace(logging, test)(LOG_LINE_STR);
  48   EXPECT_TRUE(file_contains_substring(TestLogFileName, LOG_PREFIX_STR LOG_LINE_STR));
  49 }


< prev index next >