gem5  v22.0.0.2
Classes | Typedefs | Functions | Variables
serialize.test.cc File Reference
#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. More...
 
 TEST (CheckpointInTest, SetGetDirTick)
 Tests that when the dir name has a "%d" curTick is added. More...
 
 TEST_F (SerializeFixtureDeathTest, ConstructorFailure)
 Test constructor failure by requesting the creation of a checkpoint in a non-existent dir. More...
 
 TEST_F (SerializeFixture, ConstructorSuccess)
 Test constructor success by requesting the creation of a checkpoint in a specific valid dir. More...
 
 TEST_F (CheckpointInFixtureDeathTest, GetCptDir)
 Test that changing the static cpt dir does not change the name of the cpt dir of previously created instances. More...
 
 TEST_F (CheckpointInFixture, FindSections)
 Test finding sections. More...
 
 TEST_F (CheckpointInFixture, FindEntries)
 Test finding entries. More...
 
 TEST_F (CheckpointInFixture, ExtractEntries)
 Test extracting the values of entries. More...
 
 TEST_F (CheckpointInFixture, SCSCptInPathScoped)
 Test that paths are increased and decreased according to the scope that its SCS was created in (using CheckpointIn). More...
 
 TEST_F (SerializeFixture, SCSCptOutPathScoped)
 Test that paths are increased and decreased according to the scope that its SCS was created in (using CheckpointOut). More...
 
 TEST_F (SerializeFixture, SCSNoChangeCptIn)
 Make sure that a SCS that uses a CheckpointIn does not change the checkpoint file's contents. More...
 
std::string getString (std::istream &is)
 
std::string getContents (std::ofstream &cpt, std::string filename)
 Flushes the checkpoint and reads its contents. More...
 
 TEST_F (SerializableFixture, SCSChangeCptOutSingle)
 Make sure that a SCS that uses a CheckpointOut changes the checkpoint file's contents (single section). More...
 
 TEST_F (SerializableFixture, SCSChangeCptOutMultiple)
 Make sure that a SCS that uses a CheckpointOut changes the checkpoint file's contents (multiple sections). More...
 
 TEST_F (SerializableFixture, SCSChangeCptOutLarge)
 Make sure that a SCS that uses a CheckpointOut changes the checkpoint file's contents (large test). More...
 
 TEST (SerializableDeathTest, GenerateCptOutFail)
 Test failure to create dir. More...
 
 TEST_F (SerializeFixture, GenerateCptOut)
 Test successful CheckpointOut generation with non-existent dir. More...
 
 TEST_F (SerializeFixture, GenerateCptOutExistent)
 Test successful CheckpointOut generation with existing dir. More...
 
 TEST_F (SerializableFixture, SectionSerializationSimple)
 Test section serialization and unserialization for an object without serializable contents. More...
 
 TEST_F (SerializableFixtureDeathTest, ParamIn)
 Test that paramIn called on a param that does not exist triggers an error. More...
 
 TEST_F (SerializableFixture, ParamOutIn)
 Test serialization followed by unserialization, using ParamInImpl and ParamOut. More...
 
 TEST_F (SerializableFixture, ParamOutInMultipleSections)
 Test serialization followed by unserialization, using ParamInImpl and ParamOut, when multiple sections exist. More...
 
 TEST_F (SerializeFixture, OptParamOutIn)
 Test optional parameters. More...
 
 TEST_F (SerializableFixtureDeathTest, NoSectionParamIn)
 Check for death when there is no section and paramIn is requested. More...
 
 TEST_F (SerializeFixture, ArrayParamOutIn)
 Test arrayParamOut and arrayParamIn. More...
 
 TEST_F (SerializeFixture, DISABLED_ArrayParamOutInSpacedStrings)
 Test arrayParamOut and arrayParamIn for strings with spaces. More...
 
 TEST_F (SerializeFixtureDeathTest, ArrayParamOutInSmaller)
 Test that using arrayParamIn with sizes smaller than the container's throws an exception. More...
 
 TEST_F (SerializeFixture, MappingParamOutIn)
 Test mappingParamOut and mappingParamIn with all keys. More...
 
 TEST_F (SerializeFixture, MappingParamOutInMissing)
 Test that missing keys are ignored on mappingParamIn. More...
 
 TEST_F (SerializeFixture, SerializeScalar)
 Test serialization followed by unserialization, using SERIALIZE_SCALAR and UNSERIALIZE_SCALAR. More...
 
 TEST_F (SerializeFixture, UnserializeOptScalar)
 Test optional parameters with UNSERIALIZE_OPT_SCALAR. More...
 
 TEST_F (SerializeFixture, SerializeEnum)
 Test serialization followed by unserialization, using SERIALIZE_ENUM and UNSERIALIZE_ENUM. More...
 
 TEST_F (SerializeFixture, SerializeArray)
 Test SERIALIZE_ARRAY and UNSERIALIZE_ARRAY. More...
 
 TEST_F (SerializeFixture, SerializeContainer)
 Test SERIALIZE_CONTAINER and UNSERIALIZE_CONTAINER. More...
 
 TEST_F (SerializeFixture, SerializeMapping)
 Test SERIALIZE_MAPPING and UNSERIALIZE_MAPPING with all keys. More...
 

Variables

GTestTickHandler tickHandler
 

Typedef Documentation

◆ CheckpointInFixtureDeathTest

Definition at line 143 of file serialize.test.cc.

◆ SerializableFixtureDeathTest

Definition at line 144 of file serialize.test.cc.

◆ SerializeFixture

Definition at line 65 of file serialize.test.cc.

◆ SerializeFixtureDeathTest

Definition at line 142 of file serialize.test.cc.

Function Documentation

◆ dirExists()

bool dirExists ( std::string  dir)
Returns
Whether the given dir exists and is accessible.

Definition at line 59 of file serialize.test.cc.

Referenced by TEST(), and TEST_F().

◆ getContents()

std::string getContents ( std::ofstream &  cpt,
std::string  filename 
)

Flushes the checkpoint and reads its contents.

Parameters
cptThe checkpoint to be flushed.
filenameThe name of the file to be read.
Returns
The contents in the filename, as a string.

Definition at line 354 of file serialize.test.cc.

References gem5::MipsISA::is.

Referenced by TEST_F().

◆ getString()

std::string getString ( std::istream &  is)
Returns
The ostream as a std::string.

Definition at line 338 of file serialize.test.cc.

References gem5::MipsISA::is.

◆ TEST() [1/3]

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() [2/3]

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() [3/3]

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() [1/31]

TEST_F ( CheckpointInFixture  ,
ExtractEntries   
)

Test extracting the values of entries.

Definition at line 245 of file serialize.test.cc.

◆ TEST_F() [2/31]

TEST_F ( CheckpointInFixture  ,
FindEntries   
)

Test finding entries.

Definition at line 230 of file serialize.test.cc.

◆ TEST_F() [3/31]

TEST_F ( CheckpointInFixture  ,
FindSections   
)

Test finding sections.

Definition at line 217 of file serialize.test.cc.

◆ TEST_F() [4/31]

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() [5/31]

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() [6/31]

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() [7/31]

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() [8/31]

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() [9/31]

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() [10/31]

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() [11/31]

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() [12/31]

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() [13/31]

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() [14/31]

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() [15/31]

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() [16/31]

TEST_F ( SerializeFixture  ,
DISABLED_ArrayParamOutInSpacedStrings   
)

Test arrayParamOut and arrayParamIn for strings with spaces.

Todo:
This is broken because spaces are delimiters between array entries; so, strings containing spaces are seen as multiple entries

Definition at line 905 of file serialize.test.cc.

References gem5::arrayParamIn(), gem5::arrayParamOut, expected, getContents(), and gem5::MipsISA::scs.

◆ TEST_F() [17/31]

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() [18/31]

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() [19/31]

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() [20/31]

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() [21/31]

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() [22/31]

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() [23/31]

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() [24/31]

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() [25/31]

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() [26/31]

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() [27/31]

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() [28/31]

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() [29/31]

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() [30/31]

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() [31/31]

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().

Variable Documentation

◆ tickHandler

GTestTickHandler tickHandler

Definition at line 55 of file serialize.test.cc.


Generated on Thu Jul 28 2022 13:32:49 for gem5 by doxygen 1.8.17