Daniel Carvalho has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/41397 )

Change subject: tests: Remove gtest/logging
......................................................................

tests: Remove gtest/logging

The existence of this file does not allow testing logging.cc,
since they are mutually exclusive.

Change-Id: Ib2dc780e06e7790526b34fb12d15dbb588e6c425
---
M src/base/SConscript
M src/base/debug.test.cc
D src/base/gtest/SConscript
D src/base/gtest/logging.cc
M src/base/loader/SConscript
M src/base/socket.test.cc
M src/base/stats/SConscript
M src/base/stats/storage.test.cc
M src/dev/SConscript
M src/sim/SConscript
10 files changed, 35 insertions(+), 159 deletions(-)



diff --git a/src/base/SConscript b/src/base/SConscript
index 1190b93..03f54f6 100644
--- a/src/base/SConscript
+++ b/src/base/SConscript
@@ -41,22 +41,23 @@
 GTest('cprintf.test', 'cprintf.test.cc')
 Executable('cprintftime', 'cprintftime.cc', 'cprintf.cc')
 Source('debug.cc')
-GTest('debug.test', 'debug.test.cc', 'debug.cc')
+GTest('debug.test', 'debug.test.cc', 'debug.cc', with_tag('gem5 logging'))
 if env['USE_FENV']:
     Source('fenv.c')
 if env['USE_PNG']:
     Source('pngwriter.cc')
 Source('fiber.cc')
-GTest('fiber.test', 'fiber.test.cc', 'fiber.cc')
+GTest('fiber.test', 'fiber.test.cc', 'fiber.cc', with_tag('gem5 logging'))
 GTest('flags.test', 'flags.test.cc')
-GTest('coroutine.test', 'coroutine.test.cc', 'fiber.cc')
+GTest('coroutine.test', 'coroutine.test.cc', 'fiber.cc',
+    with_tag('gem5 logging'))
 Source('framebuffer.cc')
-Source('hostinfo.cc')
+Source('hostinfo.cc', add_tags='gem5 logging')
 Source('inet.cc')
 Source('inifile.cc')
 GTest('inifile.test', 'inifile.test.cc', 'inifile.cc', 'str.cc')
-GTest('intmath.test', 'intmath.test.cc')
-Source('logging.cc')
+GTest('intmath.test', 'intmath.test.cc', with_tag('gem5 logging'))
+Source('logging.cc', add_tags='gem5 logging')
 Source('match.cc')
 GTest('match.test', 'match.test.cc', 'match.cc', 'str.cc')
 Source('output.cc')
@@ -67,27 +68,29 @@
 if env['TARGET_ISA'] != 'null':
     Source('remote_gdb.cc')
 Source('socket.cc')
-GTest('socket.test', 'socket.test.cc', 'socket.cc')
+GTest('socket.test', 'socket.test.cc', 'socket.cc', with_tag('gem5 logging'))
 Source('statistics.cc')
 Source('str.cc')
-GTest('str.test', 'str.test.cc', 'str.cc')
+GTest('str.test', 'str.test.cc', 'str.cc', with_tag('gem5 logging'))
 Source('time.cc')
 Source('version.cc')
 Source('temperature.cc')
 GTest('temperature.test', 'temperature.test.cc', 'temperature.cc')
 Source('trace.cc')
-GTest('trie.test', 'trie.test.cc')
+GTest('trie.test', 'trie.test.cc', with_tag('gem5 logging'))
 Source('types.cc')
 GTest('types.test', 'types.test.cc', 'types.cc')
 GTest('uncontended_mutex.test', 'uncontended_mutex.test.cc')

-GTest('addr_range.test', 'addr_range.test.cc')
-GTest('addr_range_map.test', 'addr_range_map.test.cc')
+GTest('addr_range.test', 'addr_range.test.cc', with_tag('gem5 logging'))
+GTest('addr_range_map.test', 'addr_range_map.test.cc',
+    with_tag('gem5 logging'))
 GTest('bitunion.test', 'bitunion.test.cc')
-GTest('channel_addr.test', 'channel_addr.test.cc', 'channel_addr.cc')
-GTest('circlebuf.test', 'circlebuf.test.cc')
+GTest('channel_addr.test', 'channel_addr.test.cc', 'channel_addr.cc',
+    with_tag('gem5 logging'))
+GTest('circlebuf.test', 'circlebuf.test.cc', with_tag('gem5 logging'))
 GTest('circular_queue.test', 'circular_queue.test.cc')
-GTest('sat_counter.test', 'sat_counter.test.cc')
+GTest('sat_counter.test', 'sat_counter.test.cc', with_tag('gem5 logging'))
 GTest('refcnt.test','refcnt.test.cc')
 GTest('condcodes.test', 'condcodes.test.cc')
 GTest('chunk_generator.test', 'chunk_generator.test.cc')
diff --git a/src/base/debug.test.cc b/src/base/debug.test.cc
index f995a33..49b1af8 100644
--- a/src/base/debug.test.cc
+++ b/src/base/debug.test.cc
@@ -26,6 +26,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include <gmock/gmock.h>
 #include <gtest/gtest.h>

 #include "base/debug.hh"
@@ -50,14 +51,10 @@
 /** Test that names are unique. */
 TEST(DebugFlagDeathTest, UniqueNames)
 {
+ // We only care that the error message contains the name of the debug flag
     Debug::SimpleFlag flag("FlagUniqueNamesTest", "A");
-    testing::internal::CaptureStderr();
-    EXPECT_ANY_THROW(Debug::SimpleFlag("FlagUniqueNamesTest", "B"));
-    const std::string expected = "panic: panic condition !result.second "
-        "occurred: Flag FlagUniqueNamesTest already defined!\n";
-    std::string actual = testing::internal::GetCapturedStderr().substr();
-    actual = actual.substr(actual.find(":", actual.find(":") + 1) + 2);
-    EXPECT_EQ(expected, actual);
+    ASSERT_DEATH(Debug::SimpleFlag("FlagUniqueNamesTest", "B"),
+        ::testing::HasSubstr("FlagUniqueNamesTest"));
 }

 /** Test format attribute. */
diff --git a/src/base/gtest/SConscript b/src/base/gtest/SConscript
deleted file mode 100644
index 4bc34b5..0000000
--- a/src/base/gtest/SConscript
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2017 Google Inc.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met: redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer;
-# redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution;
-# neither the name of the copyright holders nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-Import('*')
-
-Source('logging.cc', tags=('gtest lib', 'gtest logging'))
diff --git a/src/base/gtest/logging.cc b/src/base/gtest/logging.cc
deleted file mode 100644
index 8d40682..0000000
--- a/src/base/gtest/logging.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <gtest/gtest.h>
-
-#include <array>
-#include <string>
-
-#include "base/cprintf.hh"
-#include "base/logging.hh"
-
-namespace {
-
-// This custom exception type will help prevent fatal exceptions from being
-// caught by other code in gem5 and let them escape to the gtest framework.
-// Unfortunately that results in a somewhat confusing message about an unknown -// exception being thrown after the panic/fatal message has been printed, but
-// there will at least be some indication what went wrong.
-struct GTestException
-{};
-
-class GTestExitLogger : public Logger
-{
-  public:
-    using Logger::Logger;
-
-  protected:
-    void
-    log(const Loc &loc, std::string s) override
-    {
-        std::cerr << loc.file << ":" << loc.line << ": " << s;
-    }
-    // Throw an exception to escape down to the gtest framework.
-    void exit() override { throw GTestException(); }
-};
-
-GTestExitLogger panicLogger("panic: ");
-GTestExitLogger fatalLogger("fatal: ");
-Logger warnLogger("warn: ");
-Logger infoLogger("info: ");
-Logger hackLogger("hack: ");
-
-} // anonymous namespace
-
-Logger &Logger::getPanic() { return panicLogger; }
-Logger &Logger::getFatal() { return fatalLogger; }
-Logger &Logger::getWarn() { return warnLogger; }
-Logger &Logger::getInfo() { return infoLogger; }
-Logger &Logger::getHack() { return hackLogger; }
diff --git a/src/base/loader/SConscript b/src/base/loader/SConscript
index d17875f..4b5d559 100644
--- a/src/base/loader/SConscript
+++ b/src/base/loader/SConscript
@@ -31,7 +31,8 @@
 Source('dtb_file.cc')
 Source('elf_object.cc')
 Source('image_file_data.cc')
-GTest('image_file_data.test', 'image_file_data.test.cc', 'image_file_data.cc')
+GTest('image_file_data.test', 'image_file_data.test.cc', 'image_file_data.cc',
+    '../logging.cc', '../hostinfo.cc')
 Source('memory_image.cc')
 Source('object_file.cc')
 Source('symtab.cc')
diff --git a/src/base/socket.test.cc b/src/base/socket.test.cc
index 7262a02..04c4831 100644
--- a/src/base/socket.test.cc
+++ b/src/base/socket.test.cc
@@ -95,7 +95,7 @@
     EXPECT_FALSE(listen_socket.allDisabled());
 }

-TEST(SocketTest, RelistenWithSameInstanceSamePort)
+TEST(SocketDeathTest, RelistenWithSameInstanceSamePort)
 {
     MockListenSocket listen_socket;
     EXPECT_TRUE(listen_socket.listen(TEST_PORT_1));
@@ -103,24 +103,11 @@
     /*
* You cannot listen to another port if you are already listening to one.
      */
-    testing::internal::CaptureStderr();
-    EXPECT_ANY_THROW(listen_socket.listen(TEST_PORT_1));
-    std::string expected = "panic: Socket already listening!\n";
-    std::string actual = testing::internal::GetCapturedStderr().substr();
-
-    /*
-     * The GoogleExitLogger will output using the following:
-     * `std::cerr << loc.file << ":" << loc.line << ": " << s;`
-     * As we do not care about the file and line where the error originated
- * (this may change, and it shouldn't break the test when this happens), - * we strip out the leading `<file>:<line>: ` (we simply remove everything
-     * prior to two characters after the second colon in the string).
-     */
-    actual = actual.substr(actual.find(":", actual.find(":") + 1) + 2);
-    EXPECT_EQ(expected, actual);
+    EXPECT_DEATH(listen_socket.listen(TEST_PORT_1),
+        "panic: Socket already listening!\n");
 }

-TEST(SocketTest, RelistenWithSameInstanceDifferentPort)
+TEST(SocketDeathTest, RelistenWithSameInstanceDifferentPort)
 {
     MockListenSocket listen_socket;
     EXPECT_TRUE(listen_socket.listen(TEST_PORT_1));
@@ -128,13 +115,8 @@
     /*
* You cannot listen to another port if you are already listening to one.
      */
-    testing::internal::CaptureStderr();
-    EXPECT_ANY_THROW(listen_socket.listen(TEST_PORT_2));
-
-    std::string expected = "panic: Socket already listening!\n";
-    std::string actual = testing::internal::GetCapturedStderr().substr();
-    actual = actual.substr(actual.find(":", actual.find(":") + 1) + 2);
-    EXPECT_EQ(expected, actual);
+    EXPECT_DEATH(listen_socket.listen(TEST_PORT_2),
+        "panic: Socket already listening!\n");
 }

 TEST(SocketTest, RelistenWithDifferentInstanceOnDifferentPort)
diff --git a/src/base/stats/SConscript b/src/base/stats/SConscript
index 8f037ba..659be93 100644
--- a/src/base/stats/SConscript
+++ b/src/base/stats/SConscript
@@ -41,4 +41,4 @@
         Source('hdf5.cc')

GTest('storage.test', 'storage.test.cc', '../debug.cc', '../str.cc', 'info.cc',
-    'storage.cc', '../../sim/cur_tick.cc')
+    'storage.cc', '../../sim/cur_tick.cc', with_tag('gem5 logging'))
diff --git a/src/base/stats/storage.test.cc b/src/base/stats/storage.test.cc
index 3218438..d058f20 100644
--- a/src/base/stats/storage.test.cc
+++ b/src/base/stats/storage.test.cc
@@ -272,9 +272,7 @@
 /** Test that an assertion is thrown when bucket size is 0. */
 TEST(StatsDistStorDeathTest, BucketSize0)
 {
-    testing::internal::CaptureStderr();
-    EXPECT_ANY_THROW(Stats::DistStor::Params params(0, 5, 0));
-    testing::internal::GetCapturedStderr();
+    ASSERT_DEATH(Stats::DistStor::Params params(0, 5, 0), "");
 }
 #endif

@@ -500,17 +498,13 @@
/** Test that an assertion is thrown when not enough buckets are provided. */
 TEST(StatsHistStorDeathTest, NotEnoughBuckets0)
 {
-    testing::internal::CaptureStderr();
-    EXPECT_ANY_THROW(Stats::HistStor::Params params(0));
-    testing::internal::GetCapturedStderr();
+    ASSERT_DEATH(Stats::HistStor::Params params(0), "");
 }

/** Test that an assertion is thrown when not enough buckets are provided. */
 TEST(StatsHistStorDeathTest, NotEnoughBuckets1)
 {
-    testing::internal::CaptureStderr();
-    EXPECT_ANY_THROW(Stats::HistStor::Params params(1));
-    testing::internal::GetCapturedStderr();
+    ASSERT_DEATH(Stats::HistStor::Params params(1), "");
 }
 #endif

diff --git a/src/dev/SConscript b/src/dev/SConscript
index 02f9733..dddd6d7 100644
--- a/src/dev/SConscript
+++ b/src/dev/SConscript
@@ -55,4 +55,4 @@
 DebugFlag('Intel8254Timer')
 DebugFlag('MC146818')

-GTest('reg_bank.test', 'reg_bank.test.cc')
+GTest('reg_bank.test', 'reg_bank.test.cc', with_tag('gem5 logging'))
diff --git a/src/sim/SConscript b/src/sim/SConscript
index fe18d24..4dddaa2 100644
--- a/src/sim/SConscript
+++ b/src/sim/SConscript
@@ -86,7 +86,7 @@

 GTest('byteswap.test', 'byteswap.test.cc', '../base/types.cc')
 GTest('guest_abi.test', 'guest_abi.test.cc')
-GTest('proxy_ptr.test', 'proxy_ptr.test.cc')
+GTest('proxy_ptr.test', 'proxy_ptr.test.cc', with_tag('gem5 logging'))

 if env['TARGET_ISA'] != 'null':
     SimObject('InstTracer.py')

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/41397
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ib2dc780e06e7790526b34fb12d15dbb588e6c425
Gerrit-Change-Number: 41397
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to