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
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Davide Magrin <magrinda@dei.unipd.it>
18
*/
19
20
/*
21
* This file includes testing for the following components:
22
* - EndDeviceStatus
23
* - GatewayStatus
24
* - NetworkStatus
25
*/
26
27
// Include headers of classes to test
28
#include "
utilities.h
"
29
30
#include "ns3/end-device-status.h"
31
#include "ns3/log.h"
32
#include "ns3/network-status.h"
33
34
// An essential include is test.h
35
#include "ns3/test.h"
36
37
using namespace
ns3
;
38
using namespace
lorawan;
39
40
NS_LOG_COMPONENT_DEFINE
(
"NetworkStatusTestSuite"
);
41
42
/**
43
* \ingroup lorawan
44
*
45
* It tests the constructor of the EndDeviceStatus class
46
*/
47
class
EndDeviceStatusTest
:
public
TestCase
48
{
49
public
:
50
EndDeviceStatusTest
();
//!< Default constructor
51
~EndDeviceStatusTest
()
override
;
//!< Destructor
52
53
private
:
54
void
DoRun
()
override
;
55
};
56
57
// Add some help text to this case to describe what it is intended to test
58
EndDeviceStatusTest::EndDeviceStatusTest
()
59
:
TestCase
(
"Verify correct behavior of the EndDeviceStatus object"
)
60
{
61
}
62
63
// Reminder that the test case should clean up after itself
64
EndDeviceStatusTest::~EndDeviceStatusTest
()
65
{
66
}
67
68
// This method is the pure virtual method from class TestCase that every
69
// TestCase must implement
70
void
71
EndDeviceStatusTest::DoRun
()
72
{
73
NS_LOG_DEBUG
(
"EndDeviceStatusTest"
);
74
75
// Create an EndDeviceStatus object
76
EndDeviceStatus
eds =
EndDeviceStatus
();
77
}
78
79
/**
80
* \ingroup lorawan
81
*
82
* It tests the function NetworkStatus::AddNode
83
*/
84
class
NetworkStatusTest
:
public
TestCase
85
{
86
public
:
87
NetworkStatusTest
();
//!< Default constructor
88
~NetworkStatusTest
()
override
;
//!< Destructor
89
90
private
:
91
void
DoRun
()
override
;
92
};
93
94
// Add some help text to this case to describe what it is intended to test
95
NetworkStatusTest::NetworkStatusTest
()
96
:
TestCase
(
"Verify correct behavior of the NetworkStatus object"
)
97
{
98
}
99
100
// Reminder that the test case should clean up after itself
101
NetworkStatusTest::~NetworkStatusTest
()
102
{
103
}
104
105
// This method is the pure virtual method from class TestCase that every
106
// TestCase must implement
107
void
108
NetworkStatusTest::DoRun
()
109
{
110
NS_LOG_DEBUG
(
"NetworkStatusTest"
);
111
112
// Create a NetworkStatus object
113
NetworkStatus
ns =
NetworkStatus
();
114
115
// Create a bunch of actual devices
116
NetworkComponents
components =
InitializeNetwork
(1, 1);
117
118
Ptr<LoraChannel>
channel = components.
channel
;
119
NodeContainer
endDevices = components.
endDevices
;
120
NodeContainer
gateways = components.
gateways
;
121
122
ns.
AddNode
(GetMacLayerFromNode<ClassAEndDeviceLorawanMac>(endDevices.
Get
(0)));
123
}
124
125
/**
126
* \ingroup lorawan
127
*
128
* The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the
129
* TestCases to be run. Typically, only the constructor for this class must be defined
130
*/
131
class
NetworkStatusTestSuite
:
public
TestSuite
132
{
133
public
:
134
NetworkStatusTestSuite
();
//!< Default constructor
135
};
136
137
NetworkStatusTestSuite::NetworkStatusTestSuite
()
138
:
TestSuite
(
"network-status"
,
Type
::UNIT)
139
{
140
LogComponentEnable
(
"NetworkStatusTestSuite"
,
LOG_LEVEL_DEBUG
);
141
// TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
142
AddTestCase
(
new
EndDeviceStatusTest
,
Duration::QUICK
);
143
AddTestCase
(
new
NetworkStatusTest
,
Duration::QUICK
);
144
}
145
146
// Do not forget to allocate an instance of this TestSuite
147
static
NetworkStatusTestSuite
lorawanTestSuite
;
EndDeviceStatusTest
It tests the constructor of the EndDeviceStatus class.
Definition:
network-status-test-suite.cc:48
EndDeviceStatusTest::EndDeviceStatusTest
EndDeviceStatusTest()
Default constructor.
Definition:
network-status-test-suite.cc:58
EndDeviceStatusTest::~EndDeviceStatusTest
~EndDeviceStatusTest() override
Destructor.
Definition:
network-status-test-suite.cc:64
EndDeviceStatusTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
network-status-test-suite.cc:71
NetworkStatusTest
It tests the function NetworkStatus::AddNode.
Definition:
network-status-test-suite.cc:85
NetworkStatusTest::NetworkStatusTest
NetworkStatusTest()
Default constructor.
Definition:
network-status-test-suite.cc:95
NetworkStatusTest::~NetworkStatusTest
~NetworkStatusTest() override
Destructor.
Definition:
network-status-test-suite.cc:101
NetworkStatusTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
network-status-test-suite.cc:108
NetworkStatusTestSuite
The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the TestCases...
Definition:
network-status-test-suite.cc:132
NetworkStatusTestSuite::NetworkStatusTestSuite
NetworkStatusTestSuite()
Default constructor.
Definition:
network-status-test-suite.cc:137
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:40
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:78
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::TestCase
encapsulates test code
Definition:
test.h:1061
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:302
ns3::TestCase::Duration::QUICK
@ QUICK
Fast test.
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1273
ns3::TestSuite::Type
Type
Type of test.
Definition:
test.h:1280
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:83
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:49
ns3::lorawan::NetworkStatus::AddNode
void AddNode(Ptr< ClassAEndDeviceLorawanMac > edMac)
Add a device to the ones that are tracked by this NetworkStatus object.
Definition:
network-status.cc:63
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition:
log.h:268
ns3::lorawan::InitializeNetwork
NetworkComponents InitializeNetwork(int nDevices, int nGateways)
Definition:
utilities.cc:128
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::LogComponentEnable
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition:
log.cc:302
ns3::LOG_LEVEL_DEBUG
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
Definition:
log.h:113
lorawanTestSuite
static NetworkStatusTestSuite lorawanTestSuite
Definition:
network-status-test-suite.cc:147
ns3::lorawan::NetworkComponents
Stores the main elements of a simulated LoRaWAN network.
Definition:
utilities.h:40
ns3::lorawan::NetworkComponents::channel
Ptr< LoraChannel > channel
A pointer to the LoraChannel object.
Definition:
utilities.h:41
ns3::lorawan::NetworkComponents::endDevices
NodeContainer endDevices
Container of the end device nodes.
Definition:
utilities.h:42
ns3::lorawan::NetworkComponents::gateways
NodeContainer gateways
Container of the gateway nodes.
Definition:
utilities.h:43
utilities.h
src
lorawan
test
network-status-test-suite.cc
Generated on Mon Aug 12 2024 11:16:15 for ns-3 by
1.9.6