gem5
[DEVELOP-FOR-23.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. 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... | |
Definition at line 714 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 85 of file symtab.test.cc.
References error, expected, and getSymbolError().
Referenced by 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 104 of file symtab.test.cc.
References gem5::loader::SymbolTable::begin(), gem5::loader::SymbolTable::end(), error, expected, and 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.
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, and ss.
Referenced by checkSymbol(), and checkTable().
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(), gem5::loader::SymbolTable::clear(), gem5::loader::SymbolTable::empty(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
TEST | ( | LoaderSymtabTest | , |
EmptyConstruction | |||
) |
Test that the constructor creates an empty table.
Definition at line 127 of file symtab.test.cc.
References checkTable(), and gem5::loader::SymbolTable::empty().
TEST | ( | LoaderSymtabTest | , |
FindExistingName | |||
) |
Test searching for an existing name.
Definition at line 535 of file symtab.test.cc.
References checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::find(), gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::Local, and name().
TEST | ( | LoaderSymtabTest | , |
FindNearestExact | |||
) |
Test searching for an existent address using findNearest.
Definition at line 554 of file symtab.test.cc.
References checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::findNearest(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
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.
References gem5::loader::Symbol::address, gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::findNearest(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
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 gem5::loader::Symbol::address, checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::findNearest(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
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(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::findNearest(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
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 gem5::loader::Symbol::address, checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::findNearest(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
TEST | ( | LoaderSymtabTest | , |
FindNonExistentAddress | |||
) |
Test searching for a non-existent address.
Definition at line 471 of file symtab.test.cc.
References gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::find(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
TEST | ( | LoaderSymtabTest | , |
FindNonExistentName | |||
) |
Test searching for a non-existent name.
Definition at line 523 of file symtab.test.cc.
References gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::find(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
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, checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::find(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
TEST | ( | LoaderSymtabTest | , |
FindUniqueAddress | |||
) |
Test searching for a unique address.
Definition at line 482 of file symtab.test.cc.
References checkSymbol(), gem5::loader::SymbolTable::end(), gem5::loader::SymbolTable::find(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
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(), gem5::loader::Symbol::Global, gem5::loader::SymbolTable::globals(), gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::Local, and gem5::loader::Symbol::Weak.
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(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
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(), gem5::loader::SymbolTable::empty(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
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, checkTable(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
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(), gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::Local, and name().
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(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
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(), gem5::loader::SymbolTable::insert(), and gem5::loader::Symbol::Local.
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(), gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::Local, 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 412 of file symtab.test.cc.
References checkTable(), gem5::loader::Symbol::Global, gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::Local, gem5::loader::SymbolTable::locals(), and gem5::loader::Symbol::Weak.
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 gem5::loader::Symbol::address, gem5::loader::Symbol::binding, checkTable(), gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::Local, gem5::mask(), gem5::loader::SymbolTable::mask(), and gem5::loader::Symbol::name.
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 gem5::loader::Symbol::address, gem5::loader::Symbol::binding, checkTable(), gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::Local, gem5::loader::Symbol::name, gem5::ArmISA::offset, and gem5::loader::SymbolTable::offset().
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 gem5::loader::Symbol::address, gem5::loader::Symbol::binding, checkTable(), gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::Local, name(), gem5::loader::Symbol::name, and gem5::loader::SymbolTable::rename().
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 gem5::loader::Symbol::address, gem5::loader::Symbol::binding, checkTable(), gem5::ArmISA::i, gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::Local, name(), gem5::loader::Symbol::name, and gem5::loader::SymbolTable::rename().
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(), gem5::loader::Symbol::Global, gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::Local, gem5::loader::Symbol::Weak, and gem5::loader::SymbolTable::weaks().
TEST_F | ( | LoaderSymtabSerializationFixture | , |
Serialization | |||
) |
Test serialization.
Definition at line 717 of file symtab.test.cc.
References gem5::loader::SymbolTable::insert(), gem5::loader::Symbol::Local, gem5::MipsISA::scs, and gem5::loader::SymbolTable::serialize().
TEST_F | ( | LoaderSymtabSerializationFixture | , |
Unserialization | |||
) |
Test unserialization.
Definition at line 743 of file symtab.test.cc.
References checkTable(), gem5::loader::Symbol::Local, gem5::MipsISA::scs, and gem5::loader::SymbolTable::unserialize().
TEST_F | ( | LoaderSymtabSerializationFixture | , |
UnserializationMissingBinding | |||
) |
Test unserialization missing binding.
Definition at line 771 of file symtab.test.cc.
References checkTable(), gem5::loader::Symbol::Global, gem5::loader::Symbol::Local, gem5::MipsISA::scs, and gem5::loader::SymbolTable::unserialize().
TEST_F | ( | LoaderSymtabSerializationFixture | , |
UnserializationMissingBindingChangeDefault | |||
) |
Test unserialization missing binding with a different default value.
Definition at line 800 of file symtab.test.cc.
References checkTable(), gem5::loader::Symbol::Local, gem5::MipsISA::scs, gem5::loader::SymbolTable::unserialize(), and gem5::loader::Symbol::Weak.