gem5  v21.1.0.2
Classes | Functions | Variables
storage.test.cc File Reference
#include <gtest/gtest-spi.h>
#include <gtest/gtest.h>
#include <cmath>
#include "base/gtest/cur_tick_fake.hh"
#include "base/gtest/logging.hh"
#include "base/stats/storage.hh"

Go to the source code of this file.

Classes

struct  ValueSamples
 A pair of value and its number of samples, used for sampling. More...
 

Functions

void increaseTick ()
 Increases the current tick by one. More...
 
 TEST (StatsStatStorTest, SetValueResult)
 Test setting and getting a value to the storage. More...
 
 TEST (StatsStatStorTest, Prepare)
 Test if prepare does not change the value. More...
 
 TEST (StatsStatStorTest, IncDec)
 Test whether incrementing and decrementing work as expected. More...
 
 TEST (StatsStatStorTest, ZeroReset)
 Test whether zero is correctly set as the reset value. More...
 
 TEST (StatsAvgStorTest, SetValueResult)
 Test setting and getting a value to the storage. More...
 
 TEST (StatsAvgStorTest, Prepare)
 Test whether getting the result in a different tick does not trigger an assertion if storage is prepared. More...
 
 TEST (StatsAvgStorTest, IncDec)
 Test whether incrementing and decrementing work as expected. More...
 
 TEST (StatsAvgStorTest, ZeroReset)
 Test whether zero is correctly set as the reset value. More...
 
 TEST (StatsDistStorTest, ZeroReset)
 Test whether zero is correctly set as the reset value. More...
 
 TEST (StatsDistStorTest, Size)
 Test that the size of this storage is equal to its counters vector's size, and that after it has been set, nothing can modify it. More...
 
void checkExpectedDistData (const statistics::DistData &data, const statistics::DistData &expected_data, bool no_log=true)
 Compare both dist datas to see if their contents match. More...
 
void prepareCheckDistStor (statistics::DistStor::Params &params, ValueSamples *values, int num_values, statistics::DistData &expected_data)
 Auxiliary function that finishes preparing the DistStor's expected values, perform the calls to the storage's sample, and compares the expected data. More...
 
 TEST (StatsDistStorTest, SamplePrepareSingle)
 Test setting and getting value from storage. More...
 
 TEST (StatsDistStorTest, SamplePrepareMultiple)
 Test setting and getting value from storage with multiple values. More...
 
 TEST (StatsDistStorTest, Reset)
 Test resetting storage. More...
 
 TEST (StatsHistStorTest, ZeroReset)
 Test whether zero is correctly set as the reset value. More...
 
 TEST (StatsHistStorTest, Size)
 Test that the size of this storage is equal to its counters vector's size, and that after it has been set, nothing can modify it. More...
 
void prepareCheckHistStor (statistics::HistStor::Params &params, ValueSamples *values, int num_values, statistics::DistData &expected_data)
 Auxiliary function that finishes preparing the HistStor's expected values, perform the calls to the storage's sample, and compares the expected data. More...
 
 TEST (StatsHistStorTest, SamplePrepareFit)
 Test samples that fit in the initial buckets, and therefore do not need to grow up. More...
 
 TEST (StatsHistStorTest, SamplePrepareSingleGrowUp)
 Test samples that do not fit in the initial buckets, and therefore have to grow up once. More...
 
 TEST (StatsHistStorTest, SamplePrepareMultipleGrowUp)
 Test samples that do not fit in the initial buckets, and therefore have to grow up a few times. More...
 
 TEST (StatsHistStorTest, SamplePrepareGrowDownOddBuckets)
 Test samples that have a negative value, and therefore do not fit in the initial buckets. More...
 
 TEST (StatsHistStorTest, SamplePrepareGrowDownEvenBuckets)
 Test samples that have a negative value, and therefore do not fit in the initial buckets. More...
 
 TEST (StatsHistStorTest, SamplePrepareGrowDownGrowOutOddBuckets)
 Test samples that have one low negative value, and therefore do not fit in the initial buckets and have to grow down a few times. More...
 
 TEST (StatsHistStorTest, SamplePrepareGrowDownGrowOutEvenBuckets)
 Test samples that have one low negative value, and therefore do not fit in the initial buckets and have to grow down a few times. More...
 
 TEST (StatsHistStorTest, SamplePrepareMultipleGrowOddBuckets)
 Test a complex sample set with negative values, and therefore multiple grows will happen. More...
 
 TEST (StatsHistStorTest, SamplePrepareMultipleGrowEvenBuckets)
 Test a complex sample set with negative values, and therefore multiple grows will happen. More...
 
 TEST (StatsHistStorTest, Reset)
 Test resetting storage. More...
 
 TEST (StatsHistStorTest, Add)
 Test merging two histograms. More...
 
 TEST (StatsSampleStorTest, ZeroReset)
 Test whether zero is correctly set as the reset value. More...
 
 TEST (StatsSampleStorTest, SamplePrepare)
 Test setting and getting value from storage. More...
 
 TEST (StatsSampleStorTest, Size)
 The size is always 1, no matter which functions have been called. More...
 
 TEST (StatsAvgSampleStorTest, ZeroReset)
 Test whether zero is correctly set as the reset value. More...
 
 TEST (StatsAvgSampleStorTest, SamplePrepare)
 Test setting and getting value from storage. More...
 
 TEST (StatsAvgSampleStorTest, Size)
 The size is always 1, no matter which functions have been called. More...
 
 TEST (StatsSparseHistStorTest, ZeroReset)
 Test whether zero is correctly set as the reset value. More...
 
 TEST (StatsSparseHistStorTest, SamplePrepare)
 Test setting and getting value from storage. More...
 

Variables

GTestTickHandler tickHandler
 

Function Documentation

◆ checkExpectedDistData()

void checkExpectedDistData ( const statistics::DistData data,
const statistics::DistData expected_data,
bool  no_log = true 
)

◆ increaseTick()

void increaseTick ( )

Increases the current tick by one.

Definition at line 44 of file storage.test.cc.

References gem5::curTick(), gem5::GTestTickHandler::setCurTick(), and tickHandler.

Referenced by TEST().

◆ prepareCheckDistStor()

void prepareCheckDistStor ( statistics::DistStor::Params params,
ValueSamples values,
int  num_values,
statistics::DistData expected_data 
)

Auxiliary function that finishes preparing the DistStor's expected values, perform the calls to the storage's sample, and compares the expected data.

Parameters
paramsThe params containing the number of buckets.
valuesThe value-num_sample pairs to be sampled.
num_valuesNumber of values in the values array.
expected_dataExpected data after sampling, with the following values setup to the expected values: bucket_size, min, max_val, and cvec.

Definition at line 347 of file storage.test.cc.

References checkExpectedDistData(), data, gem5::ArmISA::i, gem5::statistics::DistData::logs, gem5::statistics::DistData::max, gem5::statistics::DistStor::Params::max, gem5::statistics::DistData::min, gem5::statistics::DistStor::Params::min, ValueSamples::numSamples, gem5::statistics::DistStor::prepare(), gem5::statistics::DistStor::sample(), gem5::statistics::DistData::samples, gem5::statistics::DistData::squares, gem5::statistics::DistData::sum, gem5::X86ISA::val, and ValueSamples::value.

Referenced by TEST().

◆ prepareCheckHistStor()

void prepareCheckHistStor ( statistics::HistStor::Params params,
ValueSamples values,
int  num_values,
statistics::DistData expected_data 
)

Auxiliary function that finishes preparing the HistStor's expected values, perform the calls to the storage's sample, and compares the expected data.

Parameters
paramsThe params containing the number of buckets.
valuesThe value-num_sample pairs to be sampled.
num_valuesNumber of values in the values array.
expected_dataExpected data after sampling, with the following values setup to the expected values: bucket_size, min, max_val, and cvec.

Definition at line 548 of file storage.test.cc.

References gem5::statistics::DistData::bucket_size, checkExpectedDistData(), data, gem5::ArmISA::i, gem5::statistics::DistData::logs, gem5::statistics::DistData::max, gem5::statistics::DistData::max_val, gem5::statistics::DistData::min, gem5::statistics::DistData::min_val, ValueSamples::numSamples, gem5::statistics::HistStor::prepare(), gem5::statistics::HistStor::sample(), gem5::statistics::DistData::samples, gem5::statistics::DistData::squares, gem5::statistics::DistData::sum, gem5::X86ISA::val, and ValueSamples::value.

Referenced by TEST().

◆ TEST() [1/34]

TEST ( StatsAvgSampleStorTest  ,
SamplePrepare   
)

◆ TEST() [2/34]

TEST ( StatsAvgSampleStorTest  ,
Size   
)

◆ TEST() [3/34]

TEST ( StatsAvgSampleStorTest  ,
ZeroReset   
)

Test whether zero is correctly set as the reset value.

The test order is to check if it is initially zero on creation, then it is made non zero, and finally reset to zero.

Definition at line 1070 of file storage.test.cc.

References gem5::statistics::AvgSampleStor::reset(), gem5::statistics::AvgSampleStor::sample(), gem5::X86ISA::val, and gem5::statistics::AvgSampleStor::zero().

◆ TEST() [4/34]

TEST ( StatsAvgStorTest  ,
IncDec   
)

Test whether incrementing and decrementing work as expected.

Definition at line 201 of file storage.test.cc.

References gem5::statistics::AvgStor::dec(), gem5::statistics::AvgStor::inc(), gem5::statistics::AvgStor::set(), gem5::X86ISA::val, and gem5::statistics::AvgStor::value().

◆ TEST() [5/34]

TEST ( StatsAvgStorTest  ,
Prepare   
)

Test whether getting the result in a different tick does not trigger an assertion if storage is prepared.

Definition at line 175 of file storage.test.cc.

References gem5::curTick(), increaseTick(), gem5::statistics::AvgStor::prepare(), gem5::statistics::AvgStor::result(), gem5::statistics::AvgStor::set(), gem5::statistics::total, gem5::X86ISA::val, and gem5::statistics::AvgStor::value().

◆ TEST() [6/34]

TEST ( StatsAvgStorTest  ,
SetValueResult   
)

◆ TEST() [7/34]

TEST ( StatsAvgStorTest  ,
ZeroReset   
)

Test whether zero is correctly set as the reset value.

The test order is to check if it is initially zero on creation, then it is made non zero, and finally reset to zero.

Definition at line 233 of file storage.test.cc.

References gem5::statistics::AvgStor::inc(), increaseTick(), gem5::statistics::AvgStor::reset(), gem5::X86ISA::val, and gem5::statistics::AvgStor::zero().

◆ TEST() [8/34]

TEST ( StatsDistStorTest  ,
Reset   
)

◆ TEST() [9/34]

TEST ( StatsDistStorTest  ,
SamplePrepareMultiple   
)

◆ TEST() [10/34]

TEST ( StatsDistStorTest  ,
SamplePrepareSingle   
)

◆ TEST() [11/34]

TEST ( StatsDistStorTest  ,
Size   
)

Test that the size of this storage is equal to its counters vector's size, and that after it has been set, nothing can modify it.

Definition at line 286 of file storage.test.cc.

References data, gem5::statistics::DistStor::prepare(), gem5::statistics::DistStor::reset(), gem5::statistics::DistStor::sample(), gem5::statistics::DistStor::size(), gem5::X86ISA::val, and gem5::statistics::DistStor::zero().

◆ TEST() [12/34]

TEST ( StatsDistStorTest  ,
ZeroReset   
)

Test whether zero is correctly set as the reset value.

The test order is to check if it is initially zero on creation, then it is made non zero, and finally reset to zero.

Definition at line 265 of file storage.test.cc.

References gem5::statistics::DistStor::reset(), gem5::statistics::DistStor::sample(), gem5::X86ISA::val, and gem5::statistics::DistStor::zero().

◆ TEST() [13/34]

TEST ( StatsHistStorTest  ,
Add   
)

◆ TEST() [14/34]

TEST ( StatsHistStorTest  ,
Reset   
)

◆ TEST() [15/34]

TEST ( StatsHistStorTest  ,
SamplePrepareFit   
)

◆ TEST() [16/34]

TEST ( StatsHistStorTest  ,
SamplePrepareGrowDownEvenBuckets   
)

Test samples that have a negative value, and therefore do not fit in the initial buckets.

Since this involves using negative values, the logs become irrelevant.

Definition at line 707 of file storage.test.cc.

References gem5::statistics::DistData::bucket_size, gem5::statistics::HistStor::Params::buckets, gem5::statistics::DistData::cvec, gem5::statistics::Hist, gem5::statistics::DistData::max_val, gem5::statistics::DistData::min, prepareCheckHistStor(), and gem5::statistics::DistData::type.

◆ TEST() [17/34]

TEST ( StatsHistStorTest  ,
SamplePrepareGrowDownGrowOutEvenBuckets   
)

Test samples that have one low negative value, and therefore do not fit in the initial buckets and have to grow down a few times.

Since this involves using negative values, the logs become irrelevant.

Definition at line 769 of file storage.test.cc.

References gem5::statistics::DistData::bucket_size, gem5::statistics::HistStor::Params::buckets, gem5::statistics::DistData::cvec, gem5::statistics::Hist, gem5::statistics::DistData::max_val, gem5::statistics::DistData::min, prepareCheckHistStor(), and gem5::statistics::DistData::type.

◆ TEST() [18/34]

TEST ( StatsHistStorTest  ,
SamplePrepareGrowDownGrowOutOddBuckets   
)

Test samples that have one low negative value, and therefore do not fit in the initial buckets and have to grow down a few times.

Since this involves using negative values, the logs become irrelevant.

Definition at line 737 of file storage.test.cc.

References gem5::statistics::DistData::bucket_size, gem5::statistics::HistStor::Params::buckets, gem5::statistics::DistData::cvec, gem5::statistics::Hist, gem5::statistics::DistData::max_val, gem5::statistics::DistData::min, prepareCheckHistStor(), and gem5::statistics::DistData::type.

◆ TEST() [19/34]

TEST ( StatsHistStorTest  ,
SamplePrepareGrowDownOddBuckets   
)

Test samples that have a negative value, and therefore do not fit in the initial buckets.

Since this involves using negative values, the logs become irrelevant.

Definition at line 675 of file storage.test.cc.

References gem5::statistics::DistData::bucket_size, gem5::statistics::HistStor::Params::buckets, gem5::statistics::DistData::cvec, gem5::statistics::Hist, gem5::statistics::DistData::max_val, gem5::statistics::DistData::min, prepareCheckHistStor(), and gem5::statistics::DistData::type.

◆ TEST() [20/34]

TEST ( StatsHistStorTest  ,
SamplePrepareMultipleGrowEvenBuckets   
)

Test a complex sample set with negative values, and therefore multiple grows will happen.

Since this involves using negative values, the logs become irrelevant.

Definition at line 833 of file storage.test.cc.

References gem5::statistics::DistData::bucket_size, gem5::statistics::HistStor::Params::buckets, gem5::statistics::DistData::cvec, gem5::statistics::Hist, gem5::statistics::DistData::max_val, gem5::statistics::DistData::min, prepareCheckHistStor(), and gem5::statistics::DistData::type.

◆ TEST() [21/34]

TEST ( StatsHistStorTest  ,
SamplePrepareMultipleGrowOddBuckets   
)

Test a complex sample set with negative values, and therefore multiple grows will happen.

Since this involves using negative values, the logs become irrelevant.

Definition at line 800 of file storage.test.cc.

References gem5::statistics::DistData::bucket_size, gem5::statistics::HistStor::Params::buckets, gem5::statistics::DistData::cvec, gem5::statistics::Hist, gem5::statistics::DistData::max_val, gem5::statistics::DistData::min, prepareCheckHistStor(), and gem5::statistics::DistData::type.

◆ TEST() [22/34]

TEST ( StatsHistStorTest  ,
SamplePrepareMultipleGrowUp   
)

◆ TEST() [23/34]

TEST ( StatsHistStorTest  ,
SamplePrepareSingleGrowUp   
)

◆ TEST() [24/34]

TEST ( StatsHistStorTest  ,
Size   
)

Test that the size of this storage is equal to its counters vector's size, and that after it has been set, nothing can modify it.

Definition at line 514 of file storage.test.cc.

References data, gem5::ArmISA::i, gem5::statistics::HistStor::prepare(), gem5::statistics::HistStor::reset(), gem5::statistics::HistStor::sample(), gem5::statistics::HistStor::size(), gem5::X86ISA::val, and gem5::statistics::HistStor::zero().

◆ TEST() [25/34]

TEST ( StatsHistStorTest  ,
ZeroReset   
)

Test whether zero is correctly set as the reset value.

The test order is to check if it is initially zero on creation, then it is made non zero, and finally reset to zero.

Definition at line 493 of file storage.test.cc.

References gem5::statistics::HistStor::reset(), gem5::statistics::HistStor::sample(), gem5::X86ISA::val, and gem5::statistics::HistStor::zero().

◆ TEST() [26/34]

TEST ( StatsSampleStorTest  ,
SamplePrepare   
)

◆ TEST() [27/34]

TEST ( StatsSampleStorTest  ,
Size   
)

◆ TEST() [28/34]

TEST ( StatsSampleStorTest  ,
ZeroReset   
)

Test whether zero is correctly set as the reset value.

The test order is to check if it is initially zero on creation, then it is made non zero, and finally reset to zero.

Definition at line 978 of file storage.test.cc.

References gem5::statistics::SampleStor::reset(), gem5::statistics::SampleStor::sample(), gem5::X86ISA::val, and gem5::statistics::SampleStor::zero().

◆ TEST() [29/34]

TEST ( StatsSparseHistStorTest  ,
SamplePrepare   
)

◆ TEST() [30/34]

TEST ( StatsSparseHistStorTest  ,
ZeroReset   
)

Test whether zero is correctly set as the reset value.

The test order is to check if it is initially zero on creation, then it is made non zero, and finally reset to zero.

Definition at line 1163 of file storage.test.cc.

References gem5::statistics::SparseHistStor::reset(), gem5::statistics::SparseHistStor::sample(), gem5::X86ISA::val, and gem5::statistics::SparseHistStor::zero().

◆ TEST() [31/34]

TEST ( StatsStatStorTest  ,
IncDec   
)

Test whether incrementing and decrementing work as expected.

Definition at line 89 of file storage.test.cc.

References gem5::statistics::StatStor::dec(), gem5::statistics::StatStor::inc(), gem5::X86ISA::val, and gem5::statistics::StatStor::value().

◆ TEST() [32/34]

TEST ( StatsStatStorTest  ,
Prepare   
)

◆ TEST() [33/34]

TEST ( StatsStatStorTest  ,
SetValueResult   
)

Test setting and getting a value to the storage.

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

References gem5::statistics::StatStor::result(), gem5::statistics::StatStor::set(), gem5::X86ISA::val, and gem5::statistics::StatStor::value().

◆ TEST() [34/34]

TEST ( StatsStatStorTest  ,
ZeroReset   
)

Test whether zero is correctly set as the reset value.

The test order is to check if it is initially zero on creation, then it is made non zero, and finally reset to zero.

Definition at line 117 of file storage.test.cc.

References gem5::statistics::StatStor::inc(), gem5::statistics::StatStor::reset(), gem5::X86ISA::val, and gem5::statistics::StatStor::zero().

Variable Documentation

◆ tickHandler

GTestTickHandler tickHandler

Definition at line 41 of file storage.test.cc.

Referenced by increaseTick().


Generated on Tue Sep 21 2021 12:26:26 for gem5 by doxygen 1.8.17