gem5 v24.0.0.0
Loading...
Searching...
No Matches
trace.test.cc File Reference
#include <gtest/gtest.h>
#include <sstream>
#include <string>
#include "base/gtest/cur_tick_fake.hh"
#include "base/gtest/logging.hh"
#include "base/named.hh"
#include "base/trace.hh"

Go to the source code of this file.

Namespaces

namespace  gem5
 Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
 
namespace  gem5::debug
 

Functions

std::string getString (std::ostream &os)
 
std::string getString (trace::Logger *logger)
 
 TEST (TraceTest, LogSimpleMessage)
 Test creating a simple log message.
 
 TEST (TraceTest, LogMessageName)
 Test creating a simple log message with a name.
 
 TEST (TraceTest, LogMessageMaxTick)
 Test that when the tick is set to MaxTick it is not printed.
 
 TEST (TraceTest, LogMessageFlagDisabled)
 Test that by default the flag is not printed.
 
 TEST (TraceTest, LogMessageTickDisabledAndEnableDisable)
 Test creating a simple log message without tick information and that enabling and disabling format flags work.
 
 TEST (TraceTest, LogMessageFlagEnabled)
 Test creating a full log message to verify expected order of appearance.
 
 TEST (TraceTest, LogMessageActivateOne)
 Test that log messages are displayed for activated objects (single).
 
 TEST (TraceTest, LogMessageActivateMultiple)
 Test that log messages are displayed for activated objects (multiple).
 
 TEST (TraceTest, LogMessageIgnoreOne)
 Test that log messages are not displayed for ignored objects (single).
 
 TEST (TraceTest, LogMessageIgnoreMultiple)
 Test that log messages are not displayed for ignored objects (multiple).
 
 TEST (TraceTest, LogMessageActivateAndIgnore)
 Test that log messages are displayed properly within ignore and activate.
 
 TEST (TraceTest, DumpIgnored)
 Test that dumping for an ignored name does not log anything.
 
 TEST (TraceTest, DumpSimple)
 Test that a regular dump will change the message so that it contains both the hex and char representation of every byte.
 
 TEST (TraceTest, DumpMultiLine)
 Test that a regular dump will change the message so that it contains both the hex and char representation of every byte, for a multi-line message.
 
 TEST (TraceTest, DISABLED_GetNullLogger)
 Test that when no logger exists a logger is created redirecting to cerr.
 
 TEST (TraceTest, SetGetLogger)
 Test that the logger is set properly.
 
 TEST (TraceTest, Output)
 Test that output() gets the ostream of the current debug logger.
 
 TEST (TraceTest, DprintfFlagIgnore)
 Test dprintf_flag with ignored name.
 
 TEST (TraceTest, DprintfFlagZeroArgs)
 Test dprintf_flag with zero args.
 
 TEST (TraceTest, DprintfFlagOneArg)
 Test dprintf_flag with one arg.
 
 TEST (TraceTest, DprintfFlagMultipleArgs)
 Test dprintf_flag with multiple args.
 
 TEST (TraceTest, DprintfFlagEnabled)
 Test dprintf_flag with flag.
 
 TEST (TraceTest, DprintfIgnore)
 Test dprintf with ignored name.
 
 TEST (TraceTest, DprintfEnabled)
 Test that dprintf does not have a flag.
 
 TEST (TraceTest, DprintfWrapper)
 Test that dprintf is just a flagless wrapper for dprintf_flag.
 
 TEST (TraceTest, MacroDDUMP)
 Test DDUMP with tracing on.
 
 TEST (TraceTest, MacroDPRINTF)
 Test DPRINTF with tracing on.
 
 TEST (TraceTest, MacroDPRINTFS)
 Test DPRINTFS with tracing on.
 
 TEST (TraceTest, MacroDPRINTFR)
 Test DPRINTFR with tracing on.
 
 TEST (TraceTest, MacroDPRINTFN)
 Test DPRINTFN with tracing on.
 
 TEST (TraceTest, MacroDPRINTFNR)
 Test DPRINTFNR with tracing on.
 
 TEST (TraceTest, MacroDPRINTF_UNCONDITIONAL)
 Test DPRINTF_UNCONDITIONAL with tracing on.
 
 TEST (TraceTest, GlobalName)
 Test that there is a global name() to fall through when a locally scoped name() is not defined.
 

Variables

std::stringstream ss
 
trace::OstreamLogger main_logger (ss)
 
GTestTickHandler tickHandler
 
SimpleFlag gem5::debug::TraceTestDebugFlag ("TraceTestDebugFlag", "Exclusive debug flag for the trace tests")
 Debug flag used for the tests in this file.
 

Function Documentation

◆ getString() [1/2]

std::string getString ( std::ostream & os)
Returns
The ostream as a std::string.

Definition at line 63 of file trace.test.cc.

References gem5::X86ISA::os.

Referenced by getString(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ getString() [2/2]

std::string getString ( trace::Logger * logger)
Returns
The logger's ostream as a std::string.

Definition at line 73 of file trace.test.cc.

References gem5::trace::Logger::getOstream(), and getString().

◆ TEST() [1/33]

TEST ( TraceTest ,
DISABLED_GetNullLogger  )

Test that when no logger exists a logger is created redirecting to cerr.

This is the only test that uses cerr. All other test will use main_logger.

Definition at line 382 of file trace.test.cc.

References gem5::trace::getDebugLogger(), gem5::gtestLogOutput, and gem5::trace::Logger::logMessage().

◆ TEST() [2/33]

TEST ( TraceTest ,
DprintfEnabled  )

Test that dprintf does not have a flag.

Definition at line 488 of file trace.test.cc.

References gem5::debug::changeFlag(), gem5::trace::disable(), gem5::trace::Logger::dprintf(), gem5::trace::enable(), getString(), and gem5::ArmISA::ss.

◆ TEST() [3/33]

TEST ( TraceTest ,
DprintfFlagEnabled  )

◆ TEST() [4/33]

TEST ( TraceTest ,
DprintfFlagIgnore  )

Test dprintf_flag with ignored name.

Definition at line 415 of file trace.test.cc.

References gem5::trace::Logger::dprintf_flag(), getString(), gem5::trace::Logger::setIgnore(), and gem5::ArmISA::ss.

◆ TEST() [5/33]

TEST ( TraceTest ,
DprintfFlagMultipleArgs  )

Test dprintf_flag with multiple args.

Definition at line 447 of file trace.test.cc.

References gem5::trace::Logger::dprintf_flag(), getString(), and gem5::ArmISA::ss.

◆ TEST() [6/33]

TEST ( TraceTest ,
DprintfFlagOneArg  )

Test dprintf_flag with one arg.

Definition at line 437 of file trace.test.cc.

References gem5::trace::Logger::dprintf_flag(), getString(), and gem5::ArmISA::ss.

◆ TEST() [7/33]

TEST ( TraceTest ,
DprintfFlagZeroArgs  )

Test dprintf_flag with zero args.

Definition at line 427 of file trace.test.cc.

References gem5::trace::Logger::dprintf_flag(), getString(), and gem5::ArmISA::ss.

◆ TEST() [8/33]

TEST ( TraceTest ,
DprintfIgnore  )

Test dprintf with ignored name.

Definition at line 476 of file trace.test.cc.

References gem5::trace::Logger::dprintf(), getString(), gem5::trace::Logger::setIgnore(), and gem5::ArmISA::ss.

◆ TEST() [9/33]

TEST ( TraceTest ,
DprintfWrapper  )

Test that dprintf is just a flagless wrapper for dprintf_flag.

Definition at line 502 of file trace.test.cc.

References gem5::trace::Logger::dprintf(), gem5::trace::Logger::dprintf_flag(), getString(), and gem5::ArmISA::ss.

◆ TEST() [10/33]

TEST ( TraceTest ,
DumpIgnored  )

Test that dumping for an ignored name does not log anything.

Definition at line 302 of file trace.test.cc.

References gem5::trace::Logger::dump(), getString(), gem5::trace::Logger::setIgnore(), and gem5::ArmISA::ss.

◆ TEST() [11/33]

TEST ( TraceTest ,
DumpMultiLine  )

Test that a regular dump will change the message so that it contains both the hex and char representation of every byte, for a multi-line message.

Definition at line 359 of file trace.test.cc.

References gem5::trace::Logger::dump(), getString(), and gem5::ArmISA::ss.

◆ TEST() [12/33]

TEST ( TraceTest ,
DumpSimple  )

Test that a regular dump will change the message so that it contains both the hex and char representation of every byte.

There is a space between every 8 bytes. For each 16-byte line of a message the order of appearance is <byte number> <2 spaces> <8 spaced bytes> <1 space> <8 spaced bytes> <3-spaces missing to fill 16 bytes> <1 space> <16 bytes as chars> <
>

Definition at line 321 of file trace.test.cc.

References gem5::debug::changeFlag(), gem5::trace::disable(), gem5::trace::Logger::dump(), gem5::trace::enable(), getString(), and gem5::ArmISA::ss.

◆ TEST() [13/33]

TEST ( TraceTest ,
GlobalName  )

Test that there is a global name() to fall through when a locally scoped name() is not defined.

Definition at line 668 of file trace.test.cc.

References gem5::debug::changeFlag(), gem5::trace::disable(), DPRINTF, gem5::trace::enable(), getString(), and gem5::trace::output().

◆ TEST() [14/33]

TEST ( TraceTest ,
LogMessageActivateAndIgnore  )

Test that log messages are displayed properly within ignore and activate.

Definition at line 280 of file trace.test.cc.

References getString(), gem5::trace::OstreamLogger::logMessage(), gem5::trace::Logger::setActivate(), gem5::trace::Logger::setIgnore(), and gem5::ArmISA::ss.

◆ TEST() [15/33]

TEST ( TraceTest ,
LogMessageActivateMultiple  )

Test that log messages are displayed for activated objects (multiple).

Definition at line 194 of file trace.test.cc.

References gem5::trace::Logger::addActivate(), getString(), gem5::trace::OstreamLogger::logMessage(), gem5::trace::Logger::setActivate(), and gem5::ArmISA::ss.

◆ TEST() [16/33]

TEST ( TraceTest ,
LogMessageActivateOne  )

Test that log messages are displayed for activated objects (single).

Definition at line 170 of file trace.test.cc.

References getString(), gem5::trace::OstreamLogger::logMessage(), gem5::trace::Logger::setActivate(), and gem5::ArmISA::ss.

◆ TEST() [17/33]

TEST ( TraceTest ,
LogMessageFlagDisabled  )

Test that by default the flag is not printed.

Definition at line 109 of file trace.test.cc.

References getString(), gem5::trace::OstreamLogger::logMessage(), and gem5::ArmISA::ss.

◆ TEST() [18/33]

TEST ( TraceTest ,
LogMessageFlagEnabled  )

Test creating a full log message to verify expected order of appearance.

This does not include the backtrace.

Definition at line 151 of file trace.test.cc.

References gem5::debug::changeFlag(), gem5::trace::disable(), gem5::trace::enable(), getString(), gem5::trace::OstreamLogger::logMessage(), and gem5::ArmISA::ss.

◆ TEST() [19/33]

TEST ( TraceTest ,
LogMessageIgnoreMultiple  )

Test that log messages are not displayed for ignored objects (multiple).

Definition at line 249 of file trace.test.cc.

References gem5::trace::Logger::addIgnore(), getString(), gem5::trace::OstreamLogger::logMessage(), gem5::trace::Logger::setIgnore(), and gem5::ArmISA::ss.

◆ TEST() [20/33]

TEST ( TraceTest ,
LogMessageIgnoreOne  )

Test that log messages are not displayed for ignored objects (single).

Definition at line 225 of file trace.test.cc.

References getString(), gem5::trace::OstreamLogger::logMessage(), gem5::trace::Logger::setIgnore(), and gem5::ArmISA::ss.

◆ TEST() [21/33]

TEST ( TraceTest ,
LogMessageMaxTick  )

Test that when the tick is set to MaxTick it is not printed.

Definition at line 99 of file trace.test.cc.

References getString(), gem5::trace::OstreamLogger::logMessage(), gem5::MaxTick, and gem5::ArmISA::ss.

◆ TEST() [22/33]

TEST ( TraceTest ,
LogMessageName  )

Test creating a simple log message with a name.

Definition at line 89 of file trace.test.cc.

References getString(), gem5::trace::OstreamLogger::logMessage(), and gem5::ArmISA::ss.

◆ TEST() [23/33]

TEST ( TraceTest ,
LogMessageTickDisabledAndEnableDisable  )

Test creating a simple log message without tick information and that enabling and disabling format flags work.

Definition at line 122 of file trace.test.cc.

References gem5::debug::changeFlag(), gem5::trace::disable(), gem5::trace::enable(), getString(), gem5::trace::OstreamLogger::logMessage(), and gem5::ArmISA::ss.

◆ TEST() [24/33]

TEST ( TraceTest ,
LogSimpleMessage  )

Test creating a simple log message.

Definition at line 79 of file trace.test.cc.

References getString(), gem5::trace::OstreamLogger::logMessage(), and gem5::ArmISA::ss.

◆ TEST() [25/33]

TEST ( TraceTest ,
MacroDDUMP  )

Test DDUMP with tracing on.

Definition at line 516 of file trace.test.cc.

References gem5::debug::changeFlag(), DDUMP, gem5::trace::disable(), gem5::trace::enable(), getString(), name(), and gem5::trace::output().

◆ TEST() [26/33]

TEST ( TraceTest ,
MacroDPRINTF  )

Test DPRINTF with tracing on.

Definition at line 542 of file trace.test.cc.

References gem5::debug::changeFlag(), gem5::trace::disable(), DPRINTF, gem5::trace::enable(), getString(), name(), and gem5::trace::output().

◆ TEST() [27/33]

TEST ( TraceTest ,
MacroDPRINTF_UNCONDITIONAL  )

Test DPRINTF_UNCONDITIONAL with tracing on.

Definition at line 637 of file trace.test.cc.

References gem5::debug::changeFlag(), gem5::trace::disable(), DPRINTF_UNCONDITIONAL, gem5::trace::enable(), getString(), name(), and gem5::trace::output().

◆ TEST() [28/33]

TEST ( TraceTest ,
MacroDPRINTFN  )

Test DPRINTFN with tracing on.

Definition at line 614 of file trace.test.cc.

References DPRINTFN, getString(), name(), and gem5::trace::output().

◆ TEST() [29/33]

TEST ( TraceTest ,
MacroDPRINTFNR  )

Test DPRINTFNR with tracing on.

Definition at line 626 of file trace.test.cc.

References DPRINTFNR, getString(), and gem5::trace::output().

◆ TEST() [30/33]

TEST ( TraceTest ,
MacroDPRINTFR  )

Test DPRINTFR with tracing on.

Definition at line 593 of file trace.test.cc.

References gem5::debug::changeFlag(), gem5::trace::disable(), DPRINTFR, gem5::trace::enable(), getString(), and gem5::trace::output().

◆ TEST() [31/33]

TEST ( TraceTest ,
MacroDPRINTFS  )

Test DPRINTFS with tracing on.

Definition at line 566 of file trace.test.cc.

References gem5::debug::changeFlag(), gem5::trace::disable(), DPRINTFS, gem5::trace::enable(), getString(), and gem5::trace::output().

◆ TEST() [32/33]

TEST ( TraceTest ,
Output  )

Test that output() gets the ostream of the current debug logger.

Definition at line 408 of file trace.test.cc.

References gem5::trace::getDebugLogger(), getString(), gem5::trace::Logger::logMessage(), and gem5::trace::output().

◆ TEST() [33/33]

TEST ( TraceTest ,
SetGetLogger  )

Test that the logger is set properly.

Definition at line 393 of file trace.test.cc.

References gem5::trace::getDebugLogger(), getString(), gem5::trace::OstreamLogger::logMessage(), main_logger, and gem5::trace::setDebugLogger().

Variable Documentation

◆ main_logger

trace::OstreamLogger main_logger(ss) ( ss )

Referenced by TEST().

◆ ss

◆ tickHandler

GTestTickHandler tickHandler

Definition at line 49 of file trace.test.cc.


Generated on Tue Jun 18 2024 16:24:08 for gem5 by doxygen 1.11.0