gem5 v24.0.0.0
Loading...
Searching...
No Matches
symtab.test.cc File Reference
#include <gmock/gmock.h>
#include <gtest/gtest-spi.h>
#include <gtest/gtest.h>
#include <cassert>
#include <initializer_list>
#include <sstream>
#include "base/gtest/serialization_fixture.hh"
#include "base/loader/symtab.hh"

Go to the source code of this file.

Typedefs

using LoaderSymtabSerializationFixture = SerializationFixture
 

Functions

std::string getSymbolError (const loader::Symbol &symbol, const loader::Symbol &expected)
 Checks if a symbol's contents matches the expected contents to generate an error message.
 
::testing::AssertionResult checkSymbol (const char *m_symbol, const char *m_expected, const loader::Symbol &symbol, const loader::Symbol &expected)
 Checks that a symbol's contents matches the expected contents.
 
::testing::AssertionResult checkTable (const loader::SymbolTable &symtab, const std::initializer_list< loader::Symbol > &expected)
 Checks that a symbol table contains only the expected symbols.
 
 TEST (LoaderSymtabTest, EmptyConstruction)
 Test that the constructor creates an empty table.
 
 TEST (LoaderSymtabTest, InsertSymbolNoName)
 Test that the insertion of a symbol with no name fails.
 
 TEST (LoaderSymtabTest, InsertOneSymbol)
 Test that the insertion of one symbol in an empty table works.
 
 TEST (LoaderSymtabTest, InsertSymbolExistingName)
 Test that the insertion of a symbol with an existing name fails.
 
 TEST (LoaderSymtabTest, InsertSymbolExistingAddress)
 Test that the insertion of a symbol with an existing address works.
 
 TEST (LoaderSymtabTest, InsertMultipleSymbols)
 Test that the insertion of one symbol in a non-empty table works.
 
 TEST (LoaderSymtabTest, ClearMultiple)
 Test that a table with multiple entries becomes empty after being cleared.
 
 TEST (LoaderSymtabTest, Offset)
 Test the creation of a new table with offsets applied to the original symbols' addresses.
 
 TEST (LoaderSymtabTest, Mask)
 Test the creation of a new table with masks applied to the original symbols' addresses.
 
 TEST (LoaderSymtabTest, Rename)
 Test the creation of a new table with renamed symbols.
 
 TEST (LoaderSymtabTest, RenameNonUnique)
 Tests that renaming symbols respects the rule that symbols in a table must have unique names.
 
 TEST (LoaderSymtabTest, Globals)
 Test the creation of a new filtered table containing only the global symbols of the original table.
 
 TEST (LoaderSymtabTest, Locals)
 Test the creation of a new filtered table containing only the local symbols of the original table.
 
 TEST (LoaderSymtabTest, Weaks)
 Test the creation of a new filtered table containing only the weak symbols of the original table.
 
 TEST (LoaderSymtabTest, FunctionSymbols)
 Test the creation of a new filtered table containing only function symbols of the original table.
 
 TEST (LoaderSymtabTest, FindNonExistentAddress)
 Test searching for a non-existent address.
 
 TEST (LoaderSymtabTest, FindUniqueAddress)
 Test searching for a unique address.
 
 TEST (LoaderSymtabTest, FindNonUniqueAddress)
 Test that searching for a non-unique address returns the first occurrence.
 
 TEST (LoaderSymtabTest, FindNonExistentName)
 Test searching for a non-existent name.
 
 TEST (LoaderSymtabTest, FindExistingName)
 Test searching for an existing name.
 
 TEST (LoaderSymtabTest, FindNearestExact)
 Test searching for an existent address using findNearest.
 
 TEST (LoaderSymtabTest, FindNearestRound)
 Test that, in a table containing address A, searching for the nearest address of an address B where B=A+x returns A.
 
 TEST (LoaderSymtabTest, FindNearestRoundWithNext)
 Test that, in a table containing address A1 and A2, where A1.
 
 TEST (LoaderSymtabTest, FindNearestRoundWithNextNonExistent)
 Test that, in a table containing address A, searching for the nearest address of an address B where B=A+x returns A; however, the next address is non-existent, so it is marked as not valid.
 
 TEST (LoaderSymtabTest, FindNearestNonExistent)
 Test that searching for the nearest address of an address lower than the lowest address fails.
 
 TEST (LoaderSymtabTest, InsertTableConflicting)
 Test that the insertion of a symbol table's symbols in another table works when any symbol name conflicts.
 
 TEST (LoaderSymtabTest, InsertTable)
 Test that the insertion of a symbol table's symbols in another table works when no symbols conflict.
 
 TEST_F (LoaderSymtabSerializationFixture, Serialization)
 Test serialization.
 
 TEST_F (LoaderSymtabSerializationFixture, Unserialization)
 Test unserialization.
 
 TEST_F (LoaderSymtabSerializationFixture, UnserializationMissingBinding)
 Test unserialization missing binding.
 
 TEST_F (LoaderSymtabSerializationFixture, UnserializationMissingBindingChangeDefault)
 Test unserialization missing binding with a different default value.
 

Typedef Documentation

◆ LoaderSymtabSerializationFixture

Function Documentation

◆ checkSymbol()

::testing::AssertionResult checkSymbol ( const char * m_symbol,
const char * m_expected,
const loader::Symbol & symbol,
const loader::Symbol & expected )

Checks that a symbol's contents matches the expected contents.

Parameters
m_symbol
m_expected
symbolThe symbol to check for a match.
expectedThe expected symbol value.
Returns
A GTest's assertion result, with error message on failure.

Definition at line 91 of file symtab.test.cc.

References error, expected(), and getSymbolError().

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

◆ checkTable()

::testing::AssertionResult checkTable ( const loader::SymbolTable & symtab,
const std::initializer_list< loader::Symbol > & expected )

Checks that a symbol table contains only the expected symbols.

Parameters
symtabThe table to check for matches.
expectedThe expected table's contents.
Returns
A GTest's assertion result, with error message on failure.

Definition at line 110 of file symtab.test.cc.

References gem5::loader::SymbolTable::begin(), gem5::loader::SymbolTable::end(), error, expected(), and getSymbolError().

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

◆ getSymbolError()

std::string getSymbolError ( const loader::Symbol & symbol,
const loader::Symbol & expected )

Checks if a symbol's contents matches the expected contents to generate an error message.

On matches an empty string is returned.

Parameters
symbolThe symbol to check for a match.
expectedThe expected symbol value.
Returns
The error string, if any.

Definition at line 51 of file symtab.test.cc.

References gem5::loader::Symbol::address(), gem5::loader::Symbol::binding(), expected(), gem5::loader::Symbol::name(), gem5::ArmISA::ss, and gem5::loader::Symbol::type().

Referenced by checkSymbol(), and checkTable().

◆ TEST() [1/27]

TEST ( LoaderSymtabTest ,
ClearMultiple  )

Test that a table with multiple entries becomes empty after being cleared.

Definition at line 227 of file symtab.test.cc.

References checkTable(), gem5::loader::SymbolTable::clear(), gem5::loader::SymbolTable::empty(), and gem5::loader::SymbolTable::insert().

◆ TEST() [2/27]

TEST ( LoaderSymtabTest ,
EmptyConstruction  )

Test that the constructor creates an empty table.

Definition at line 133 of file symtab.test.cc.

References checkTable(), and gem5::loader::SymbolTable::empty().

◆ TEST() [3/27]

TEST ( LoaderSymtabTest ,
FindExistingName  )

Test searching for an existing name.

Definition at line 647 of file symtab.test.cc.

References checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::find(), gem5::loader::SymbolTable::insert(), and name().

◆ TEST() [4/27]

TEST ( LoaderSymtabTest ,
FindNearestExact  )

Test searching for an existent address using findNearest.

Definition at line 669 of file symtab.test.cc.

References checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::findNearest(), and gem5::loader::SymbolTable::insert().

◆ TEST() [5/27]

TEST ( LoaderSymtabTest ,
FindNearestNonExistent  )

Test that searching for the nearest address of an address lower than the lowest address fails.

Definition at line 755 of file symtab.test.cc.

References gem5::loader::Symbol::address(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::findNearest(), and gem5::loader::SymbolTable::insert().

◆ TEST() [6/27]

TEST ( LoaderSymtabTest ,
FindNearestRound  )

Test that, in a table containing address A, searching for the nearest address of an address B where B=A+x returns A.

Definition at line 691 of file symtab.test.cc.

References gem5::loader::Symbol::address(), checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::findNearest(), and gem5::loader::SymbolTable::insert().

◆ TEST() [7/27]

TEST ( LoaderSymtabTest ,
FindNearestRoundWithNext  )

Test that, in a table containing address A1 and A2, where A1.

Definition at line 710 of file symtab.test.cc.

References checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::findNearest(), and gem5::loader::SymbolTable::insert().

◆ TEST() [8/27]

TEST ( LoaderSymtabTest ,
FindNearestRoundWithNextNonExistent  )

Test that, in a table containing address A, searching for the nearest address of an address B where B=A+x returns A; however, the next address is non-existent, so it is marked as not valid.

Definition at line 735 of file symtab.test.cc.

References gem5::loader::Symbol::address(), checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::findNearest(), and gem5::loader::SymbolTable::insert().

◆ TEST() [9/27]

TEST ( LoaderSymtabTest ,
FindNonExistentAddress  )

Test searching for a non-existent address.

Definition at line 573 of file symtab.test.cc.

References gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::find(), and gem5::loader::SymbolTable::insert().

◆ TEST() [10/27]

TEST ( LoaderSymtabTest ,
FindNonExistentName  )

Test searching for a non-existent name.

Definition at line 633 of file symtab.test.cc.

References gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::find(), and gem5::loader::SymbolTable::insert().

◆ TEST() [11/27]

TEST ( LoaderSymtabTest ,
FindNonUniqueAddress  )

Test that searching for a non-unique address returns the first occurrence.

Definition at line 610 of file symtab.test.cc.

References gem5::X86ISA::addr, checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::find(), and gem5::loader::SymbolTable::insert().

◆ TEST() [12/27]

TEST ( LoaderSymtabTest ,
FindUniqueAddress  )

Test searching for a unique address.

Definition at line 586 of file symtab.test.cc.

References checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::find(), and gem5::loader::SymbolTable::insert().

◆ TEST() [13/27]

TEST ( LoaderSymtabTest ,
FunctionSymbols  )

Test the creation of a new filtered table containing only function symbols of the original table.

Also verifies if the original table is kept the same.

Definition at line 540 of file symtab.test.cc.

References checkTable(), gem5::loader::SymbolTable::functionSymbols(), and gem5::loader::SymbolTable::insert().

◆ TEST() [14/27]

TEST ( LoaderSymtabTest ,
Globals  )

Test the creation of a new filtered table containing only the global symbols of the original table.

Also verifies if the original table is kept the same.

Definition at line 432 of file symtab.test.cc.

References checkTable(), gem5::loader::SymbolTable::globals(), and gem5::loader::SymbolTable::insert().

◆ TEST() [15/27]

TEST ( LoaderSymtabTest ,
InsertMultipleSymbols  )

Test that the insertion of one symbol in a non-empty table works.

Definition at line 205 of file symtab.test.cc.

References checkTable(), and gem5::loader::SymbolTable::insert().

◆ TEST() [16/27]

TEST ( LoaderSymtabTest ,
InsertOneSymbol  )

Test that the insertion of one symbol in an empty table works.

Definition at line 153 of file symtab.test.cc.

References checkTable(), gem5::loader::SymbolTable::empty(), and gem5::loader::SymbolTable::insert().

◆ TEST() [17/27]

TEST ( LoaderSymtabTest ,
InsertSymbolExistingAddress  )

Test that the insertion of a symbol with an existing address works.

Definition at line 186 of file symtab.test.cc.

References gem5::X86ISA::addr, checkTable(), and gem5::loader::SymbolTable::insert().

◆ TEST() [18/27]

TEST ( LoaderSymtabTest ,
InsertSymbolExistingName  )

Test that the insertion of a symbol with an existing name fails.

Definition at line 167 of file symtab.test.cc.

References checkTable(), gem5::loader::SymbolTable::insert(), and name().

◆ TEST() [19/27]

TEST ( LoaderSymtabTest ,
InsertSymbolNoName  )

Test that the insertion of a symbol with no name fails.

Definition at line 141 of file symtab.test.cc.

References checkTable(), and gem5::loader::SymbolTable::insert().

◆ TEST() [20/27]

TEST ( LoaderSymtabTest ,
InsertTable  )

Test that the insertion of a symbol table's symbols in another table works when no symbols conflict.

Definition at line 812 of file symtab.test.cc.

References checkTable(), and gem5::loader::SymbolTable::insert().

◆ TEST() [21/27]

TEST ( LoaderSymtabTest ,
InsertTableConflicting  )

Test that the insertion of a symbol table's symbols in another table works when any symbol name conflicts.

Definition at line 772 of file symtab.test.cc.

References checkTable(), gem5::loader::SymbolTable::insert(), and name().

◆ TEST() [22/27]

TEST ( LoaderSymtabTest ,
Locals  )

Test the creation of a new filtered table containing only the local symbols of the original table.

Also verifies if the original table is kept the same.

Definition at line 468 of file symtab.test.cc.

References checkTable(), gem5::loader::SymbolTable::insert(), and gem5::loader::SymbolTable::locals().

◆ TEST() [23/27]

TEST ( LoaderSymtabTest ,
Mask  )

Test the creation of a new table with masks applied to the original symbols' addresses.

Also verifies that the original table is kept the same.

Definition at line 291 of file symtab.test.cc.

References gem5::loader::Symbol::address(), gem5::loader::Symbol::binding(), checkTable(), gem5::loader::SymbolTable::insert(), gem5::ArmISA::mask, gem5::loader::SymbolTable::mask(), gem5::loader::Symbol::name(), and gem5::loader::Symbol::type().

◆ TEST() [24/27]

TEST ( LoaderSymtabTest ,
Offset  )

Test the creation of a new table with offsets applied to the original symbols' addresses.

Also verifies that the original table is kept the same.

Definition at line 252 of file symtab.test.cc.

References gem5::loader::Symbol::address(), gem5::loader::Symbol::binding(), checkTable(), gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::name(), gem5::ArmISA::offset, gem5::loader::SymbolTable::offset(), and gem5::loader::Symbol::type().

◆ TEST() [25/27]

TEST ( LoaderSymtabTest ,
Rename  )

Test the creation of a new table with renamed symbols.

Also verifies that the original table is kept the same.

Definition at line 336 of file symtab.test.cc.

References gem5::loader::Symbol::address(), gem5::loader::Symbol::binding(), checkTable(), gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::name(), name(), gem5::loader::SymbolTable::rename(), and gem5::loader::Symbol::type().

◆ TEST() [26/27]

TEST ( LoaderSymtabTest ,
RenameNonUnique  )

◆ TEST() [27/27]

TEST ( LoaderSymtabTest ,
Weaks  )

Test the creation of a new filtered table containing only the weak symbols of the original table.

Also verifies if the original table is kept the same.

Definition at line 504 of file symtab.test.cc.

References checkTable(), gem5::loader::SymbolTable::insert(), and gem5::loader::SymbolTable::weaks().

◆ TEST_F() [1/4]

TEST_F ( LoaderSymtabSerializationFixture ,
Serialization  )

Test serialization.

Definition at line 852 of file symtab.test.cc.

References gem5::loader::SymbolTable::insert(), gem5::MipsISA::scs, and gem5::loader::SymbolTable::serialize().

◆ TEST_F() [2/4]

TEST_F ( LoaderSymtabSerializationFixture ,
Unserialization  )

Test unserialization.

Definition at line 884 of file symtab.test.cc.

References checkTable(), gem5::MipsISA::scs, and gem5::loader::SymbolTable::unserialize().

◆ TEST_F() [3/4]

TEST_F ( LoaderSymtabSerializationFixture ,
UnserializationMissingBinding  )

Test unserialization missing binding.

Todo
Since there is no way to create a checkpoint without binding anymore, this functionality should be deprecated at some point.

Definition at line 918 of file symtab.test.cc.

References checkTable(), gem5::MipsISA::scs, and gem5::loader::SymbolTable::unserialize().

◆ TEST_F() [4/4]

TEST_F ( LoaderSymtabSerializationFixture ,
UnserializationMissingBindingChangeDefault  )

Test unserialization missing binding with a different default value.

Todo
Since there is no way to create a checkpoint without binding anymore, this functionality should be deprecated at some point.

Definition at line 952 of file symtab.test.cc.

References checkTable(), gem5::MipsISA::scs, and gem5::loader::SymbolTable::unserialize().


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