gem5  v22.0.0.1
Typedefs | Functions
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. More...
 
::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. More...
 
::testing::AssertionResult checkTable (const Loader::SymbolTable &symtab, const std::initializer_list< Loader::Symbol > &expected)
 Checks that a symbol table contains only the expected symbols. More...
 
 TEST (LoaderSymtabTest, EmptyConstruction)
 Test that the constructor creates an empty table. More...
 
 TEST (LoaderSymtabTest, InsertSymbolNoName)
 Test that the insertion of a symbol with no name fails. More...
 
 TEST (LoaderSymtabTest, InsertOneSymbol)
 Test that the insertion of one symbol in an empty table works. More...
 
 TEST (LoaderSymtabTest, InsertSymbolExistingName)
 Test that the insertion of a symbol with an existing name fails. More...
 
 TEST (LoaderSymtabTest, InsertSymbolExistingAddress)
 Test that the insertion of a symbol with an existing address works. More...
 
 TEST (LoaderSymtabTest, InsertMultipleSymbols)
 Test that the insertion of one symbol in a non-empty table works. More...
 
 TEST (LoaderSymtabTest, ClearMultiple)
 Test that a table with multiple entries becomes empty after being cleared. More...
 
 TEST (LoaderSymtabTest, Offset)
 Test the creation of a new table with offsets applied to the original symbols' addresses. More...
 
 TEST (LoaderSymtabTest, Mask)
 Test the creation of a new table with masks applied to the original symbols' addresses. More...
 
 TEST (LoaderSymtabTest, Rename)
 Test the creation of a new table with renamed symbols. More...
 
 TEST (LoaderSymtabTest, RenameNonUnique)
 Tests that renaming symbols respects the rule that symbols in a table must have unique names. More...
 
 TEST (LoaderSymtabTest, Globals)
 Test the creation of a new filtered table containing only the global symbols of the original table. More...
 
 TEST (LoaderSymtabTest, Locals)
 Test the creation of a new filtered table containing only the local symbols of the original table. More...
 
 TEST (LoaderSymtabTest, Weaks)
 Test the creation of a new filtered table containing only the weak symbols of the original table. More...
 
 TEST (LoaderSymtabTest, FindNonExistentAddress)
 Test searching for a non-existent address. More...
 
 TEST (LoaderSymtabTest, FindUniqueAddress)
 Test searching for a unique address. More...
 
 TEST (LoaderSymtabTest, FindNonUniqueAddress)
 Test that searching for a non-unique address returns the first occurrence. More...
 
 TEST (LoaderSymtabTest, FindNonExistentName)
 Test searching for a non-existent name. More...
 
 TEST (LoaderSymtabTest, FindExistingName)
 Test searching for an existing name. More...
 
 TEST (LoaderSymtabTest, FindNearestExact)
 Test searching for an existent address using findNearest. More...
 
 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. More...
 
 TEST (LoaderSymtabTest, FindNearestRoundWithNext)
 Test that, in a table containing address A1 and A2, where A1<A2, searching for the nearest address of an address B where B=A1+x and B<A2 returns A1, and marks A2 as the next address. More...
 
 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. More...
 
 TEST (LoaderSymtabTest, FindNearestNonExistent)
 Test that searching for the nearest address of an address lower than the lowest address fails. More...
 
 TEST (LoaderSymtabTest, InsertTableConflicting)
 Test that the insertion of a symbol table's symbols in another table works when any symbol name conflicts. More...
 
 TEST (LoaderSymtabTest, InsertTable)
 Test that the insertion of a symbol table's symbols in another table works when no symbols conflict. More...
 
 TEST_F (LoaderSymtabSerializationFixture, Serialization)
 Test serialization. More...
 
 TEST_F (LoaderSymtabSerializationFixture, Unserialization)
 Test unserialization. More...
 
 TEST_F (LoaderSymtabSerializationFixture, UnserializationMissingBinding)
 Test unserialization missing binding. More...
 
 TEST_F (LoaderSymtabSerializationFixture, UnserializationMissingBindingChangeDefault)
 Test unserialization missing binding with a different default value. More...
 

Typedef Documentation

◆ LoaderSymtabSerializationFixture

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

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 85 of file symtab.test.cc.

References error, expected, and getSymbolError().

Referenced by 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 104 of file symtab.test.cc.

References error, expected, and getSymbolError().

Referenced by TEST(), 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 expected, and ss.

Referenced by checkSymbol(), and checkTable().

◆ TEST() [1/26]

TEST ( LoaderSymtabTest  ,
ClearMultiple   
)

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

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

References checkTable().

◆ TEST() [2/26]

TEST ( LoaderSymtabTest  ,
EmptyConstruction   
)

Test that the constructor creates an empty table.

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

References checkTable().

◆ TEST() [3/26]

TEST ( LoaderSymtabTest  ,
FindExistingName   
)

Test searching for an existing name.

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

References checkSymbol(), and name().

◆ TEST() [4/26]

TEST ( LoaderSymtabTest  ,
FindNearestExact   
)

Test searching for an existent address using findNearest.

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

References checkSymbol().

◆ TEST() [5/26]

TEST ( LoaderSymtabTest  ,
FindNearestNonExistent   
)

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

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

◆ TEST() [6/26]

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 574 of file symtab.test.cc.

References checkSymbol().

◆ TEST() [7/26]

TEST ( LoaderSymtabTest  ,
FindNearestRoundWithNext   
)

Test that, in a table containing address A1 and A2, where A1<A2, searching for the nearest address of an address B where B=A1+x and B<A2 returns A1, and marks A2 as the next address.

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

References checkSymbol().

◆ TEST() [8/26]

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 614 of file symtab.test.cc.

References checkSymbol().

◆ TEST() [9/26]

TEST ( LoaderSymtabTest  ,
FindNonExistentAddress   
)

Test searching for a non-existent address.

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

◆ TEST() [10/26]

TEST ( LoaderSymtabTest  ,
FindNonExistentName   
)

Test searching for a non-existent name.

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

◆ TEST() [11/26]

TEST ( LoaderSymtabTest  ,
FindNonUniqueAddress   
)

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

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

References gem5::X86ISA::addr, and checkSymbol().

◆ TEST() [12/26]

TEST ( LoaderSymtabTest  ,
FindUniqueAddress   
)

Test searching for a unique address.

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

References checkSymbol().

◆ TEST() [13/26]

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 381 of file symtab.test.cc.

References checkTable().

◆ TEST() [14/26]

TEST ( LoaderSymtabTest  ,
InsertMultipleSymbols   
)

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

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

References checkTable().

◆ TEST() [15/26]

TEST ( LoaderSymtabTest  ,
InsertOneSymbol   
)

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

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

References checkTable().

◆ TEST() [16/26]

TEST ( LoaderSymtabTest  ,
InsertSymbolExistingAddress   
)

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

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

References gem5::X86ISA::addr, and checkTable().

◆ TEST() [17/26]

TEST ( LoaderSymtabTest  ,
InsertSymbolExistingName   
)

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

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

References checkTable(), and name().

◆ TEST() [18/26]

TEST ( LoaderSymtabTest  ,
InsertSymbolNoName   
)

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

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

References checkTable().

◆ TEST() [19/26]

TEST ( LoaderSymtabTest  ,
InsertTable   
)

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

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

References checkTable().

◆ TEST() [20/26]

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 647 of file symtab.test.cc.

References checkTable(), and name().

◆ TEST() [21/26]

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 412 of file symtab.test.cc.

References checkTable().

◆ TEST() [22/26]

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 265 of file symtab.test.cc.

References checkTable(), and gem5::mask().

◆ TEST() [23/26]

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 232 of file symtab.test.cc.

References checkTable(), and gem5::ArmISA::offset.

◆ TEST() [24/26]

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 302 of file symtab.test.cc.

References checkTable(), and name().

◆ TEST() [25/26]

TEST ( LoaderSymtabTest  ,
RenameNonUnique   
)

Tests that renaming symbols respects the rule that symbols in a table must have unique names.

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

References checkTable(), gem5::ArmISA::i, and name().

◆ TEST() [26/26]

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 443 of file symtab.test.cc.

References checkTable().

◆ TEST_F() [1/4]

TEST_F ( LoaderSymtabSerializationFixture  ,
Serialization   
)

Test serialization.

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

References gem5::MipsISA::scs.

◆ TEST_F() [2/4]

TEST_F ( LoaderSymtabSerializationFixture  ,
Unserialization   
)

Test unserialization.

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

References checkTable(), and gem5::MipsISA::scs.

◆ 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 771 of file symtab.test.cc.

References checkTable(), and gem5::MipsISA::scs.

◆ 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 800 of file symtab.test.cc.

References checkTable(), and gem5::MipsISA::scs.


Generated on Sat Jun 18 2022 08:12:46 for gem5 by doxygen 1.8.17