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  NS3UnusedSourcesTestCase
 ns-3 tests related to checking if source files were left behind, not being used by CMake 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 ()
 Extracts the programs list from .lock-ns3. More...
 
def get_test_enabled ()
 Check if tests are enabled in the .lock-ns3. More...
 
def read_lock_entry (entry)
 Read interesting entries from the .lock-ns3 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_lock_filename = os.path.join(ns3_path, ".lock-ns3_%s_build" % sys.platform)
 
 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()
 
 tests = dict(map(lambda x: (x._testMethodName, x), suite._tests))
 
 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 .lock-ns3
@return list of enabled modules (prefixed with 'ns3-').

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

References read_lock_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 133 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()

◆ get_test_enabled()

def test-ns3.get_test_enabled ( )

Check if tests are enabled in the .lock-ns3.

Returns
bool.

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

References read_lock_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_lock_entry()

def test-ns3.read_lock_entry (   entry)

Read interesting entries from the .lock-ns3 file.

Parameters
entryentry to read from .lock-ns3
Returns
value of the requested entry.

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

Referenced by get_enabled_modules(), get_test_enabled(), test-ns3.NS3BuildBaseTestCase.test_10_PybindgenBindings(), and test-ns3.NS3ExpectedUseTestCase.test_14_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 52 of file test-ns3.py.

References run_program().

Referenced by 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.NS3ExpectedUseTestCase.test_04_BuildAndRunNonExistingTarget(), test-ns3.NS3BuildBaseTestCase.test_04_BuildProjectNoTaskLines(), test-ns3.NS3CommonSettingsTestCase.test_04_CheckProfile(), test-ns3.NS3ConfigureTestCase.test_04_DisableModules(), 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.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.NS3BuildBaseTestCase.test_10_PybindgenBindings(), test-ns3.NS3BuildBaseTestCase.test_11_AmbiguityCheck(), 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.NS3BuildBaseTestCase.test_12_StaticBuilds(), test-ns3.NS3ExpectedUseTestCase.test_13_Documentation(), test-ns3.NS3ConfigureTestCase.test_13_Scratches(), test-ns3.NS3ExpectedUseTestCase.test_14_EnableSudo(), test-ns3.NS3ConfigureTestCase.test_14_MpiCommandTemplate(), test-ns3.NS3ExpectedUseTestCase.test_15_CommandTemplate(), test-ns3.NS3ConfigureTestCase.test_15_InvalidLibrariesToLink(), test-ns3.NS3ExpectedUseTestCase.test_16_ForwardArgumentsToRunTargets(), test-ns3.NS3ConfigureTestCase.test_16_LibrariesContainingLib(), test-ns3.NS3ConfigureTestCase.test_17_CMakePerformanceTracing(), and test-ns3.NS3ExpectedUseTestCase.test_17_RunNoBuildLldb().

+ 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 68 of file test-ns3.py.

Referenced by run_ns3(), test-ns3.NS3BuildBaseTestCase.test_08_InstallationAndUninstallation(), test-ns3.NS3BuildBaseTestCase.test_10_PybindgenBindings(), and test-ns3.NS3ConfigureTestCase.test_13_Scratches().

+ 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 46 of file test-ns3.py.

◆ cmake_build_target_command

◆ loader

test-ns3.loader = unittest.TestLoader()

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

◆ ns3_lock_filename

test-ns3.ns3_lock_filename = os.path.join(ns3_path, ".lock-ns3_%s_build" % sys.platform)

Definition at line 36 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 37 of file test-ns3.py.

◆ ns3rc_script

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

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

◆ ns3rc_script_bak

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

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

◆ result

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

Definition at line 2150 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::UeManager.GetRrcConnectionReconfigurationForHandover(), 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(), 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 2149 of file test-ns3.py.

Referenced by ns3::TestCase.Run().

◆ suite

test-ns3.suite = unittest.TestSuite()

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

◆ tests

test-ns3.tests = dict(map(lambda x: (x._testMethodName, x), suite._tests))

◆ usual_lib_outdir

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

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

◆ usual_outdir

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

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