A Discrete-Event Network Simulator
API
test-ns3 Namespace Reference

Classes

class  NS3BaseTestCase
 Generic test case with basic function inherited by more complex tests. More...
 
class  NS3BuildBaseTestCase
 Tests ns3 regarding building the project. More...
 
class  NS3CommonSettingsTestCase
 ns3 tests related to generic options More...
 
class  NS3ConfigureBuildProfileTestCase
 ns3 tests related to build profiles More...
 
class  NS3ConfigureTestCase
 Test ns3 configuration options. More...
 
class  NS3ExpectedUseTestCase
 Tests ns3 usage in more realistic scenarios. More...
 
class  NS3RunWafTargets
 ns3 tests related to compatibility with Waf-produced binaries More...
 

Functions

def get_enabled_modules ()
 
def get_headers_list (outdir=usual_outdir)
 Gets a list of header files. More...
 
def get_libraries_list (lib_outdir=usual_lib_outdir)
 Gets a list of built libraries. More...
 
def get_programs_list (build_status_script_path=usual_build_status_script)
 Extracts the programs list from build-status.py. More...
 
def get_test_enabled ()
 Check if tests are enabled in the c4che/_cache.py. More...
 
def read_c4che_entry (entry, c4che_script_path=usual_c4che_script)
 Read interesting entries from the c4che/_cache.py file. More...
 
def run_ns3 (args, env=None)
 Runs the ns3 wrapper script with arguments. More...
 
def run_program (program, args, python=False, cwd=ns3_path, env=None)
 Runs a program with the given arguments and returns a tuple containing (error code, stdout and stderr) More...
 

Variables

string cmake_build_project_command = "cmake --build . -j".format(ns3_path=ns3_path)
 
 cmake_build_target_command
 
 loader = unittest.TestLoader()
 
 ns3_path = os.path.dirname(os.path.abspath(os.sep.join([__file__, "../../"])))
 
 ns3_script = os.sep.join([ns3_path, "ns3"])
 
 ns3rc_script = os.sep.join([ns3_path, ".ns3rc"])
 
string ns3rc_script_bak = ns3rc_script + ".bak"
 
 result = runner.run(suite)
 
 runner = unittest.TextTestRunner(failfast=True)
 
 suite = unittest.TestSuite()
 
 usual_build_status_script = os.sep.join([usual_outdir, "build-status.py"])
 
 usual_c4che_script = os.sep.join([usual_outdir, "c4che", "_cache.py"])
 
 usual_lib_outdir = os.sep.join([usual_outdir, "lib"])
 
 usual_outdir = os.sep.join([ns3_path, "build"])
 

Function Documentation

◆ get_enabled_modules()

def test-ns3.get_enabled_modules ( )
Check if tests are enabled in the c4che/_cache.py
@return list of enabled modules (prefixed with 'ns3-').

Definition at line 160 of file test-ns3.py.

References read_c4che_entry().

Referenced by test-ns3.NS3ExpectedUseTestCase.test_01_BuildProject(), test-ns3.NS3ConfigureTestCase.test_03_EnableModules(), test-ns3.NS3ConfigureTestCase.test_04_DisableModules(), test-ns3.NS3ConfigureTestCase.test_05_EnableModulesComma(), test-ns3.NS3ConfigureTestCase.test_06_DisableModulesComma(), and test-ns3.NS3ConfigureTestCase.test_07_Ns3rc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_headers_list()

def test-ns3.get_headers_list (   outdir = usual_outdir)

Gets a list of header files.

Parameters
outdirpath containing headers
Returns
list of headers.

Definition at line 130 of file test-ns3.py.

Referenced by test-ns3.NS3BuildBaseTestCase.test_08_InstallationAndUninstallation().

+ Here is the caller graph for this function:

◆ get_libraries_list()

def test-ns3.get_libraries_list (   lib_outdir = usual_lib_outdir)

◆ get_programs_list()

def test-ns3.get_programs_list (   build_status_script_path = usual_build_status_script)

Extracts the programs list from build-status.py.

Parameters
build_status_script_pathpath containing build-status.py
Returns
list of programs.

Definition at line 109 of file test-ns3.py.

Referenced by test-ns3.NS3ExpectedUseTestCase.test_01_BuildProject(), test-ns3.NS3ConfigureTestCase.test_01_Examples(), test-ns3.NS3BuildBaseTestCase.test_03_BuildProject(), test-ns3.NS3BuildBaseTestCase.test_06_TestVersionFile(), test-ns3.NS3ConfigureTestCase.test_07_Ns3rc(), and test-ns3.NS3ConfigureTestCase.test_08_DryRun().

+ Here is the caller graph for this function:

◆ get_test_enabled()

def test-ns3.get_test_enabled ( )

Check if tests are enabled in the c4che/_cache.py.

Returns
bool.

Definition at line 152 of file test-ns3.py.

References read_c4che_entry().

Referenced by test-ns3.NS3ConfigureTestCase.test_07_Ns3rc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_c4che_entry()

def test-ns3.read_c4che_entry (   entry,
  c4che_script_path = usual_c4che_script 
)

Read interesting entries from the c4che/_cache.py file.

Parameters
entryentry to read from c4che/_cache.py
c4che_script_pathpath containing _cache.py
Returns
value of the requested entry.

Definition at line 139 of file test-ns3.py.

Referenced by get_enabled_modules(), get_test_enabled(), and test-ns3.NS3ExpectedUseTestCase.test_15_EnableSudo().

+ Here is the caller graph for this function:

◆ run_ns3()

def test-ns3.run_ns3 (   args,
  env = None 
)

Runs the ns3 wrapper script with arguments.

Parameters
argsstring containing arguments that will get split before calling ns3
envenvironment variables dictionary
Returns
tuple containing (error code, stdout and stderr)

Definition at line 53 of file test-ns3.py.

References run_program().

Referenced by test-ns3.NS3RunWafTargets.setUp(), test-ns3.NS3CommonSettingsTestCase.setUp(), test-ns3.NS3ConfigureBuildProfileTestCase.setUp(), test-ns3.NS3BaseTestCase.setUp(), test-ns3.NS3ExpectedUseTestCase.setUp(), test-ns3.NS3BuildBaseTestCase.test_01_BuildExistingTargets(), test-ns3.NS3ExpectedUseTestCase.test_01_BuildProject(), test-ns3.NS3ConfigureBuildProfileTestCase.test_01_Debug(), test-ns3.NS3ConfigureTestCase.test_01_Examples(), test-ns3.NS3CommonSettingsTestCase.test_01_NoOption(), test-ns3.NS3ExpectedUseTestCase.test_02_BuildAndRunExistingExecutableTarget(), test-ns3.NS3BuildBaseTestCase.test_02_BuildNonExistingTargets(), test-ns3.NS3CommonSettingsTestCase.test_02_NoTaskLines(), test-ns3.NS3ConfigureBuildProfileTestCase.test_02_Release(), test-ns3.NS3ConfigureTestCase.test_02_Tests(), test-ns3.NS3ExpectedUseTestCase.test_03_BuildAndRunExistingLibraryTarget(), test-ns3.NS3BuildBaseTestCase.test_03_BuildProject(), test-ns3.NS3CommonSettingsTestCase.test_03_CheckConfig(), test-ns3.NS3ConfigureTestCase.test_03_EnableModules(), test-ns3.NS3ConfigureBuildProfileTestCase.test_03_Optimized(), test-ns3.NS3RunWafTargets.test_03_runNobuildScratchSim(), test-ns3.NS3ExpectedUseTestCase.test_04_BuildAndRunNonExistingTarget(), test-ns3.NS3BuildBaseTestCase.test_04_BuildProjectNoTaskLines(), test-ns3.NS3CommonSettingsTestCase.test_04_CheckProfile(), test-ns3.NS3ConfigureTestCase.test_04_DisableModules(), test-ns3.NS3RunWafTargets.test_04_runNobuildExample(), test-ns3.NS3ConfigureBuildProfileTestCase.test_04_Typo(), test-ns3.NS3BuildBaseTestCase.test_05_BreakBuild(), test-ns3.NS3CommonSettingsTestCase.test_05_CheckVersion(), test-ns3.NS3ConfigureTestCase.test_05_EnableModulesComma(), test-ns3.NS3ExpectedUseTestCase.test_05_RunNoBuildExistingExecutableTarget(), test-ns3.NS3ConfigureBuildProfileTestCase.test_05_TYPO(), test-ns3.NS3ConfigureTestCase.test_06_DisableModulesComma(), test-ns3.NS3ExpectedUseTestCase.test_06_RunNoBuildExistingLibraryTarget(), test-ns3.NS3BuildBaseTestCase.test_06_TestVersionFile(), test-ns3.NS3ConfigureTestCase.test_07_Ns3rc(), test-ns3.NS3BuildBaseTestCase.test_07_OutputDirectory(), test-ns3.NS3RunWafTargets.test_07_runCoreExampleSimulator(), test-ns3.NS3ExpectedUseTestCase.test_07_RunNoBuildNonExistingExecutableTarget(), test-ns3.NS3ConfigureTestCase.test_08_DryRun(), test-ns3.NS3BuildBaseTestCase.test_08_InstallationAndUninstallation(), test-ns3.NS3ExpectedUseTestCase.test_08_RunNoBuildGdb(), test-ns3.NS3ConfigureTestCase.test_09_PropagationOfReturnCode(), test-ns3.NS3ExpectedUseTestCase.test_09_RunNoBuildValgrind(), test-ns3.NS3BuildBaseTestCase.test_09_Scratches(), test-ns3.NS3ConfigureTestCase.test_10_CheckConfig(), test-ns3.NS3ExpectedUseTestCase.test_10_DoxygenWithBuild(), test-ns3.NS3ConfigureTestCase.test_11_CheckProfile(), test-ns3.NS3ExpectedUseTestCase.test_11_DoxygenWithoutBuild(), test-ns3.NS3ConfigureTestCase.test_12_CheckVersion(), test-ns3.NS3ExpectedUseTestCase.test_12_SphinxDocumentation(), test-ns3.NS3ExpectedUseTestCase.test_13_Documentation(), test-ns3.NS3ConfigureTestCase.test_13_Scratches(), test-ns3.NS3ExpectedUseTestCase.test_14_Check(), test-ns3.NS3ConfigureTestCase.test_14_MpiCommandTemplate(), test-ns3.NS3ExpectedUseTestCase.test_15_EnableSudo(), test-ns3.NS3ExpectedUseTestCase.test_16_CommandTemplate(), and test-ns3.NS3ExpectedUseTestCase.test_17_ForwardArgumentsToRunTargets().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run_program()

def test-ns3.run_program (   program,
  args,
  python = False,
  cwd = ns3_path,
  env = None 
)

Runs a program with the given arguments and returns a tuple containing (error code, stdout and stderr)

Parameters
programprogram to execute (or python script)
argsstring containing arguments that will get split before calling the program
pythonflag indicating whether the program is a python script
cwdthe working directory used that will be the root folder for the execution
envenvironment variables dictionary
Returns
tuple containing (error code, stdout and stderr)

Definition at line 64 of file test-ns3.py.

References test-waf.replace().

Referenced by run_ns3(), test-ns3.NS3RunWafTargets.setUp(), test-ns3.NS3RunWafTargets.test_05_runTestCaseCoreExampleSimulator(), test-ns3.NS3RunWafTargets.test_06_runTestCaseExamplesAsTestsTestSuite(), test-ns3.NS3RunWafTargets.test_07_runCoreExampleSimulator(), test-ns3.NS3BuildBaseTestCase.test_08_InstallationAndUninstallation(), and test-ns3.NS3ConfigureTestCase.test_13_Scratches().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ cmake_build_project_command

string test-ns3.cmake_build_project_command = "cmake --build . -j".format(ns3_path=ns3_path)

Definition at line 47 of file test-ns3.py.

◆ cmake_build_target_command

◆ loader

test-ns3.loader = unittest.TestLoader()

Definition at line 1641 of file test-ns3.py.

◆ ns3_path

test-ns3.ns3_path = os.path.dirname(os.path.abspath(os.sep.join([__file__, "../../"])))

Definition at line 35 of file test-ns3.py.

◆ ns3_script

test-ns3.ns3_script = os.sep.join([ns3_path, "ns3"])

Definition at line 36 of file test-ns3.py.

◆ ns3rc_script

test-ns3.ns3rc_script = os.sep.join([ns3_path, ".ns3rc"])

Definition at line 37 of file test-ns3.py.

◆ ns3rc_script_bak

string test-ns3.ns3rc_script_bak = ns3rc_script + ".bak"

Definition at line 1653 of file test-ns3.py.

◆ result

test-ns3.result = runner.run(suite)

Definition at line 1659 of file test-ns3.py.

Referenced by _cairo_uint_96by64_32x64_divrem(), ns3::Names.Add(), ns3::InterferenceHelper.AddBand(), ns3::dsdv::RoutingTable.AddIpv4Event(), ns3::dsr::DsrRouteCache.AddRoute(), ns3::aodv::RoutingTable.AddRoute(), ns3::dsdv::RoutingTable.AddRoute(), ns3::LrWpanInterferenceHelper.AddSignal(), ns3::int64x64::test::Int64x64CompareTestCase.Check(), ns3::int64x64::test::Int64x64Bug455TestCase.Check(), ns3::int64x64::test::Int64x64Bug863TestCase.Check(), ns3::int64x64::test::Int64x64DoubleTestCase.Check(), ns3::int64x64::test::Int64x64InvertTestCase.CheckCase(), ns3::dsr::DsrRouting.CheckSendBuffer(), ns3::test::RandomVariable::TestCaseBase.ChiSquaredsAverage(), ns3::CandidateQueue.CompareSPFVertex(), ns3::aodv::RoutingProtocol.DeferredRouteOutput(), ns3::dsdv::RoutingProtocol.DeferredRouteOutput(), ns3::PbbMessageIpv4.DeserializeOriginatorAddress(), ns3::int64x64_t.Div(), Ipv6L3ProtocolTestCase.DoRun(), MakeBoundCallbackTestCase.DoRun(), ns3::test::RandomVariable::UniformTestCase.DoRun(), RngUniformTestCase.DoRun(), RngNormalTestCase.DoRun(), RngExponentialTestCase.DoRun(), RngParetoTestCase.DoRun(), LinkTest.DoRun(), Ipv4L3ProtocolTestCase.DoRun(), BitSerializerTest.DoRun(), BitDeserializerTest.DoRun(), FileHeaderTestCase.DoRun(), RecordHeaderTestCase.DoRun(), CoDelQueueDiscNewtonStepTest.DoRun(), TwoLevelAggregationTest.DoRun(), Bug730TestCase.DoRun(), ns3::InternetStackHelper.EnableAsciiIpv4Internal(), ns3::InternetStackHelper.EnableAsciiIpv6Internal(), ns3::InternetStackHelper.EnablePcapIpv4Internal(), ns3::InternetStackHelper.EnablePcapIpv6Internal(), ns3::dsr::DsrRouteCache.FindSameRoute(), ns3::MeshPointDevice.Forward(), ns3::dsr::DsrRouting.ForwardPacket(), ns3::dot11s::HwmpProtocol.ForwardUnicast(), ns3::BitDeserializer.GetBits(), ns3::BitSerializer.GetBytes(), anonymous_namespace{packet-test-suite.cc}::ATestTagBase.GetData(), ns3::Ipv6StaticRouting.GetDefaultRoute(), ns3::Ipv4StaticRouting.GetDefaultRoute(), ns3::Hash::Function::Murmur3.GetHash64(), ns3::Mac48Address.GetMulticast(), ns3.GetNodeIdInt(), ns3::Object.GetObject(), ns3::aodv::RoutingTableEntry.GetPrecursors(), ns3::dot11s::Dot11sMeshCapability.GetUint8(), ns3::ErlangRandomVariable.GetValue(), ns3::flame::FlameProtocol.HandleDataFrame(), ns3::AsciiTraceHelper.HookDefaultDequeueSinkWithContext(), ns3::AsciiTraceHelper.HookDefaultDequeueSinkWithoutContext(), ns3::AsciiTraceHelper.HookDefaultDropSinkWithContext(), ns3::AsciiTraceHelper.HookDefaultDropSinkWithoutContext(), ns3::AsciiTraceHelper.HookDefaultEnqueueSinkWithContext(), ns3::AsciiTraceHelper.HookDefaultEnqueueSinkWithoutContext(), ns3::AsciiTraceHelper.HookDefaultReceiveSinkWithContext(), ns3::AsciiTraceHelper.HookDefaultReceiveSinkWithoutContext(), ns3::PcapHelper.HookDefaultSink(), ns3::MapScheduler.Insert(), ns3::int64x64_t.Invert(), Ns3TcpLossTestCase.Ipv4L3Tx(), Ns3TcpStateTestCase.Ipv4L3Tx(), ns3::ErrorModel.IsCorrupt(), ns3::int64x64_t.Mul(), ns3::int64x64_t.MulByInvert(), ns3::UanPhyPerUmodem.NChooseK(), ns3::dsr::DsrRouting.PacketNewRoute(), ns3::LrWpanPhy.PlmeEdRequest(), ns3::dot11s::HwmpProtocol.ProactivePathResolved(), ns3::AnimationInterface.ProtocolTypeToString(), ns3::dot11s::HwmpProtocol.ReactivePathResolved(), ns3::PacketMetadata.ReadUleb128(), ns3::dot11s::HwmpProtocol.ReceivePerr(), ns3::dot11s::HwmpProtocol.ReceivePrep(), ns3::dot11s::HwmpProtocol.ReceivePreq(), ns3::LrWpanInterferenceHelper.RemoveSignal(), ns3::Names.Rename(), ns3::TestRunnerImpl.ReplaceXmlSpecialCharacters(), ns3::flame::FlameProtocol.RequestRoute(), ns3::dot11s::HwmpProtocol.RetryPathDiscovery(), ns3::dsr::DsrRouting.Send(), ChannelRoutingTestCase.SendIp(), ns3::dsr::DsrRouting.SendPacketFromBuffer(), ns3::dsr::DsrRouting.SendUnreachError(), ChannelRoutingTestCase.SendWsa(), ChannelRoutingTestCase.SendWsmp(), ns3::LteUeComponentCarrierManager.SetComponentCarrierMacSapProviders(), LengthTestCase.TestAddingLengthAndQuantity(), LengthTestCase.TestAddingQuantityAndLength(), LengthTestCase.TestAddingTwoLengths(), ChannelAccessTestCase.TestAlternating(), ChannelAccessTestCase.TestAlternatingAfter(), LengthValueTestCase.TestAttributeDeserialization(), ChannelAccessTestCase.TestContinuous(), ChannelAccessTestCase.TestContinuousAfter(), LengthTestCase.TestDivideLengthByLength(), LengthTestCase.TestDivideLengthByLengthReturnsNaN(), LengthTestCase.TestDivideLengthByScalar(), TimeSimpleTestCase.TestDivision(), LengthTestCase.TestDivReturnsCorrectRemainder(), LengthTestCase.TestDivReturnsCorrectResult(), LengthTestCase.TestDivReturnsZeroRemainder(), ChannelAccessTestCase.TestExtended(), ChannelAccessTestCase.TestExtendedAfter(), LengthTestCase.TestModReturnsNonZero(), LengthTestCase.TestModReturnsZero(), LengthTestCase.TestMultiplyLengthByScalar(), LengthTestCase.TestMultiplyScalarByLength(), LengthTestCase.TestSubtractingLengthAndQuantity(), LengthTestCase.TestSubtractingQuantityAndLength(), LengthTestCase.TestSubtractingTwoLengths(), LengthTestCase.TestTryParseReturnsFalse(), LengthTestCase.TestTryParseReturnsTrue(), ns3::WallClockSynchronizer.TimevalAdd(), ns3::PointToPointNetDevice.TransmitStart(), ns3::int64x64_t.Udiv(), ns3::int64x64_t.Umul(), ns3::int64x64_t.UmulByInvert(), and ns3::dsr::DsrRouteCache.UpdateRouteEntry().

◆ runner

test-ns3.runner = unittest.TextTestRunner(failfast=True)

Definition at line 1658 of file test-ns3.py.

Referenced by ns3::TestCase.Run().

◆ suite

test-ns3.suite = unittest.TestSuite()

Definition at line 1642 of file test-ns3.py.

◆ usual_build_status_script

test-ns3.usual_build_status_script = os.sep.join([usual_outdir, "build-status.py"])

Definition at line 39 of file test-ns3.py.

◆ usual_c4che_script

test-ns3.usual_c4che_script = os.sep.join([usual_outdir, "c4che", "_cache.py"])

Definition at line 40 of file test-ns3.py.

◆ usual_lib_outdir

test-ns3.usual_lib_outdir = os.sep.join([usual_outdir, "lib"])

Definition at line 41 of file test-ns3.py.

◆ usual_outdir

test-ns3.usual_outdir = os.sep.join([ns3_path, "build"])

Definition at line 38 of file test-ns3.py.