A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ns3::TestCase Class Referenceabstract

encapsulates test code More...

#include <test.h>

+ Inheritance diagram for ns3::TestCase:

Classes

struct  Result
 

Public Types

enum  TestDuration { QUICK = 1, EXTENSIVE = 2, TAKES_FOREVER = 3 }
 How long the test takes to execute. More...
 

Protected Member Functions

 TestCase (std::string name)
 
void AddTestCase (TestCase *testCase) NS_DEPRECATED
 Add an individual test case to this test suite. More...
 
void AddTestCase (TestCase *testCase, enum TestDuration duration)
 Add an individual test case to this test suite. More...
 
std::string CreateDataDirFilename (std::string filename)
 
std::string CreateTempDirFilename (std::string filename)
 
bool GetErrorStatus (void) const NS_DEPRECATED
 
std::string GetName (void) const
 
bool IsStatusFailure (void) const
 
bool IsStatusSuccess (void) const
 
bool MustAssertOnFailure (void) const
 
bool MustContinueOnFailure (void) const
 
void ReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, std::string file, int32_t line)
 
void SetDataDir (std::string directory)
 

Private Member Functions

 TestCase (TestCase &tc)
 
virtual void DoRun (void)=0
 Implementation to actually run this test case. More...
 
virtual void DoSetup (void)
 Implementation to do any local setup required for this test case. More...
 
virtual void DoTeardown (void)
 Implementation to do any local setup required for this test case. More...
 
bool IsFailed (void) const
 
TestCaseoperator= (TestCase &tc)
 
void Run (TestRunnerImpl *runner)
 

Private Attributes

std::vector< TestCase * > m_children
 
std::string m_dataDir
 
enum TestDuration m_duration
 
std::string m_name
 
TestCasem_parent
 
struct Resultm_result
 
TestRunnerImplm_runner
 

Friends

class TestRunnerImpl
 

Detailed Description

encapsulates test code

To allow a new test to be run within the ns-3 test framework, users need to create subclasses of this base class, override the DoRun method, and use the NS_TEST_* macros within DoRun.

Definition at line 834 of file test.h.

Member Enumeration Documentation

How long the test takes to execute.

Enumerator
EXTENSIVE 

Fast test.

TAKES_FOREVER 

Medium length test.

Definition at line 841 of file test.h.

Constructor & Destructor Documentation

ns3::TestCase::TestCase ( std::string  name)
protected
Parameters
namethe name of the new test created

Definition at line 147 of file test.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

void ns3::TestCase::AddTestCase ( TestCase testCase,
enum TestDuration  duration 
)
protected

Add an individual test case to this test suite.

Parameters
testCasePointer to the test case object to be added.
durationAmount of time this test takes to execute.

Definition at line 178 of file test.cc.

References NS_FATAL_ERROR, and NS_LOG_FUNCTION.

virtual void ns3::TestCase::DoRun ( void  )
privatepure virtual

Implementation to actually run this test case.

Subclasses should override this method to conduct their tests.

Implemented in RandomVariableStreamEmpiricalAntitheticTestCase, RandomVariableStreamEmpiricalTestCase, RandomVariableStreamDeterministicTestCase, RandomVariableStreamZetaAntitheticTestCase, RandomVariableStreamZetaTestCase, RandomVariableStreamZipfAntitheticTestCase, RandomVariableStreamZipfTestCase, RandomVariableStreamErlangAntitheticTestCase, RandomVariableStreamErlangTestCase, RandomVariableStreamGammaAntitheticTestCase, RandomVariableStreamGammaTestCase, RandomVariableStreamLogNormalAntitheticTestCase, RandomVariableStreamLogNormalTestCase, RandomVariableStreamWeibullAntitheticTestCase, CallbackValueTestCase, RandomVariableStreamWeibullTestCase, PointerAttributeTestCase, DiffTestCase, RandomVariableStreamParetoAntitheticTestCase, TracedCallbackTestCase, ns3::TestSuite, ReadFileTestCase, IntegerTraceSourceTestCase, RandomVariableStreamParetoTestCase, CsmaStarTestCase, AlternateFindTestCase, ns3::MeasurementReportTestCase, IntegerTraceSourceAttributeTestCase, RelativeFindTestCase, ns3::RrcConnectionRejectTestCase, CsmaRawIpSocketTestCase, RandomVariableStreamExponentialAntitheticTestCase, ObjectMapAttributeTestCase, ns3::RrcConnectionReestablishmentCompleteTestCase, FullyQualifiedFindTestCase, ObjectVectorAttributeTestCase, ns3::RrcConnectionReestablishmentTestCase, StringContextFindTestCase, CsmaPingTestCase, RandomVariableStreamExponentialTestCase, RandomVariableStreamAttributeTestCase, ns3::RrcConnectionReestablishmentRequestTestCase, RecordHeaderTestCase, BasicFindTestCase, AttributeTestCase< T >, ns3::HandoverPreparationInfoTestCase, FindPathTestCase, CsmaPacketSocketTestCase, AttributeTestCase< T >, RandomVariableStreamNormalAntitheticTestCase, RelativeRenameTestCase, AttributeTestCase< T >, ns3::dsr::DsrRreqTableTest, ObjectVectorTraceConfigTestCase, ns3::aodv::AodvRtableTest, FullyQualifiedRenameTestCase, CsmaOneSubnetTestCase, MakeCallbackTemplatesTestCase, ns3::RrcConnectionReconfigurationTestCase, FileHeaderTestCase, RandomVariableStreamNormalTestCase, RangePropagationLossModelTestCase, Udp6SocketImplTest, ns3::aodv::AodvRtableEntryTest, ns3::dsr::DsrSendBuffTest, NullifyCallbackTestCase, StringContextRenameTestCase, ns3::RrcConnectionReconfigurationCompleteTestCase, Ns3TcpCwndTestCase2, AttributeTestCase< T >, MatrixPropagationLossModelTestCase, ns3::ObjectFactoryTestCase, RandomVariableStreamSequentialTestCase, ns3::RrcConnectionSetupCompleteTestCase, ns3::dsr::DsrCacheEntryTest, RngParetoTestCase, BasicRenameTestCase, ns3::Bug555TestCase, ObjectVectorConfigTestCase, AttributeTestCase< T >, ns3::dsr::DsrAckHeaderTest, ns3::aodv::AodvRqueueTest, RandomVariableStreamConstantTestCase, MakeBoundCallbackTestCase, ns3::RrcConnectionSetupTestCase, GlobalRoutingSlash32TestCase, WaypointMobilityModelViaHelper, CsmaMulticastTestCase, ns3::EpcS1uUlTestCase, LogDistancePropagationLossModelTestCase, UdpEchoClientSetFillTestCase, RelativeAddTestCase, ns3::aodv::QueueEntryTest, ns3::dsr::DsrAckReqHeaderTest, AttributeTestCase< T >, Int64x64InvertTestCase, PacketMetadataTest, ns3::OlsrHnaTestCase, ns3::RrcConnectionRequestTestCase, AddressCollisionTestCase, Int64x64CompareTestCase, RngExponentialTestCase, ns3::aodv::RerrHeaderTest, ns3::Ns2MobilityHelperTest, ns3::dsr::DsrRerrHeaderTest, CtrlBAckResponseHeaderTest, BasicEnergyDepletionTest, ns3::OlsrTcTestCase, ns3::aodv::RrepAckHeaderTest, ns3::dot11s::PeerLinkFrameStartTest, AddressCollision6TestCase, UnderRootNamespaceConfigTestCase, PacketTest, Int64x64Bug863TestCase, FullyQualifiedAddTestCase, ReadModeCreateTestCase, ns3::AcousticModemEnergyDepletionTestCase, UdpSocketImplTest, FiveDoublesTestCase, PacketLossCounterTestCase, FiveDoublesAverageTestCase, ExampleAddressGeneratorTestCase, TestFulfilledAlignment, ns3::aodv::ChainRegressionTest, IpAddressHelperTestCasev4, ns3::InterferenceHelperSequenceTest, CommandLineStringTestCase, RandomVariableStreamUniformAntitheticTestCase, Ns3TcpCwndTestCase1, ns3::dsr::DsrSRHeaderTest, SimulatorTemplateTestCase, Int64x64Bug455TestCase, ns3::AggregateObjectTestCase, ns3::aodv::RrepHeaderTest, MakeCallbackTestCase, Ns3WimaxSFTypeTestCase, ExampleAddress6GeneratorTestCase, CsmaBroadcastTestCase, NscTcpLossTestCase2, WaypointInitialPositionIsWaypoint, Ns3TcpSocketTestCase2, ns3::OlsrHelloTestCase, ns3::QosUtilsIsOldPacketTest, Udp6SocketLoopbackTest, BurstErrorModelSimple, ns3::SameRoomPositionAllocatorTestCase, RootNamespaceConfigTestCase, PacketBufferingCaseB, CommandLineUnsignedIntTestCase, Ns3WimaxSfTlvTestCase, TestOptionWithAlignment, TwoRayGroundPropagationLossModelTestCase, RngNormalTestCase, ns3::dsr::DsrRrepHeaderTest, StringContextAddTestCase, Ns3WimaxSNRtoBLERTestCase, NetworkAndAddressTestCase, UdpTraceClientServerTestCase, ns3::aodv::RreqHeaderTest, NetworkAndAddress6TestCase, ResetAllocatorHelperTestCase, Int64x64ArithmeticTestCase, ns3::LteRlcAmTransmitterReportBufferStatusTestCase, ns3::LteRlcUmTransmitterReportBufferStatusTestCase, FiveIntegersTestCase, ns3::LteTxPsdTestCase, FiveIntegersAverageTestCase, Ns3WimaxManagementConnectionsTestCase, CommandLineIntTestCase, ns3::CreateObjectTestCase, UdpSocketLoopbackTest, Ipv6FragmentationTest, WaypointLazyNotifyTrue, ns3::DsdvTableTestCase, RandomNumberSerializationTestCase, ns3::LteRlcAmTransmitterConcatenationTestCase, ns3::LteRlcUmTransmitterConcatenationTestCase, ns3::aodv::TypeHeaderTest, TimerTemplateTestCase, ns3::BuildingsHelperOneTestCase, ns3::LteEarfcnUlTestCase, ns3::BriteTopologyFunctionTestCase, ns3::dsr::DsrRreqHeaderTest, Ipv4FragmentationTest, ns3::RrcHeaderTestCase, ns3::LteEpcE2eDataTestCase, Ipv6ListRoutingPositiveTestCase, ns3::olsr::TcRegressionTest, ns3::dot11s::HwmpRtableTest, ns3::LteRlcAmTransmitterSegmentationTestCase, ns3::LteRlcUmTransmitterSegmentationTestCase, WriteModeCreateTestCase, Ns3TcpInteroperabilityTestCase, TestOptionWithoutAlignment, TimesWithSignsTestCase, Ipv4ListRoutingPositiveTestCase, Ipv4RawSocketImplTest, Ipv4PacketInfoTagTest, Int64x64InputOutputTestCase, Ipv4HeaderTest, ns3::EpcS1uDlTestCase, AddressAllocatorTestCase, ns3::LteNoisePsdTestCase, Ipv6RawSocketImplTest, ns3::LteFadingSystemTestCase, ns3::TwoVectorsConstructorTestCase, CommandLineBooleanTestCase, ns3::SpectrumIdealPhyTestCase, ns3::RadiansToDegreesTestCase, AddressAllocatorHelperTestCase, HwmpReactiveRegressionTest, SequenceNumberTestCase, AddressAllocator6TestCase, Ipv6PacketInfoTagTest, RandomVariableStreamUniformTestCase, ns3::aodv::Bug772ChainTest, ns3::LteRlcAmTransmitterOneSduTestCase, ns3::LteRlcUmTransmitterOneSduTestCase, HwmpSimplestRegressionTest, ErrorModelSimple, BasicAddTestCase, HwmpDoRfRegressionTest, ns3::LteEarfcnDlTestCase, ns3::LteHandoverDelayTestCase, ns3::RandomRoomPositionAllocatorTestCase, ns3::LenaFdTbfqFfMacSchedulerTestCase2, ns3::LenaPssFfMacSchedulerTestCase2, ns3::LenaTdTbfqFfMacSchedulerTestCase2, ns3::EpcTftClassifierTestCase, ns3::LenaFdBetFfMacSchedulerTestCase2, ns3::LenaTdBetFfMacSchedulerTestCase2, ns3::LenaPfFfMacSchedulerTestCase2, ns3::LteUplinkSrsSinrTestCase, PacketBufferingCaseA, TcpTestCase, ns3::LteDownlinkCtrlSinrTestCase, Ns3TcpLossTestCase, Ns3TcpStateTestCase, Ipv6ListRoutingNegativeTestCase, ns3::olsr::HelloRegressionTest, BatteryLifetimeTest, ns3::LenaDlCtrlPhyErrorModelTestCase, ThreadedSimulatorEventsTestCase, ns3::dsr::DsrFsHeaderTest, HwmpProactiveRegressionTest, ns3::flame::FlameRtableTest, ns3::DcfManagerTest, ns3::LteX2HandoverTestCase, FlameRegressionTest, CsmaBridgeTestCase, DualStackTestCase, PeerManagementProtocolRegressionTest, WifiInterferenceTestCase, RngUniformTestCase, Ipv4ListRoutingNegativeTestCase, Ns3WimaxSimpleOFDMTestCase, ns3::LteEnbAntennaTestCase, DynamicGlobalRoutingTestCase, NscTcpLossTestCase1, PtrTestCase, ns3::DsdvHeaderTestCase, ns3::LtePathlossModelSystemTestCase, Ns3WimaxNetworkEntryTestCase, TimerStateTestCase, ns3::LteFadingTestCase, Ns3TcpSocketTestCase1, Ns3WimaxFragmentationTestCase, Ns3WimaxSfCreationTestCase, Ns3WimaxCsParamTlvTestCase, ns3::Ipv6L3ProtocolTestCase, ns3::LteInterferenceTestCase, Ns3TcpNoDelayTestCase, BasicEnergyUpdateTest, ns3::OlsrMidTestCase, DsaRequestTestCase, UdpClientServerTestCase, ns3::Ipv4L3ProtocolTestCase, ns3::LteRlcAmTransmitterTestCase, ns3::LteRlcUmTransmitterTestCase, MobilityTraceTestCase, ns3::AcousticModemEnergyTestCase, ns3::LteDownlinkDataSinrTestCase, ns3::LteLinkAdaptationTestCase, ns3::LteUplinkDataSinrTestCase, StaticRoutingSlash32TestCase, ns3::LenaFdBetFfMacSchedulerTestCase1, LenaFdMtFfMacSchedulerTestCase, ns3::LenaFdTbfqFfMacSchedulerTestCase1, ns3::LenaPssFfMacSchedulerTestCase1, ns3::LenaTdBetFfMacSchedulerTestCase1, LenaTdMtFfMacSchedulerTestCase, ns3::LenaTdTbfqFfMacSchedulerTestCase1, LenaTtaFfMacSchedulerTestCase, WifiMsduAggregatorThroughputTest, ns3::CosineAntennaModelTestCase, ns3::ParabolicAntennaModelTestCase, ns3::BuildingsShadowingTestCase, ns3::EpsGtpuHeaderTestCase, ns3::LenaPfFfMacSchedulerTestCase1, ns3::WaypointMobilityModelNotifyTest, ns3::AnimationInterfaceTestCase, ns3::olsr::OlsrMprTestCase, ns3::WifiTest, Ns3WimaxSchedulingTestCase, ns3::BuildingsPathlossTestCase, ns3::LteRlcAmE2eTestCase, ns3::LteRlcUmE2eTestCase, ns3::LteRrcConnectionEstablishmentTestCase, WaypointLazyNotifyFalse, ns3::LenaRrFfMacSchedulerTestCase, SwitchFlowTableTestCase, ns3::MeshInformationElementVectorBist, ns3::LenaHarqTestCase, ns3::LenaDataPhyErrorModelTestCase, ns3::olsr::Bug780Test, ns3::aodv::IdCacheTest, ns3::LteSpectrumModelTestCase, ns3::ItuR1411LosPropagationLossModelTestCase, ns3::ItuR1411NlosOverRooftopPropagationLossModelTestCase, ns3::Kun2600MhzPropagationLossModelTestCase, ns3::OkumuraHataPropagationLossModelTestCase, FriisPropagationLossModelTestCase, ns3::LteEarfcnTestCase, ns3::SpectrumInterferenceTestCase, ns3::SpectrumValueTestCase, Int64x64InputTestCase, BasicRandomNumberTestCase, ns3::SteadyStateRandomWaypointTest, UanTest, ns3::BriteTopologyStructureTestCase, ManyUniformRandomVariablesOneGetValueCallTestCase, OneUniformRandomVariableManyGetValueCallsTestCase, TestEmptyOptionField, ns3::LenaMimoTestCase, OneIntegerTestCase, OneIntegerAverageTestCase, ns3::RocketfuelTopologyReaderTest, BasicCallbackTestCase, PbbTestCase, ns3::DegreesToRadiansTestCase, ns3::IsotropicAntennaModelTestCase, ns3::aodv::LoopbackTestCase, ns3::dot11s::MeshHeaderTest, ns3::OneVectorConstructorTestCase, ns3::LiIonEnergyTestCase, IpAddressHelperTestCasev6, GlobalRouteManagerImplTestCase, ns3::flame::FlameHeaderTest, ns3::EventGarbageCollectorTestCase, ns3::TxDurationTest, ns3::aodv::NeighborTest, ns3::GlobalValueTestCase, RttTestCase, RedQueueTestCase, SimulatorEventsTestCase, TimeSimpleTestCase, BasicTracedCallbackTestCase, TypeTraitsTestCase, NetworkAllocatorHelperTestCase, ns3::HistogramTestCase, NetworkNumber6AllocatorTestCase, ns3::OlsrEmfTestCase, WatchdogTestCase, NetworkNumberAllocatorTestCase, DropTailQueueTestCase, Ipv6AddressTestCase1, CognitiveTestCase1, SampleTestCase1, BufferTest, PointToPointTest, and Int64x64FracTestCase.

void ns3::TestCase::DoSetup ( void  )
privatevirtual

Implementation to do any local setup required for this test case.

Subclasses should override this method to perform any costly per-test setup before DoRun is invoked.

Reimplemented in ReadFileTestCase, RecordHeaderTestCase, FileHeaderTestCase, NullifyCallbackTestCase, MakeBoundCallbackTestCase, ns3::Ns2MobilityHelperTest, ReadModeCreateTestCase, MakeCallbackTestCase, WriteModeCreateTestCase, Ns3TcpInteroperabilityTestCase, TimesWithSignsTestCase, Ns3TcpLossTestCase, Ns3TcpStateTestCase, ThreadedSimulatorEventsTestCase, BasicCallbackTestCase, and TimeSimpleTestCase.

Definition at line 343 of file test.cc.

References NS_LOG_FUNCTION.

bool ns3::TestCase::GetErrorStatus ( void  ) const
protected

This method is deprecated. IsStatusFailure replaces it.

Definition at line 317 of file test.cc.

References IsStatusFailure(), and NS_LOG_FUNCTION.

bool ns3::TestCase::IsStatusFailure ( void  ) const
protected
Returns
true if the tests have failed, false otherwise.

Definition at line 323 of file test.cc.

References IsStatusSuccess(), and NS_LOG_FUNCTION.

Referenced by ns3::Ns2MobilityHelperTest::CheckInitialPositions(), and GetErrorStatus().

bool ns3::TestCase::IsStatusSuccess ( void  ) const
protected
Returns
true if the tests have succeeded, false otherwise.

Definition at line 329 of file test.cc.

References NS_LOG_FUNCTION.

Referenced by IsStatusFailure().

void ns3::TestCase::SetDataDir ( std::string  directory)
protected
Parameters
directorythe directory where the test data is located

In general, this method is invoked as SetDataDir (NS_TEST_SOURCEDIR); However, if a module contains a test directory with subdirectories (e.g. src/mesh/test), and the test data (e.g. pcap traces) is located in one of these subdirectories, then the variable NS_TEST_SOURCEDIR may not work and the user may want to explicitly pass in a directory string.

Note that NS_TEST_SOURCEDIR is set in src/wscript for each module

Definition at line 336 of file test.cc.

References NS_LOG_FUNCTION.

Referenced by MobilityTraceTestCase::DoRun().


The documentation for this class was generated from the following files: