mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 10:03:58 +02:00
WIP: Add tests for isl-mock-channel
This commit is contained in:
parent
e05dc827cc
commit
e8bf45a5d9
3 changed files with 66 additions and 3 deletions
62
test/isl-mock-channel-test-suite.cc
Normal file
62
test/isl-mock-channel-test-suite.cc
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/network-module.h"
|
||||
#include "ns3/internet-module.h"
|
||||
#include "ns3/applications-module.h"
|
||||
#include "ns3/node-container.h"
|
||||
|
||||
#include "ns3/leo-module.h"
|
||||
#include "ns3/test.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
class IslMockChannelTransmitTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
IslMockChannelTransmitTestCase ();
|
||||
virtual ~IslMockChannelTransmitTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
IslMockChannelTransmitTestCase::IslMockChannelTransmitTestCase ()
|
||||
: TestCase ("Test channel transmission")
|
||||
{
|
||||
}
|
||||
|
||||
IslMockChannelTransmitTestCase::~IslMockChannelTransmitTestCase ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
IslMockChannelTransmitTestCase::DoRun (void)
|
||||
{
|
||||
Ptr<IslMockChannel> channel = CreateObject<IslMockChannel> ();
|
||||
Packet *packet = new Packet ();
|
||||
Ptr<Packet> p = Ptr<Packet>(packet);
|
||||
Ptr<MockNetDevice> dev = CreateObject<MockNetDevice> ();
|
||||
int32_t srcId = channel->Attach (dev);
|
||||
Address destAddr;
|
||||
Time txTime;
|
||||
bool result = channel->TransmitStart (p, srcId, destAddr, txTime);
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (result, false, "Unknown destination fails to deliver");
|
||||
}
|
||||
|
||||
class IslMockChannelTestSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
IslMockChannelTestSuite ();
|
||||
};
|
||||
|
||||
IslMockChannelTestSuite::IslMockChannelTestSuite ()
|
||||
: TestSuite ("isl-mock-channel", UNIT)
|
||||
{
|
||||
// TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
|
||||
AddTestCase (new IslMockChannelTransmitTestCase, TestCase::QUICK);
|
||||
}
|
||||
|
||||
// Do not forget to allocate an instance of this TestSuite
|
||||
static IslMockChannelTestSuite islMockChannelTestSuite;
|
|
@ -56,6 +56,7 @@ IslIcmpTestCase::DoRun (void)
|
|||
NdCacheHelper nsHelper;
|
||||
nsHelper.Install (devices, interfaces);
|
||||
|
||||
// install echo server on all nodes
|
||||
UdpEchoServerHelper echoServer (9);
|
||||
ApplicationContainer serverApps = echoServer.Install (nodes);
|
||||
|
||||
|
@ -70,13 +71,12 @@ IslIcmpTestCase::DoRun (void)
|
|||
Address destAddress = interfaces.GetAddress (i, 0);
|
||||
echoClient.SetAttribute ("RemoteAddress", AddressValue (destAddress));
|
||||
|
||||
clientApps.Add (echoClient.Install (nodes.Get (i-1)));
|
||||
clientApps.Add (echoClient.Install (nodes.Get (0)));
|
||||
}
|
||||
|
||||
serverApps.Start (Seconds (1.0));
|
||||
clientApps.Start (Seconds (2.0));
|
||||
clientApps.Stop (Seconds (10.0));
|
||||
|
||||
serverApps.Start (Seconds (1.0));
|
||||
serverApps.Stop (Seconds (10.0));
|
||||
|
||||
Simulator::Run ();
|
||||
|
|
1
wscript
1
wscript
|
@ -27,6 +27,7 @@ def build(bld):
|
|||
module_test.source = [
|
||||
'test/leo-test-suite.cc',
|
||||
'test/isl-test-suite.cc',
|
||||
'test/isl-mock-channel-test-suite.cc',
|
||||
]
|
||||
|
||||
headers = bld(features='ns3header')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue