A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
network-status-test-suite.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2018 University of Padova
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Davide Magrin <magrinda@dei.unipd.it>
7
*/
8
9
/*
10
* This file includes testing for the following components:
11
* - EndDeviceStatus
12
* - GatewayStatus
13
* - NetworkStatus
14
*/
15
16
#include "
utilities.h
"
17
18
// An essential include is test.h
19
#include "ns3/test.h"
20
21
// Include headers of classes to test
22
#include "ns3/class-a-end-device-lorawan-mac.h"
23
#include "ns3/network-status.h"
24
25
using namespace
ns3
;
26
using namespace
lorawan
;
27
28
NS_LOG_COMPONENT_DEFINE
(
"NetworkStatusTestSuite"
);
29
30
/**
31
* @ingroup lorawan
32
*
33
* It tests the constructor of the EndDeviceStatus class
34
*/
35
class
EndDeviceStatusTest
:
public
TestCase
36
{
37
public
:
38
EndDeviceStatusTest
();
//!< Default constructor
39
~EndDeviceStatusTest
()
override
;
//!< Destructor
40
41
private
:
42
void
DoRun
()
override
;
43
};
44
45
// Add some help text to this case to describe what it is intended to test
46
EndDeviceStatusTest::EndDeviceStatusTest
()
47
:
TestCase
(
"Verify correct behavior of the EndDeviceStatus object"
)
48
{
49
}
50
51
// Reminder that the test case should clean up after itself
52
EndDeviceStatusTest::~EndDeviceStatusTest
()
53
{
54
}
55
56
// This method is the pure virtual method from class TestCase that every
57
// TestCase must implement
58
void
59
EndDeviceStatusTest::DoRun
()
60
{
61
NS_LOG_DEBUG
(
"EndDeviceStatusTest"
);
62
63
// Create an EndDeviceStatus object
64
EndDeviceStatus
eds =
EndDeviceStatus
();
65
}
66
67
/**
68
* @ingroup lorawan
69
*
70
* It tests the function NetworkStatus::AddNode
71
*/
72
class
NetworkStatusTest
:
public
TestCase
73
{
74
public
:
75
NetworkStatusTest
();
//!< Default constructor
76
~NetworkStatusTest
()
override
;
//!< Destructor
77
78
private
:
79
void
DoRun
()
override
;
80
};
81
82
// Add some help text to this case to describe what it is intended to test
83
NetworkStatusTest::NetworkStatusTest
()
84
:
TestCase
(
"Verify correct behavior of the NetworkStatus object"
)
85
{
86
}
87
88
// Reminder that the test case should clean up after itself
89
NetworkStatusTest::~NetworkStatusTest
()
90
{
91
}
92
93
// This method is the pure virtual method from class TestCase that every
94
// TestCase must implement
95
void
96
NetworkStatusTest::DoRun
()
97
{
98
NS_LOG_DEBUG
(
"NetworkStatusTest"
);
99
100
// Create a NetworkStatus object
101
NetworkStatus
ns =
NetworkStatus
();
102
103
// Create a bunch of actual devices
104
NetworkComponents
components =
InitializeNetwork
(1, 1);
105
106
Ptr<LoraChannel>
channel = components.
channel
;
107
NodeContainer
endDevices = components.
endDevices
;
108
NodeContainer
gateways = components.
gateways
;
109
110
ns.AddNode(
GetMacLayerFromNode<ClassAEndDeviceLorawanMac>
(endDevices.
Get
(0)));
111
}
112
113
/**
114
* @ingroup lorawan
115
*
116
* The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the
117
* TestCases to be run. Typically, only the constructor for this class must be defined
118
*/
119
class
NetworkStatusTestSuite
:
public
TestSuite
120
{
121
public
:
122
NetworkStatusTestSuite
();
//!< Default constructor
123
};
124
125
NetworkStatusTestSuite::NetworkStatusTestSuite
()
126
:
TestSuite
(
"network-status"
,
Type
::UNIT)
127
{
128
// LogComponentEnable("NetworkStatusTestSuite", LOG_LEVEL_DEBUG);
129
130
AddTestCase
(
new
EndDeviceStatusTest
,
Duration::QUICK
);
131
AddTestCase
(
new
NetworkStatusTest
,
Duration::QUICK
);
132
}
133
134
// Do not forget to allocate an instance of this TestSuite
135
static
NetworkStatusTestSuite
lorawanTestSuite
;
EndDeviceStatusTest
It tests the constructor of the EndDeviceStatus class.
Definition
network-status-test-suite.cc:36
EndDeviceStatusTest::EndDeviceStatusTest
EndDeviceStatusTest()
Default constructor.
Definition
network-status-test-suite.cc:46
EndDeviceStatusTest::~EndDeviceStatusTest
~EndDeviceStatusTest() override
Destructor.
Definition
network-status-test-suite.cc:52
EndDeviceStatusTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
network-status-test-suite.cc:59
NetworkStatusTest
It tests the function NetworkStatus::AddNode.
Definition
network-status-test-suite.cc:73
NetworkStatusTest::NetworkStatusTest
NetworkStatusTest()
Default constructor.
Definition
network-status-test-suite.cc:83
NetworkStatusTest::~NetworkStatusTest
~NetworkStatusTest() override
Destructor.
Definition
network-status-test-suite.cc:89
NetworkStatusTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
network-status-test-suite.cc:96
NetworkStatusTestSuite
The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the TestCases...
Definition
network-status-test-suite.cc:120
NetworkStatusTestSuite::NetworkStatusTestSuite
NetworkStatusTestSuite()
Default constructor.
Definition
network-status-test-suite.cc:125
ns3::NodeContainer
keep track of a set of node pointers.
Definition
node-container.h:29
ns3::NodeContainer::Get
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Definition
node-container.cc:67
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:70
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:296
ns3::TestCase::Duration::QUICK
@ QUICK
Fast test.
Definition
test.h:1057
ns3::TestCase::TestCase
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1271
ns3::TestSuite::TestSuite
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition
test.cc:494
ns3::lorawan::EndDeviceStatus
This class represents the network server's knowledge about an end device in the LoRaWAN network it is...
Definition
end-device-status.h:71
ns3::lorawan::NetworkStatus
This class represents the knowledge about the state of the network that is available at the network s...
Definition
network-status.h:33
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:194
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition
log.h:260
lorawanTestSuite
static LorawanTestSuite lorawanTestSuite
Definition
lorawan-test-suite.cc:2261
ns3::lorawan
Definition
forwarder-helper.cc:19
ns3::lorawan::InitializeNetwork
NetworkComponents InitializeNetwork(int nDevices, int nGateways)
Definition
utilities.cc:124
ns3::lorawan::GetMacLayerFromNode
Ptr< T > GetMacLayerFromNode(Ptr< Node > n)
Definition
utilities.h:45
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::lorawan::NetworkComponents
Stores the main elements of a simulated LoRaWAN network.
Definition
utilities.h:28
ns3::lorawan::NetworkComponents::channel
Ptr< LoraChannel > channel
A pointer to the LoraChannel object.
Definition
utilities.h:29
ns3::lorawan::NetworkComponents::endDevices
NodeContainer endDevices
Container of the end device nodes.
Definition
utilities.h:30
ns3::lorawan::NetworkComponents::gateways
NodeContainer gateways
Container of the gateway nodes.
Definition
utilities.h:31
utilities.h
src
lorawan
test
network-status-test-suite.cc
Generated on
for ns-3 by
1.15.0