gem5 v24.0.0.0
|
#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. | |
Definition at line 849 of file symtab.test.cc.
::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.
m_symbol | |
m_expected | |
symbol | The symbol to check for a match. |
expected | The expected symbol value. |
Definition at line 91 of file symtab.test.cc.
References error, expected(), and getSymbolError().
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
::testing::AssertionResult checkTable | ( | const loader::SymbolTable & | symtab, |
const std::initializer_list< loader::Symbol > & | expected ) |
Checks that a symbol table contains only the expected symbols.
symtab | The table to check for matches. |
expected | The expected table's contents. |
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().
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.
symbol | The symbol to check for a match. |
expected | The expected symbol value. |
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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | 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 | ( | LoaderSymtabTest | , |
RenameNonUnique | ) |
Tests that renaming symbols respects the rule that symbols in a table must have unique names.
Definition at line 381 of file symtab.test.cc.
References gem5::loader::Symbol::address(), gem5::loader::Symbol::binding(), checkTable(), gem5::ArmISA::i, gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::name(), name(), gem5::loader::SymbolTable::rename(), and gem5::loader::Symbol::type().
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 | ( | 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 | ( | 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 | ( | LoaderSymtabSerializationFixture | , |
UnserializationMissingBinding | ) |
Test unserialization missing binding.
Definition at line 918 of file symtab.test.cc.
References checkTable(), gem5::MipsISA::scs, and gem5::loader::SymbolTable::unserialize().
TEST_F | ( | LoaderSymtabSerializationFixture | , |
UnserializationMissingBindingChangeDefault | ) |
Test unserialization missing binding with a different default value.
Definition at line 952 of file symtab.test.cc.
References checkTable(), gem5::MipsISA::scs, and gem5::loader::SymbolTable::unserialize().