gem5 v24.0.0.0
|
#include <gmock/gmock.h>
#include <gtest/gtest-spi.h>
#include <gtest/gtest.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <array>
#include <cassert>
#include <cstdint>
#include <deque>
#include <fstream>
#include <list>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/compiler.hh"
#include "base/gtest/cur_tick_fake.hh"
#include "base/gtest/logging.hh"
#include "base/gtest/serialization_fixture.hh"
#include "sim/serialize.hh"
Go to the source code of this file.
Classes | |
class | CheckpointInFixture |
class | SerializableFixture |
A fixture to handle checkpoint in and out variables, as well as the testing of the temporary directory. More... | |
class | SerializableType |
Typedefs | |
using | SerializeFixture = SerializationFixture |
using | SerializeFixtureDeathTest = SerializeFixture |
using | CheckpointInFixtureDeathTest = CheckpointInFixture |
using | SerializableFixtureDeathTest = SerializableFixture |
Functions | |
bool | dirExists (std::string dir) |
TEST (CheckpointInTest, SetGetDirSlash) | |
Tests that when setting a checkpoint dir it always ends with a slash. | |
TEST (CheckpointInTest, SetGetDirTick) | |
Tests that when the dir name has a "%d" curTick is added. | |
TEST_F (SerializeFixtureDeathTest, ConstructorFailure) | |
Test constructor failure by requesting the creation of a checkpoint in a non-existent dir. | |
TEST_F (SerializeFixture, ConstructorSuccess) | |
Test constructor success by requesting the creation of a checkpoint in a specific valid dir. | |
TEST_F (CheckpointInFixtureDeathTest, GetCptDir) | |
Test that changing the static cpt dir does not change the name of the cpt dir of previously created instances. | |
TEST_F (CheckpointInFixture, FindSections) | |
Test finding sections. | |
TEST_F (CheckpointInFixture, FindEntries) | |
Test finding entries. | |
TEST_F (CheckpointInFixture, ExtractEntries) | |
Test extracting the values of entries. | |
TEST_F (CheckpointInFixture, SCSCptInPathScoped) | |
Test that paths are increased and decreased according to the scope that its SCS was created in (using CheckpointIn). | |
TEST_F (SerializeFixture, SCSCptOutPathScoped) | |
Test that paths are increased and decreased according to the scope that its SCS was created in (using CheckpointOut). | |
TEST_F (SerializeFixture, SCSNoChangeCptIn) | |
Make sure that a SCS that uses a CheckpointIn does not change the checkpoint file's contents. | |
std::string | getString (std::istream &is) |
std::string | getContents (std::ofstream &cpt, std::string filename) |
Flushes the checkpoint and reads its contents. | |
TEST_F (SerializableFixture, SCSChangeCptOutSingle) | |
Make sure that a SCS that uses a CheckpointOut changes the checkpoint file's contents (single section). | |
TEST_F (SerializableFixture, SCSChangeCptOutMultiple) | |
Make sure that a SCS that uses a CheckpointOut changes the checkpoint file's contents (multiple sections). | |
TEST_F (SerializableFixture, SCSChangeCptOutLarge) | |
Make sure that a SCS that uses a CheckpointOut changes the checkpoint file's contents (large test). | |
TEST (SerializableDeathTest, GenerateCptOutFail) | |
Test failure to create dir. | |
TEST_F (SerializeFixture, GenerateCptOut) | |
Test successful CheckpointOut generation with non-existent dir. | |
TEST_F (SerializeFixture, GenerateCptOutExistent) | |
Test successful CheckpointOut generation with existing dir. | |
TEST_F (SerializableFixture, SectionSerializationSimple) | |
Test section serialization and unserialization for an object without serializable contents. | |
TEST_F (SerializableFixtureDeathTest, ParamIn) | |
Test that paramIn called on a param that does not exist triggers an error. | |
TEST_F (SerializableFixture, ParamOutIn) | |
Test serialization followed by unserialization, using ParamInImpl and ParamOut. | |
TEST_F (SerializableFixture, ParamOutInMultipleSections) | |
Test serialization followed by unserialization, using ParamInImpl and ParamOut, when multiple sections exist. | |
TEST_F (SerializeFixture, OptParamOutIn) | |
Test optional parameters. | |
TEST_F (SerializableFixtureDeathTest, NoSectionParamIn) | |
Check for death when there is no section and paramIn is requested. | |
TEST_F (SerializeFixture, ArrayParamOutIn) | |
Test arrayParamOut and arrayParamIn. | |
TEST_F (SerializeFixture, DISABLED_ArrayParamOutInSpacedStrings) | |
Test arrayParamOut and arrayParamIn for strings with spaces. | |
TEST_F (SerializeFixtureDeathTest, ArrayParamOutInSmaller) | |
Test that using arrayParamIn with sizes smaller than the container's throws an exception. | |
TEST_F (SerializeFixture, MappingParamOutIn) | |
Test mappingParamOut and mappingParamIn with all keys. | |
TEST_F (SerializeFixture, MappingParamOutInMissing) | |
Test that missing keys are ignored on mappingParamIn. | |
TEST_F (SerializeFixture, SerializeScalar) | |
Test serialization followed by unserialization, using SERIALIZE_SCALAR and UNSERIALIZE_SCALAR. | |
TEST_F (SerializeFixture, UnserializeOptScalar) | |
Test optional parameters with UNSERIALIZE_OPT_SCALAR. | |
TEST_F (SerializeFixture, SerializeEnum) | |
Test serialization followed by unserialization, using SERIALIZE_ENUM and UNSERIALIZE_ENUM. | |
TEST_F (SerializeFixture, SerializeArray) | |
Test SERIALIZE_ARRAY and UNSERIALIZE_ARRAY. | |
TEST_F (SerializeFixture, SerializeContainer) | |
Test SERIALIZE_CONTAINER and UNSERIALIZE_CONTAINER. | |
TEST_F (SerializeFixture, SerializeMapping) | |
Test SERIALIZE_MAPPING and UNSERIALIZE_MAPPING with all keys. | |
Variables | |
GTestTickHandler | tickHandler |
Definition at line 143 of file serialize.test.cc.
Definition at line 144 of file serialize.test.cc.
using SerializeFixture = SerializationFixture |
Definition at line 65 of file serialize.test.cc.
Definition at line 142 of file serialize.test.cc.
bool dirExists | ( | std::string | dir | ) |
Definition at line 59 of file serialize.test.cc.
std::string getContents | ( | std::ofstream & | cpt, |
std::string | filename ) |
Flushes the checkpoint and reads its contents.
cpt | The checkpoint to be flushed. |
filename | The name of the file to be read. |
Definition at line 354 of file serialize.test.cc.
References gem5::MipsISA::is.
Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
std::string getString | ( | std::istream & | is | ) |
Definition at line 338 of file serialize.test.cc.
References gem5::MipsISA::is.
TEST | ( | CheckpointInTest | , |
SetGetDirSlash | ) |
Tests that when setting a checkpoint dir it always ends with a slash.
Definition at line 147 of file serialize.test.cc.
References gem5::CheckpointIn::dir(), and gem5::CheckpointIn::setDir().
TEST | ( | CheckpointInTest | , |
SetGetDirTick | ) |
Tests that when the dir name has a "%d" curTick is added.
It may also work with other formats, but it is not intended.
Definition at line 163 of file serialize.test.cc.
References gem5::CheckpointIn::dir(), and gem5::CheckpointIn::setDir().
TEST | ( | SerializableDeathTest | , |
GenerateCptOutFail | ) |
Test failure to create dir.
Try to create a dir in a non-existent dir.
Definition at line 451 of file serialize.test.cc.
References dirExists(), gem5::Serializable::generateCheckpointOut(), and gem5::SerializationFixture::generateTempDirName().
TEST_F | ( | CheckpointInFixture | , |
ExtractEntries | ) |
Test extracting the values of entries.
Definition at line 245 of file serialize.test.cc.
TEST_F | ( | CheckpointInFixture | , |
FindEntries | ) |
Test finding entries.
Definition at line 230 of file serialize.test.cc.
TEST_F | ( | CheckpointInFixture | , |
FindSections | ) |
Test finding sections.
Definition at line 217 of file serialize.test.cc.
TEST_F | ( | CheckpointInFixture | , |
SCSCptInPathScoped | ) |
Test that paths are increased and decreased according to the scope that its SCS was created in (using CheckpointIn).
Definition at line 270 of file serialize.test.cc.
References gem5::Serializable::currentSection(), and gem5::MipsISA::scs.
TEST_F | ( | CheckpointInFixtureDeathTest | , |
GetCptDir | ) |
Test that changing the static cpt dir does not change the name of the cpt dir of previously created instances.
Definition at line 211 of file serialize.test.cc.
TEST_F | ( | SerializableFixture | , |
ParamOutIn | ) |
Test serialization followed by unserialization, using ParamInImpl and ParamOut.
Definition at line 596 of file serialize.test.cc.
References expected(), getContents(), gem5::paramIn(), gem5::paramOut(), and gem5::MipsISA::scs.
TEST_F | ( | SerializableFixture | , |
ParamOutInMultipleSections | ) |
Test serialization followed by unserialization, using ParamInImpl and ParamOut, when multiple sections exist.
Definition at line 663 of file serialize.test.cc.
References expected(), getContents(), gem5::paramIn(), gem5::paramOut(), and gem5::MipsISA::scs.
TEST_F | ( | SerializableFixture | , |
SCSChangeCptOutLarge | ) |
Make sure that a SCS that uses a CheckpointOut changes the checkpoint file's contents (large test).
Definition at line 407 of file serialize.test.cc.
References expected(), getContents(), and gem5::MipsISA::scs.
TEST_F | ( | SerializableFixture | , |
SCSChangeCptOutMultiple | ) |
Make sure that a SCS that uses a CheckpointOut changes the checkpoint file's contents (multiple sections).
Definition at line 381 of file serialize.test.cc.
References expected(), getContents(), and gem5::MipsISA::scs.
TEST_F | ( | SerializableFixture | , |
SCSChangeCptOutSingle | ) |
Make sure that a SCS that uses a CheckpointOut changes the checkpoint file's contents (single section).
Definition at line 370 of file serialize.test.cc.
References getContents(), and gem5::MipsISA::scs.
TEST_F | ( | SerializableFixture | , |
SectionSerializationSimple | ) |
Test section serialization and unserialization for an object without serializable contents.
Since how (un)serialize() works is independent of the Serializable class, we just make sure that the respective functions are called when calling (un)serializeSection().
Definition at line 535 of file serialize.test.cc.
References SerializableType::checkAndResetSerialized(), SerializableType::checkAndResetUnserialized(), getContents(), gem5::Serializable::serializeSection(), and gem5::Serializable::unserializeSection().
TEST_F | ( | SerializableFixtureDeathTest | , |
NoSectionParamIn | ) |
Check for death when there is no section and paramIn is requested.
Definition at line 812 of file serialize.test.cc.
References gem5::X86ISA::of, and gem5::paramIn().
TEST_F | ( | SerializableFixtureDeathTest | , |
ParamIn | ) |
Test that paramIn called on a param that does not exist triggers an error.
Definition at line 585 of file serialize.test.cc.
References gem5::paramIn(), and gem5::MipsISA::scs.
TEST_F | ( | SerializeFixture | , |
ArrayParamOutIn | ) |
Test arrayParamOut and arrayParamIn.
Definition at line 826 of file serialize.test.cc.
References gem5::arrayParamIn(), gem5::arrayParamOut(), gem5::ArmISA::e, expected(), getContents(), and gem5::MipsISA::scs.
TEST_F | ( | SerializeFixture | , |
ConstructorSuccess | ) |
Test constructor success by requesting the creation of a checkpoint in a specific valid dir.
The static cpt dir is change on instantiation.
Definition at line 191 of file serialize.test.cc.
References gem5::CheckpointIn::dir(), and gem5::CheckpointIn::setDir().
TEST_F | ( | SerializeFixture | , |
DISABLED_ArrayParamOutInSpacedStrings | ) |
Test arrayParamOut and arrayParamIn for strings with spaces.
Definition at line 905 of file serialize.test.cc.
References gem5::arrayParamIn(), gem5::arrayParamOut(), expected(), getContents(), and gem5::MipsISA::scs.
TEST_F | ( | SerializeFixture | , |
GenerateCptOut | ) |
Test successful CheckpointOut generation with non-existent dir.
Definition at line 463 of file serialize.test.cc.
References dirExists(), gem5::Serializable::generateCheckpointOut(), and getContents().
TEST_F | ( | SerializeFixture | , |
GenerateCptOutExistent | ) |
Test successful CheckpointOut generation with existing dir.
Definition at line 479 of file serialize.test.cc.
References dirExists(), and gem5::Serializable::generateCheckpointOut().
TEST_F | ( | SerializeFixture | , |
MappingParamOutIn | ) |
Test mappingParamOut and mappingParamIn with all keys.
Definition at line 965 of file serialize.test.cc.
References gem5::ArmISA::e, expected(), getContents(), gem5::mappingParamIn(), gem5::mappingParamOut(), and gem5::MipsISA::scs.
TEST_F | ( | SerializeFixture | , |
MappingParamOutInMissing | ) |
Test that missing keys are ignored on mappingParamIn.
Definition at line 1007 of file serialize.test.cc.
References gem5::ArmISA::e, gem5::ArmISA::err, expected(), getContents(), gem5::gtestLogOutput, gem5::mappingParamIn(), gem5::mappingParamOut(), and gem5::MipsISA::scs.
TEST_F | ( | SerializeFixture | , |
OptParamOutIn | ) |
Test optional parameters.
Definition at line 756 of file serialize.test.cc.
References gem5::gtestLogOutput, gem5::optParamIn(), gem5::paramOut(), and gem5::MipsISA::scs.
TEST_F | ( | SerializeFixture | , |
SCSCptOutPathScoped | ) |
Test that paths are increased and decreased according to the scope that its SCS was created in (using CheckpointOut).
Definition at line 292 of file serialize.test.cc.
References gem5::Serializable::currentSection(), and gem5::MipsISA::scs.
TEST_F | ( | SerializeFixture | , |
SCSNoChangeCptIn | ) |
Make sure that a SCS that uses a CheckpointIn does not change the checkpoint file's contents.
Definition at line 316 of file serialize.test.cc.
References gem5::Serializable::currentSection(), gem5::MipsISA::is, gem5::X86ISA::os, and gem5::MipsISA::scs.
TEST_F | ( | SerializeFixture | , |
SerializeArray | ) |
Test SERIALIZE_ARRAY and UNSERIALIZE_ARRAY.
Definition at line 1224 of file serialize.test.cc.
References gem5::ArmISA::e, expected(), getContents(), gem5::MipsISA::scs, SERIALIZE_ARRAY, and UNSERIALIZE_ARRAY.
TEST_F | ( | SerializeFixture | , |
SerializeContainer | ) |
Test SERIALIZE_CONTAINER and UNSERIALIZE_CONTAINER.
Definition at line 1265 of file serialize.test.cc.
References expected(), getContents(), gem5::MipsISA::scs, SERIALIZE_CONTAINER, and UNSERIALIZE_CONTAINER.
TEST_F | ( | SerializeFixture | , |
SerializeEnum | ) |
Test serialization followed by unserialization, using SERIALIZE_ENUM and UNSERIALIZE_ENUM.
Definition at line 1177 of file serialize.test.cc.
References expected(), getContents(), gem5::MipsISA::scs, SERIALIZE_ENUM, UNSERIALIZE_ENUM, and gem5::ArmISA::ZERO.
TEST_F | ( | SerializeFixture | , |
SerializeMapping | ) |
Test SERIALIZE_MAPPING and UNSERIALIZE_MAPPING with all keys.
Definition at line 1326 of file serialize.test.cc.
References gem5::ArmISA::e, expected(), getContents(), gem5::MipsISA::scs, SERIALIZE_MAPPING, and UNSERIALIZE_MAPPING.
TEST_F | ( | SerializeFixture | , |
SerializeScalar | ) |
Test serialization followed by unserialization, using SERIALIZE_SCALAR and UNSERIALIZE_SCALAR.
Definition at line 1071 of file serialize.test.cc.
References expected(), getContents(), gem5::MipsISA::scs, SERIALIZE_SCALAR, and UNSERIALIZE_SCALAR.
TEST_F | ( | SerializeFixture | , |
UnserializeOptScalar | ) |
Test optional parameters with UNSERIALIZE_OPT_SCALAR.
Definition at line 1132 of file serialize.test.cc.
References gem5::MipsISA::scs, SERIALIZE_SCALAR, and UNSERIALIZE_OPT_SCALAR.
TEST_F | ( | SerializeFixtureDeathTest | , |
ArrayParamOutInSmaller | ) |
Test that using arrayParamIn with sizes smaller than the container's throws an exception.
Definition at line 937 of file serialize.test.cc.
References gem5::arrayParamIn(), gem5::arrayParamOut(), expected(), getContents(), and gem5::MipsISA::scs.
TEST_F | ( | SerializeFixtureDeathTest | , |
ConstructorFailure | ) |
Test constructor failure by requesting the creation of a checkpoint in a non-existent dir.
Definition at line 175 of file serialize.test.cc.
References gem5::CheckpointIn::setDir().
GTestTickHandler tickHandler |
Definition at line 55 of file serialize.test.cc.